-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.rb
92 lines (68 loc) · 2.8 KB
/
helpers.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# frozen_string_literal: true
def search(uuid)
visit STAFF_URL
fill_in 'global-search-box', with: uuid
find('#global-search-button').click
end
def login_admin
visit STAFF_URL
fill_in 'username', with: 'admin'
fill_in 'password', with: 'admin'
click_on 'Sign In'
expect(page).to have_content 'Welcome to ArchivesSpace'
expect(page).to have_content 'Your friendly archives management tool.'
element = find('.global-header .user-container')
expect(element.text.strip).to eq 'admin'
# Ensure the system has at least one repository
begin
element = find('.alert.alert-info.with-hide-alert')
if element.text == 'To create your first Repository, click the System menu above and then Manage Repositories.'
click_on 'System'
click_on 'Manage Repositories'
click_on 'Create Repository'
fill_in 'repository_repository__repo_code_', with: 'repository_test'
fill_in 'repository_repository__name_', with: 'Repository Test'
find('#repository_repository__publish_').check
click_on 'Save'
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Repository Created'
expect(find('.alert.alert-info.with-hide-alert').text).to eq 'Repository is Currently Selected'
visit STAFF_URL
end
rescue Capybara::ElementNotFound
# Continue
end
end
def create_resource(uuid)
fill_in 'resource_title_', with: "Resource #{uuid}"
fill_in 'resource_id_0_', with: "Resource #{uuid}"
select 'Class', from: 'resource_level_'
element = find('#resource_lang_materials__0__language_and_script__language_')
element.send_keys('AU')
element.send_keys(:tab)
select 'Single', from: 'resource_dates__0__date_type_'
fill_in 'resource_dates__0__begin_', with: '2024'
fill_in 'resource_extents__0__number_', with: '10'
select 'Cassettes', from: 'resource_extents__0__extent_type_'
element = find('#resource_finding_aid_language_')
element.send_keys('ENG')
element.send_keys(:tab)
element = find('#resource_finding_aid_script_')
element.send_keys('Latin')
element.send_keys(:tab)
find('button', text: 'Save Resource', match: :first).click
expect(page).to have_text "Resource Resource #{uuid} created"
end
def expect_record_to_be_in_search_results(search_term)
fill_in 'global-search-box', with: search_term
find('#global-search-button').click
search_result_rows = all('#tabledSearchResults tbody tr')
expect(search_result_rows.length).to eq 1
expect(search_result_rows[0].text).to include search_term
end
def expect_record_to_not_be_in_search_results(search_term)
fill_in 'global-search-box', with: search_term
find('#global-search-button').click
search_result_rows = all('#tabledSearchResults tbody tr')
expect(search_result_rows.length).to eq 0
expect(find('.alert.alert-info.with-hide-alert').text).to eq 'No records found'
end