-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
182 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
staff_features/subjects/step_definitions/subject_view.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# frozen_string_literal: true | ||
|
||
Given 'a Subject has been created' do | ||
visit "#{STAFF_URL}/subjects/new" | ||
|
||
fill_in 'subject_terms__0__term_', with: "subject_term_#{@uuid}" | ||
select 'Art & Architecture Thesaurus', from: 'subject_source_' | ||
select 'Cultural context', from: 'subject_terms__0__term_type_' | ||
|
||
click_on 'Save' | ||
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Subject Created' | ||
|
||
uri_parts = current_url.split('/') | ||
uri_parts.pop | ||
@subject_id = uri_parts.pop | ||
end | ||
|
||
Then 'the two Subjects are displayed sorted by ascending identifier' do | ||
search_result_rows = all('#tabledSearchResults tbody tr') | ||
|
||
expect(search_result_rows.length).to eq 2 | ||
expect(search_result_rows[1]).to have_text @accession_a_uuid | ||
expect(search_result_rows[0]).to have_text @accession_b_uuid | ||
end | ||
|
||
Then 'the two Subjects are displayed sorted by ascending level' do | ||
search_result_rows = all('#tabledSearchResults tbody tr') | ||
|
||
expect(search_result_rows.length).to eq 2 | ||
expect(search_result_rows[1]).to have_text @accession_a_uuid | ||
expect(search_result_rows[0]).to have_text @accession_b_uuid | ||
end | ||
|
||
When 'the user filters by text with the Subject term' do | ||
fill_in 'Filter by text', with: "subject_term_#{@uuid}" | ||
|
||
find('#filter-text').send_keys(:enter) | ||
|
||
rows = [] | ||
checks = 0 | ||
|
||
while checks < 5 | ||
checks += 1 | ||
|
||
begin | ||
rows = all('tr', text: @uuid) | ||
rescue Selenium::WebDriver::Error::JavascriptError | ||
sleep 1 | ||
end | ||
|
||
break if rows.length == 1 | ||
end | ||
end | ||
|
||
Given 'two Subjects have been created with a common keyword in their term' do | ||
@shared_subject_uuid = SecureRandom.uuid | ||
@subject_a_uuid = SecureRandom.uuid | ||
@subject_b_uuid = SecureRandom.uuid | ||
|
||
visit "#{STAFF_URL}/subjects/new" | ||
fill_in 'subject_terms__0__term_', with: "Subject A #{@subject_a_uuid} #{@shared_subject_uuid}" | ||
select 'Art & Architecture Thesaurus', from: 'subject_source_' | ||
select 'Cultural context', from: 'subject_terms__0__term_type_' | ||
click_on 'Save' | ||
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Subject Created' | ||
uri_parts = current_url.split('/') | ||
uri_parts.pop | ||
@subject_a_id = uri_parts.pop | ||
|
||
visit "#{STAFF_URL}/subjects/new" | ||
fill_in 'subject_terms__0__term_', with: "Subject B #{@subject_b_uuid} #{@shared_subject_uuid}" | ||
select 'Art & Architecture Thesaurus', from: 'subject_source_' | ||
select 'Cultural context', from: 'subject_terms__0__term_type_' | ||
click_on 'Save' | ||
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Subject Created' | ||
uri_parts = current_url.split('/') | ||
uri_parts.pop | ||
@subject_b_id = uri_parts.pop | ||
end | ||
|
||
Then 'the Subject is in the search results' do | ||
expect(page).to have_css('tr', text: @uuid) | ||
end | ||
|
||
Then 'the two Subjects are displayed sorted by descending title' do | ||
search_result_rows = all('#tabledSearchResults tbody tr') | ||
|
||
expect(search_result_rows.length).to eq 2 | ||
expect(search_result_rows[1]).to have_text @subject_a_uuid | ||
expect(search_result_rows[0]).to have_text @subject_b_uuid | ||
end | ||
|
||
Then 'the Subject view page is displayed' do | ||
expect(find('h2').text).to eq "subject_term_#{@uuid} Subject" | ||
expect(current_url).to eq "#{STAFF_URL}/subjects/#{@subject_id}" | ||
end | ||
|
||
Given 'the two Subjects are displayed sorted by ascending term' do | ||
visit "#{STAFF_URL}/subjects" | ||
|
||
fill_in 'filter-text', with: @shared_subject_uuid | ||
|
||
within '.search-filter' do | ||
find('button').click | ||
end | ||
|
||
search_result_rows = all('#tabledSearchResults tbody tr') | ||
|
||
expect(search_result_rows.length).to eq 2 | ||
expect(search_result_rows[0]).to have_text @subject_a_uuid | ||
expect(search_result_rows[1]).to have_text @subject_b_uuid | ||
end | ||
|
||
Then 'the two Subjects are displayed sorted by descending term' do | ||
search_result_rows = all('#tabledSearchResults tbody tr') | ||
|
||
expect(search_result_rows.length).to eq 2 | ||
expect(search_result_rows[1]).to have_text @subject_a_uuid | ||
expect(search_result_rows[0]).to have_text @subject_b_uuid | ||
end | ||
|
||
Then 'the two Subjects are displayed sorted by ascending created date' do | ||
search_result_rows = all('#tabledSearchResults tbody tr') | ||
|
||
expect(search_result_rows.length).to eq 2 | ||
expect(search_result_rows[0]).to have_text @subject_a_uuid | ||
expect(search_result_rows[1]).to have_text @subject_b_uuid | ||
end | ||
|
||
Then 'the two Subjects are displayed sorted by ascending modified date' do | ||
search_result_rows = all('#tabledSearchResults tbody tr') | ||
|
||
expect(search_result_rows.length).to eq 2 | ||
expect(search_result_rows[0]).to have_text @subject_a_uuid | ||
expect(search_result_rows[1]).to have_text @subject_b_uuid | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Feature: Subject View | ||
Background: | ||
Given an administrator user is logged in | ||
Scenario: Search Subject by title | ||
Given a Subject has been created | ||
When the user clicks on 'Browse' | ||
And the user clicks on 'Subjects' | ||
And the user filters by text with the Subject term | ||
Then the Subject is in the search results | ||
Scenario: View Subject from the search results | ||
Given a Subject has been created | ||
When the user clicks on 'Browse' | ||
And the user clicks on 'Subjects' | ||
And the user filters by text with the Subject term | ||
And the user clicks on 'View' | ||
Then the Subject view page is displayed | ||
Scenario: Sort Subjects by term | ||
Given two Subjects have been created with a common keyword in their term | ||
And the two Subjects are displayed sorted by ascending term | ||
When the user clicks on 'Terms' | ||
Then the two Subjects are displayed sorted by descending term | ||
Scenario: Sort Subjects by date created | ||
Given two Subjects have been created with a common keyword in their term | ||
And the two Subjects are displayed sorted by ascending term | ||
When the user clicks on 'Terms Ascending' | ||
And the user hovers on 'Created' in the dropdown menu | ||
And the user clicks on 'Ascending' in the dropdown menu | ||
Then the two Subjects are displayed sorted by ascending created date | ||
Scenario: Sort Subjects by modified date | ||
Given two Subjects have been created with a common keyword in their term | ||
And the two Subjects are displayed sorted by ascending term | ||
When the user clicks on 'Terms Ascending' | ||
And the user hovers on 'Modified' in the dropdown menu | ||
And the user clicks on 'Ascending' in the dropdown menu | ||
Then the two Subjects are displayed sorted by ascending modified date |