Skip to content

Commit 3fed532

Browse files
authored
Subject View (#75)
1 parent 7caae0a commit 3fed532

File tree

3 files changed

+182
-1
lines changed

3 files changed

+182
-1
lines changed

staff_features/shared/step_definitions.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
current_url.include?("digital_objects/#{@digital_object_id}/edit")
4949
end
5050

51+
When 'the user hovers on {string} in the dropdown menu' do |string|
52+
within '.dropdown-menu' do
53+
element = find(:xpath, "//button[contains(text(), '#{string}')] | //a[contains(text(), '#{string}')]")
54+
55+
element.hover
56+
end
57+
end
58+
5159
When 'the user clicks on {string} in the record toolbar' do |string|
5260
within '.record-toolbar' do
5361
click_on_string string
@@ -73,7 +81,9 @@
7381
When 'the user clicks on {string} in the dropdown menu' do |string|
7482
dropdown_menu = all('.dropdown-menu').first
7583

76-
within dropdown_menu do
84+
dropdown_menus = all('.dropdown-menu')
85+
86+
within dropdown_menus.first do |dropdown_menu|
7787
elements = dropdown_menu.all(:xpath, ".//*[contains(text(), '#{string}')]")
7888

7989
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Feature: Subject View
2+
Background:
3+
Given an administrator user is logged in
4+
Scenario: Search Subject by title
5+
Given a Subject has been created
6+
When the user clicks on 'Browse'
7+
And the user clicks on 'Subjects'
8+
And the user filters by text with the Subject term
9+
Then the Subject is in the search results
10+
Scenario: View Subject from the search results
11+
Given a Subject has been created
12+
When the user clicks on 'Browse'
13+
And the user clicks on 'Subjects'
14+
And the user filters by text with the Subject term
15+
And the user clicks on 'View'
16+
Then the Subject view page is displayed
17+
Scenario: Sort Subjects by term
18+
Given two Subjects have been created with a common keyword in their term
19+
And the two Subjects are displayed sorted by ascending term
20+
When the user clicks on 'Terms'
21+
Then the two Subjects are displayed sorted by descending term
22+
Scenario: Sort Subjects by date created
23+
Given two Subjects have been created with a common keyword in their term
24+
And the two Subjects are displayed sorted by ascending term
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
28+
Then the two Subjects are displayed sorted by ascending created date
29+
Scenario: Sort Subjects by modified date
30+
Given two Subjects have been created with a common keyword in their term
31+
And the two Subjects are displayed sorted by ascending term
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
35+
Then the two Subjects are displayed sorted by ascending modified date

0 commit comments

Comments
 (0)