Skip to content

Commit 908b0a7

Browse files
Subject view
1 parent c6f9c58 commit 908b0a7

File tree

3 files changed

+160
-22
lines changed

3 files changed

+160
-22
lines changed

staff_features/shared/step_definitions.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
wait_for_ajax if current_url.include? "resources/#{@resource_id}/edit"
4848
end
4949

50+
When 'the user hovers on {string} in the dropdown menu' do |string|
51+
within '.dropdown-menu' do
52+
element = find(:xpath, "//button[contains(text(), '#{string}')] | //a[contains(text(), '#{string}')]")
53+
54+
element.hover
55+
end
56+
end
57+
5058
When 'the user clicks on {string} in the record toolbar' do |string|
5159
within '.record-toolbar' do
5260
click_on_string string
@@ -70,7 +78,9 @@
7078
end
7179

7280
When 'the user clicks on {string} in the dropdown menu' do |string|
73-
within '.dropdown-menu' do |dropdown_menu|
81+
dropdown_menus = all('.dropdown-menu')
82+
83+
within dropdown_menus.first do |dropdown_menu|
7484
elements = dropdown_menu.all(:xpath, ".//*[contains(text(), '#{string}')]")
7585

7686
elements.each do |element|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# frozen_string_literal: true
2+
3+
Given 'a Subject has been created' do
4+
visit "#{STAFF_URL}/subjects/new"
5+
6+
fill_in 'subject_terms__0__term_', with: "subject_term_#{@uuid}"
7+
select 'Art & Architecture Thesaurus', from: 'subject_source_'
8+
select 'Cultural context', from: 'subject_terms__0__term_type_'
9+
10+
click_on 'Save'
11+
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Subject Created'
12+
13+
uri_parts = current_url.split('/')
14+
uri_parts.pop
15+
@subject_id = uri_parts.pop
16+
end
17+
18+
Then 'the two Subjects are displayed sorted by ascending identifier' do
19+
search_result_rows = all('#tabledSearchResults tbody tr')
20+
21+
expect(search_result_rows.length).to eq 2
22+
expect(search_result_rows[1]).to have_text @accession_a_uuid
23+
expect(search_result_rows[0]).to have_text @accession_b_uuid
24+
end
25+
26+
Then 'the two Subjects are displayed sorted by ascending level' do
27+
search_result_rows = all('#tabledSearchResults tbody tr')
28+
29+
expect(search_result_rows.length).to eq 2
30+
expect(search_result_rows[1]).to have_text @accession_a_uuid
31+
expect(search_result_rows[0]).to have_text @accession_b_uuid
32+
end
33+
34+
When 'the user filters by text with the Subject term' do
35+
fill_in 'Filter by text', with: "subject_term_#{@uuid}"
36+
37+
find('#filter-text').send_keys(:enter)
38+
39+
rows = []
40+
checks = 0
41+
42+
while checks < 5
43+
checks += 1
44+
45+
begin
46+
rows = all('tr', text: @uuid)
47+
rescue Selenium::WebDriver::Error::JavascriptError
48+
sleep 1
49+
end
50+
51+
break if rows.length == 1
52+
end
53+
end
54+
55+
Given 'two Subjects have been created with a common keyword in their term' do
56+
@shared_subject_uuid = SecureRandom.uuid
57+
@subject_a_uuid = SecureRandom.uuid
58+
@subject_b_uuid = SecureRandom.uuid
59+
60+
visit "#{STAFF_URL}/subjects/new"
61+
fill_in 'subject_terms__0__term_', with: "Subject A #{@subject_a_uuid} #{@shared_subject_uuid}"
62+
select 'Art & Architecture Thesaurus', from: 'subject_source_'
63+
select 'Cultural context', from: 'subject_terms__0__term_type_'
64+
click_on 'Save'
65+
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Subject Created'
66+
uri_parts = current_url.split('/')
67+
uri_parts.pop
68+
@subject_a_id = uri_parts.pop
69+
70+
visit "#{STAFF_URL}/subjects/new"
71+
fill_in 'subject_terms__0__term_', with: "Subject B #{@subject_b_uuid} #{@shared_subject_uuid}"
72+
select 'Art & Architecture Thesaurus', from: 'subject_source_'
73+
select 'Cultural context', from: 'subject_terms__0__term_type_'
74+
click_on 'Save'
75+
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Subject Created'
76+
uri_parts = current_url.split('/')
77+
uri_parts.pop
78+
@subject_b_id = uri_parts.pop
79+
end
80+
81+
Then 'the Subject is in the search results' do
82+
expect(page).to have_css('tr', text: @uuid)
83+
end
84+
85+
Then 'the two Subjects are displayed sorted by descending title' do
86+
search_result_rows = all('#tabledSearchResults tbody tr')
87+
88+
expect(search_result_rows.length).to eq 2
89+
expect(search_result_rows[1]).to have_text @subject_a_uuid
90+
expect(search_result_rows[0]).to have_text @subject_b_uuid
91+
end
92+
93+
Then 'the Subject view page is displayed' do
94+
expect(find('h2').text).to eq "subject_term_#{@uuid} Subject"
95+
expect(current_url).to eq "#{STAFF_URL}/subjects/#{@subject_id}"
96+
end
97+
98+
Given 'the two Subjects are displayed sorted by ascending term' do
99+
visit "#{STAFF_URL}/subjects"
100+
101+
fill_in 'filter-text', with: @shared_subject_uuid
102+
103+
within '.search-filter' do
104+
find('button').click
105+
end
106+
107+
search_result_rows = all('#tabledSearchResults tbody tr')
108+
109+
expect(search_result_rows.length).to eq 2
110+
expect(search_result_rows[0]).to have_text @subject_a_uuid
111+
expect(search_result_rows[1]).to have_text @subject_b_uuid
112+
end
113+
114+
Then 'the two Subjects are displayed sorted by descending term' do
115+
search_result_rows = all('#tabledSearchResults tbody tr')
116+
117+
expect(search_result_rows.length).to eq 2
118+
expect(search_result_rows[1]).to have_text @subject_a_uuid
119+
expect(search_result_rows[0]).to have_text @subject_b_uuid
120+
end
121+
122+
Then 'the two Subjects are displayed sorted by ascending created date' do
123+
search_result_rows = all('#tabledSearchResults tbody tr')
124+
125+
expect(search_result_rows.length).to eq 2
126+
expect(search_result_rows[0]).to have_text @subject_a_uuid
127+
expect(search_result_rows[1]).to have_text @subject_b_uuid
128+
end
129+
130+
Then 'the two Subjects are displayed sorted by ascending modified date' do
131+
search_result_rows = all('#tabledSearchResults tbody tr')
132+
133+
expect(search_result_rows.length).to eq 2
134+
expect(search_result_rows[0]).to have_text @subject_a_uuid
135+
expect(search_result_rows[1]).to have_text @subject_b_uuid
136+
end

