Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit 94450c0

Browse files
Speed up tests (#131)
1 parent ea80386 commit 94450c0

File tree

1 file changed

+20
-57
lines changed

1 file changed

+20
-57
lines changed

helpers/helpers.rb

Lines changed: 20 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ def login_archivist
6969

7070
# Ensure the system has at least one repository
7171
def ensure_test_repository_exists
72-
element = find('.alert.alert-info.with-hide-alert')
72+
menu_items = all('.global-header .global-header-nav li')
7373

74-
if element.text == 'To create your first Repository, click the System menu above and then Manage Repositories.'
74+
# Three items on the header menu means no repository has been created yet.
75+
if menu_items.length == 3
7576
click_on 'System'
7677
click_on 'Manage Repositories'
7778
click_on 'Create Repository'
@@ -87,8 +88,6 @@ def ensure_test_repository_exists
8788
visit STAFF_URL
8889
end
8990

90-
select_test_repository
91-
rescue Capybara::ElementNotFound
9291
select_test_repository
9392
end
9493

@@ -122,68 +121,32 @@ def ensure_test_user_exists
122121
end
123122

124123
def ensure_test_agent_exists
125-
visit STAFF_URL
126-
127-
fill_in 'global-search-box', with: 'test_agent'
128-
find('#global-search-button').click
129-
130-
begin
131-
find 'tr', text: 'test_agent'
132-
rescue Capybara::ElementNotFound
133-
visit "#{STAFF_URL}/agents/agent_person/new"
134-
check 'Publish'
135-
fill_in 'Primary Part of Name', with: 'test_agent'
136-
click_on 'Save'
137-
end
124+
visit "#{STAFF_URL}/agents/agent_person/new"
125+
check 'Publish'
126+
fill_in 'Primary Part of Name', with: 'test_agent'
127+
click_on 'Save'
138128
end
139129

140130
def ensure_test_subject_exists
141-
visit STAFF_URL
142-
143-
fill_in 'global-search-box', with: 'test_subject'
144-
find('#global-search-button').click
145-
146-
begin
147-
find 'tr', text: 'test_subject'
148-
rescue Capybara::ElementNotFound
149-
visit "#{STAFF_URL}/subjects/new"
150-
select 'Art & Architecture Thesaurus', from: 'subject_source_'
151-
fill_in 'subject_terms__0__term_', with: 'test_subject_term'
152-
select 'Cultural context', from: 'subject_terms__0__term_type_'
153-
click_on 'Save'
154-
end
131+
visit "#{STAFF_URL}/subjects/new"
132+
select 'Art & Architecture Thesaurus', from: 'subject_source_'
133+
fill_in 'subject_terms__0__term_', with: 'test_subject_term'
134+
select 'Cultural context', from: 'subject_terms__0__term_type_'
135+
click_on 'Save'
155136
end
156137

157138
def ensure_test_accession_exists
158-
visit STAFF_URL
159-
160-
fill_in 'global-search-box', with: 'test_accession'
161-
find('#global-search-button').click
162-
163-
begin
164-
find 'tr', text: 'test_accession'
165-
rescue Capybara::ElementNotFound
166-
visit "#{STAFF_URL}/accessions/new"
167-
fill_in 'accession_id_0_', with: 'test_accession'
168-
fill_in 'accession_title_', with: 'test_accession'
169-
click_on 'Save'
170-
end
139+
visit "#{STAFF_URL}/accessions/new"
140+
fill_in 'accession_id_0_', with: 'test_accession'
141+
fill_in 'accession_title_', with: 'test_accession'
142+
click_on 'Save'
171143
end
172144

173145
def ensure_test_classification_exists
174-
visit STAFF_URL
175-
176-
fill_in 'global-search-box', with: 'test_classification'
177-
find('#global-search-button').click
178-
179-
begin
180-
find 'tr', text: 'test_classification'
181-
rescue Capybara::ElementNotFound
182-
visit "#{STAFF_URL}/classifications/new"
183-
fill_in 'classification_identifier_', with: 'test_classification'
184-
fill_in 'classification_title_', with: 'test_classification'
185-
click_on 'Save'
186-
end
146+
visit "#{STAFF_URL}/classifications/new"
147+
fill_in 'classification_identifier_', with: 'test_classification'
148+
fill_in 'classification_title_', with: 'test_classification'
149+
click_on 'Save'
187150
end
188151

189152
def ensure_test_location_exists

0 commit comments

Comments
 (0)