Merge branch 'master' into 3140-project-content-tabs
[arvados.git] / apps / workbench / test / integration / projects_test.rb
1 require 'integration_helper'
2 require 'selenium-webdriver'
3 require 'headless'
4
5 class ProjectsTest < ActionDispatch::IntegrationTest
6   setup do
7     Capybara.current_driver = Capybara.javascript_driver
8   end
9
10   test 'Find a project and edit its description' do
11     visit page_with_token 'active', '/'
12     find('.arv-project-list a,button', text: 'A Project').
13       click
14     within('.container-fluid', text: api_fixture('groups')['aproject']['name']) do
15       find('span', text: api_fixture('groups')['aproject']['name']).click
16       within('.arv-description-as-subtitle') do
17         find('.fa-pencil').click
18         find('.editable-input textarea').set('I just edited this.')
19         find('.editable-submit').click
20       end
21       wait_for_ajax
22     end
23     visit current_path
24     assert(find?('.container-fluid', text: 'I just edited this.'),
25            "Description update did not survive page refresh")
26   end
27
28   test 'Add a new name, then edit it, without creating a duplicate' do
29     project_uuid = api_fixture('groups')['aproject']['uuid']
30     specimen_uuid = api_fixture('specimens')['owned_by_aproject_with_no_name_link']['uuid']
31     visit page_with_token 'active', '/projects/' + project_uuid
32     click_link 'Other objects'
33     within(".selection-action-container") do
34       within (first('tr', text: 'Specimen')) do
35         find(".fa-pencil").click
36         find('.editable-input input').set('Now I have a name.')
37         find('.glyphicon-ok').click
38         find('.editable', text: 'Now I have a name.').click
39         find(".fa-pencil").click
40         find('.editable-input input').set('Now I have a new name.')
41         find('.glyphicon-ok').click
42         end
43       wait_for_ajax
44       find('.editable', text: 'Now I have a new name.')
45     end
46     visit current_path
47     click_link 'Other objects'
48     within '.selection-action-container' do
49       find '.editable', text: 'Now I have a new name.'
50       page.assert_no_selector '.editable', text: 'Now I have a name.'
51     end
52   end
53
54   test 'Create a project and move it into a different project' do
55     visit page_with_token 'active', '/projects'
56     find('.btn', text: "Add new project").click
57
58     # within('.editable', text: 'New project') do
59     within('h2') do
60       find('.fa-pencil').click
61       find('.editable-input input').set('Project 1234')
62       find('.glyphicon-ok').click
63     end
64     wait_for_ajax
65
66     visit '/projects'
67     find('.btn', text: "Add new project").click
68     within('h2') do
69       find('.fa-pencil').click
70       find('.editable-input input').set('Project 5678')
71       find('.glyphicon-ok').click
72     end
73     wait_for_ajax
74
75     click_link 'Move project...'
76     find('.selectable', text: 'Project 1234').click
77     find('.modal-footer a,button', text: 'Move').click
78     wait_for_ajax
79
80     # Wait for the page to refresh and show the new parent in Permissions panel
81     click_link 'Permissions'
82     find('.panel', text: 'Project 1234')
83
84     assert(find('.panel', text: 'Permissions for this project are inherited by the owner or parent project').
85            all('*', text: 'Project 1234').any?,
86            "Project 5678 should now be inside project 1234")
87   end
88
89 end