staff_features/subjects/subject_view.feature

+13-21
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,31 @@ Feature: Subject View
55
Given a Subject has been created
66
When the user clicks on 'Browse'
77
And the user clicks on 'Subjects'
8-
And the user filters by text with the Subject title
8+
And the user filters by text with the Subject term
99
Then the Subject is in the search results
1010
Scenario: View Subject from the search results
1111
Given a Subject has been created
1212
When the user clicks on 'Browse'
1313
And the user clicks on 'Subjects'
14-
And the user filters by text with the Subject title
14+
And the user filters by text with the Subject term
1515
And the user clicks on 'View'
1616
Then the Subject view page is displayed
1717
Scenario: Sort Subjects by term
18-
Given two Subjects have been created with a common keyword in their terms
18+
Given two Subjects have been created with a common keyword in their term
1919
And the two Subjects are displayed sorted by ascending term
20-
When the user clicks on 'Term'
20+
When the user clicks on 'Terms'
2121
Then the two Subjects are displayed sorted by descending term
22-
Scenario: Sort Subjects by term type
23-
Given two subjects have been created with a common keyword in their terms
22+
Scenario: Sort Subjects by date created
23+
Given two Subjects have been created with a common keyword in their term
2424
And the two Subjects are displayed sorted by ascending term
25-
When the user clicks on 'Term Type'
26-
Then the two Subjects are displayed sorted by ascending term type
27-
Scenario: Sort Subjects by source
28-
Given two Subjects have been created with a common keyword in their terms
29-
And the two Subjects are displayed sorted by ascending term
30-
When the user clicks on 'Source'
31-
Then the two Subjects are displayed sorted by ascending source
32-
Scenario: Sort Subjects by created date
33-
Given two Subjects have been created with a common keyword in their terms
34-
And the two Subjects are displayed sorted by ascending term
35-
When the user clicks on 'Sort by' in the dropdown menu
36-
And the user clicks on 'Ascending' in 'Created' in the dropdown submenu
25+
When the user clicks on 'Terms Ascending'
26+
And the user hovers on 'Created' in the dropdown menu
27+
And the user clicks on 'Ascending' in the dropdown menu
3728
Then the two Subjects are displayed sorted by ascending created date
3829
Scenario: Sort Subjects by modified date
39-
Given two Subjects have been created with a common keyword in their terms
30+
Given two Subjects have been created with a common keyword in their term
4031
And the two Subjects are displayed sorted by ascending term
41-
When the user clicks on 'Sort by' in the dropdown menu
42-
And the user clicks on 'Ascending' in 'Modified' in the dropdown submenu
32+
When the user clicks on 'Terms Ascending'
33+
And the user hovers on 'Modified' in the dropdown menu
34+
And the user clicks on 'Ascending' in the dropdown menu
4335
Then the two Subjects are displayed sorted by ascending modified date

0 commit comments

Comments
 (0)