Skip to content

Commit 57abf99

Browse files
Accession edit step definitions
1 parent 6abe693 commit 57abf99

File tree

8 files changed

+43
-8
lines changed

8 files changed

+43
-8
lines changed

.rubocop.yml

+6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ Metrics/AbcSize:
99
Metrics/MethodLength:
1010
Max: 50
1111

12+
Layout/LineLength:
13+
Max: 180
14+
1215
Layout/ElseAlignment:
1316
Enabled: false
1417

1518
Style/ConditionalAssignment:
1619
Enabled: false
20+
21+
Style/NumericPredicate:
22+
Enabled: false

env.rb

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
Capybara::Selenium::Driver.new(app, browser: :firefox, options:)
3030
end
3131

32+
Capybara.register_driver :firefox_alternative_session do |app|
33+
options = Selenium::WebDriver::Firefox::Options.new
34+
options.add_argument(HEADLESS)
35+
36+
Capybara::Selenium::Driver.new(app, browser: :firefox, options:)
37+
end
38+
3239
Capybara.default_driver = :firefox
3340
Capybara.default_max_wait_time = 10
3441

helpers/helpers.rb

+18-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ def login_archivist
6767
end
6868
end
6969

70+
# Ensure the system has at least one repository
7071
def ensure_test_repository_exists
71-
# Ensure the system has at least one repository
72-
7372
element = find('.alert.alert-info.with-hide-alert')
7473

7574
if element.text == 'To create your first Repository, click the System menu above and then Manage Repositories.'
@@ -91,6 +90,23 @@ def ensure_test_repository_exists
9190
# Continue
9291
end
9392

93+
def ensure_test_user_exists
94+
visit "#{STAFF_URL}/users/new"
95+
96+
fill_in 'user_username_', with: 'test'
97+
fill_in 'user_name_', with: 'test'
98+
fill_in 'user_password_', with: 'test'
99+
fill_in 'user_confirm_password_', with: 'test'
100+
check 'user_is_admin_'
101+
102+
click_on 'Create Account', match: :first
103+
104+
raise 'Could not create test user' if page.has_text?('User not created') &&
105+
!page.has_text?("Username - Username 'test' is already in use")
106+
107+
visit STAFF_URL
108+
end
109+
94110
def find_user_table_row_in_manage_user_access_page(username)
95111
loop do
96112
begin

staff_features/accessions/accession_delete.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Feature: Accession Delete
1616
When the user clicks on 'Delete'
1717
And the user clicks on 'Delete' in the confirm popup
1818
Then the Accessions page is displayed
19-
And the 'Accession deleted' message is displayed
19+
And the 'Accession' deleted message is displayed
2020
And the Accession is deleted
2121
Scenario: Cancel Accession delete from the view page
2222
Given the user is on the Accession view page

staff_features/accessions/step_definitions/accession_delete.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
end
6565

6666
Then 'the user is still on the Accession view page' do
67-
expect(find('h2').text).to eq "Accession #{@uuid} Accession"
67+
expect(find('h2').text).to eq "Accession Title #{@uuid} Accession"
6868
end
6969

7070
Then 'the Accessions page is displayed' do

staff_features/accessions/step_definitions/accession_edit.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,14 @@
127127
end
128128

129129
Given 'the Accession is opened in edit mode by User B' do
130-
@session = Capybara::Session.new(:selenium)
130+
@session = Capybara::Session.new(:firefox_alternative_session)
131+
131132
@session.visit(STAFF_URL)
132133

133134
@session.fill_in 'username', with: 'test'
134135
@session.fill_in 'password', with: 'test'
135-
136136
@session.click_on 'Sign In'
137+
expect(@session).to have_text 'Welcome to ArchivesSpace'
137138

138139
@session.click_on 'Browse'
139140
@session.click_on 'Accessions'
@@ -169,7 +170,7 @@
169170
break if tries == 0
170171

171172
begin
172-
tries = tries - 1
173+
tries -= 1
173174

174175
element = @session.find('#form_messages .alert.alert-warning.update-monitor-error')
175176
expect(element.text).to eq 'This record is currently being edited by another user. Please contact the following users to ensure no conflicts occur: admin'

staff_features/accessions/step_definitions/accessions_search.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
end
1010

1111
Then 'the Accession view page is displayed' do
12-
expect(find('h2').text).to eq "Accession #{@uuid} Accession"
12+
expect(find('h2').text).to eq "Accession Title #{@uuid} Accession"
1313
end
1414

1515
Given 'two Accessions have been created with a common keyword in their title' do

staff_features/shared/step_definitions.rb

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
login_admin
99

1010
ensure_test_repository_exists
11+
ensure_test_user_exists
1112
end
1213

1314
Given 'an archivist user is logged in' do
@@ -54,6 +55,10 @@
5455
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*updated$/i)
5556
end
5657

58+
Then('the {string} deleted message is displayed') do |string|
59+
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*deleted$/i)
60+
end
61+
5762
Then 'the following error messages are displayed' do |messages|
5863
messages.raw.each do |message|
5964
expect(page).to have_text message[0]

0 commit comments

Comments
 (0)