1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
8 require 'integration_helper'
10 class JobsTest < ActionDispatch::IntegrationTest
15 def fakepipe_with_log_data
17 "2014-01-01_12:00:01 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 1\n" +
18 "2014-01-01_12:00:02 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 2\n" +
19 "2014-01-01_12:00:03 zzzzz-8i9sb-0vsrcqi7whchuil 0 log message 3\n"
20 StringIO.new content, 'r'
25 ['job_reader2', false],
26 ].each do |user, readable|
27 test "view job with components as #{user} user" do
28 Rails.configuration.Users.AnonymousUserToken = ""
29 job = api_fixture('jobs')['running_job_with_components']
30 component1 = api_fixture('jobs')['completed_job_in_publicly_accessible_project']
31 component2 = api_fixture('pipeline_instances')['running_pipeline_with_complete_job']
32 component2_child1 = api_fixture('jobs')['previous_job_run']
33 component2_child2 = api_fixture('jobs')['running']
35 visit page_with_token(user, "/jobs/#{job['uuid']}")
36 assert page.has_text? job['script_version']
37 assert page.has_no_text? 'script_parameters'
39 # The job_reader2 is allowed to read job, component2, and component2_child1,
40 # and component2_child2 only as a component of the pipeline component2
42 assert page.has_link? 'component1'
43 assert page.has_link? 'component2'
45 assert page.has_no_link? 'component1'
46 assert page.has_link? 'component2'
50 click_link('component1')
51 within('.panel-collapse') do
52 assert(has_text? component1['uuid'])
53 assert(has_text? component1['script_version'])
54 assert(has_text? 'script_parameters')
56 click_link('component1')
59 click_link('component2')
60 within('.panel-collapse') do
61 assert(has_text? component2['uuid'])
62 assert(has_text? component2['script_version'])
63 assert(has_no_text? 'script_parameters')
64 assert(has_link? 'previous')
65 assert(has_link? 'running')
67 click_link('previous')
68 within('.panel-collapse') do
69 assert(has_text? component2_child1['uuid'])
70 assert(has_text? component2_child1['script_version'])
72 click_link('previous')
75 within('.panel-collapse') do
76 assert(has_text? component2_child2['uuid'])
78 assert(has_text? component2_child2['script_version'])
80 assert(has_no_text? component2_child2['script_version'])