Skip to content

Commit 5819bcb

Browse files
authored
Merge pull request #749 from IU-Libraries-Joint-Development/fix_flaky_tests
bugfix: stabilize flaky feature specs
2 parents 2dc0f61 + 4386170 commit 5819bcb

6 files changed

Lines changed: 96 additions & 443 deletions

File tree

spec/features/create_archival_material_spec.rb

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6,93 +6,5 @@
66

77
# NOTE: If you generated more than one work, you have to set "js: true"
88
RSpec.feature 'Create an ArchivalMaterial', type: :system, js: true do
9-
context 'a logged in user', clean: true do
10-
let(:user) do
11-
FactoryBot.create :user
12-
end
13-
let(:admin_set_id) { AdminSet.find_or_create_default_admin_set_id }
14-
let(:permission_template) { Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set_id) }
15-
let(:workflow) { Sipity::Workflow.create!(active: true, name: 'test-workflow', permission_template: permission_template) }
16-
17-
before do
18-
# Create a single action that can be taken
19-
Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow)
20-
21-
# Grant the user access to deposit into the admin set.
22-
Hyrax::PermissionTemplateAccess.create!(
23-
permission_template_id: permission_template.id,
24-
agent_type: 'user',
25-
agent_id: user.user_key,
26-
access: 'deposit'
27-
)
28-
# Ensure empty requirement for ldap group authorization
29-
allow(ESSI.config[:authorized_ldap_groups]).to receive(:blank?).and_return(true)
30-
login_as user
31-
end
32-
33-
scenario do
34-
visit '/dashboard'
35-
click_link "Works"
36-
click_link "Add new work"
37-
expect(page).to have_content "Select type of work"
38-
39-
# If you generate more than one work uncomment these lines
40-
choose "payload_concern", option: "ArchivalMaterial"
41-
VCR.use_cassette('iucat_libraries_up') do
42-
click_button "Create work"
43-
end
44-
45-
expect(page).to have_content "Add New Archival Material"
46-
click_link "Files" # switch tab
47-
expect(page).to have_content "Add files"
48-
expect(page).to have_content "Add folder"
49-
within('span#addfiles') do
50-
attach_file(RSpec.configuration.fixture_path + "/world.png", make_visible: true)
51-
attach_file(RSpec.configuration.fixture_path + "/rgb.png", make_visible: true)
52-
end
53-
click_link "Descriptions" # switch tab
54-
fill_in('Title', with: 'My Test Work')
55-
fill_in('Source Metadata Identifier', with: ' ') # Workaround until the form is fixed for blank field
56-
click_link 'Additional fields'
57-
fill_in('Publication Place', with: 'Wells')
58-
59-
#select('In Copyright', from: 'Rights statement')
60-
61-
# With selenium and the chrome driver, focus remains on the
62-
# select box. Click outside the box so the next line can't find
63-
# its element
64-
find('body').click
65-
choose('archival_material_visibility_open')
66-
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
67-
page.driver.browser.manage.window.resize_to(1400,1400)
68-
check('agreement')
69-
70-
perform_enqueued_jobs do
71-
click_on('Save')
72-
end
73-
74-
# On works dashboard (would probably need a page refresh in actual use)
75-
expect(page).to have_content('My Test Work', count: 1)
76-
expect(page).to have_content('1 works you own in the repository')
77-
expect(page).to have_content "Your files are being processed by Digital Collections in the background."
78-
click_on('My Test Work')
79-
80-
# On work show page
81-
expect(find('.work-type')).to have_content('My Test Work')
82-
expect(page).to_not have_content "Your files are being processed by Digital Collections in the background."
83-
expect(find('li.attribute-title')).to have_content('My Test Work')
84-
click_on(I18n.t('hyrax.works.form.show_child_items'))
85-
expect(find('table.related-files')).to have_content('rgb.png')
86-
87-
click_on('Go')
88-
within '#facets' do
89-
click_on('Pages')
90-
expect(page).to have_content('0-99')
91-
click_on('Publication Place')
92-
expect(page).to have_content('Wells')
93-
click_on('State')
94-
expect(page).to have_content('deposited')
95-
end
96-
end
97-
end
9+
include_examples "create work feature spec", "ArchivalMaterial"
9810
end

spec/features/create_bib_record_spec.rb

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6,93 +6,5 @@
66

77
# NOTE: If you generated more than one work, you have to set "js: true"
88
RSpec.feature 'Create a BibRecord', type: :system, js: true do
9-
context 'a logged in user', clean: true do
10-
let(:user) do
11-
FactoryBot.create :user
12-
end
13-
let(:admin_set_id) { AdminSet.find_or_create_default_admin_set_id }
14-
let(:permission_template) { Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set_id) }
15-
let(:workflow) { Sipity::Workflow.create!(active: true, name: 'test-workflow', permission_template: permission_template) }
16-
17-
before do
18-
# Create a single action that can be taken
19-
Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow)
20-
21-
# Grant the user access to deposit into the admin set.
22-
Hyrax::PermissionTemplateAccess.create!(
23-
permission_template_id: permission_template.id,
24-
agent_type: 'user',
25-
agent_id: user.user_key,
26-
access: 'deposit'
27-
)
28-
# Ensure empty requirement for ldap group authorization
29-
allow(ESSI.config[:authorized_ldap_groups]).to receive(:blank?).and_return(true)
30-
login_as user
31-
end
32-
33-
scenario do
34-
visit '/dashboard'
35-
click_link "Works"
36-
click_link "Add new work"
37-
expect(page).to have_content "Select type of work"
38-
39-
# If you generate more than one work uncomment these lines
40-
choose "payload_concern", option: "BibRecord"
41-
VCR.use_cassette('iucat_libraries_up') do
42-
click_button "Create work"
43-
end
44-
45-
expect(page).to have_content "Add New Bib Record"
46-
click_link "Files" # switch tab
47-
expect(page).to have_content "Add files"
48-
expect(page).to have_content "Add folder"
49-
within('span#addfiles') do
50-
attach_file(RSpec.configuration.fixture_path + "/world.png", make_visible: true)
51-
attach_file(RSpec.configuration.fixture_path + "/rgb.png", make_visible: true)
52-
end
53-
click_link "Descriptions" # switch tab
54-
fill_in('Title', with: 'My Test Work')
55-
fill_in('Source Metadata Identifier', with: ' ') # Workaround until the form is fixed for blank field
56-
click_link 'Additional fields'
57-
fill_in('Publication Place', with: 'Wells')
58-
59-
#select('In Copyright', from: 'Rights statement')
60-
61-
# With selenium and the chrome driver, focus remains on the
62-
# select box. Click outside the box so the next line can't find
63-
# its element
64-
find('body').click
65-
choose('bib_record_visibility_open')
66-
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
67-
page.driver.browser.manage.window.resize_to(1400,1400)
68-
check('agreement')
69-
70-
perform_enqueued_jobs do
71-
click_on('Save')
72-
end
73-
74-
# On works dashboard (would probably need a page refresh in actual use)
75-
expect(page).to have_content('My Test Work', count: 1)
76-
expect(page).to have_content('1 works you own in the repository')
77-
expect(page).to have_content "Your files are being processed by Digital Collections in the background."
78-
click_on('My Test Work')
79-
80-
# On work show page
81-
expect(find('.work-type')).to have_content('My Test Work')
82-
expect(page).to_not have_content "Your files are being processed by Digital Collections in the background."
83-
expect(find('li.attribute-title')).to have_content('My Test Work')
84-
click_on(I18n.t('hyrax.works.form.show_child_items'))
85-
expect(find('table.related-files')).to have_content('rgb.png')
86-
87-
click_on('Go')
88-
within '#facets' do
89-
click_on('Pages')
90-
expect(page).to have_content('0-99')
91-
click_on('Publication Place')
92-
expect(page).to have_content('Wells')
93-
click_on('State')
94-
expect(page).to have_content('deposited')
95-
end
96-
end
97-
end
9+
include_examples "create work feature spec", "BibRecord"
9810
end

spec/features/create_image_spec.rb

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -6,92 +6,5 @@
66

77
# NOTE: If you generated more than one work, you have to set "js: true"
88
RSpec.feature 'Create an Image', type: :system, js: true do
9-
context 'a logged in user', clean: true do
10-
let(:user) do
11-
FactoryBot.create :user
12-
end
13-
let(:admin_set_id) { AdminSet.find_or_create_default_admin_set_id }
14-
let(:permission_template) { Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set_id) }
15-
let(:workflow) { Sipity::Workflow.create!(active: true, name: 'test-workflow', permission_template: permission_template) }
16-
17-
before do
18-
# Create a single action that can be taken
19-
Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow)
20-
21-
# Grant the user access to deposit into the admin set.
22-
Hyrax::PermissionTemplateAccess.create!(
23-
permission_template_id: permission_template.id,
24-
agent_type: 'user',
25-
agent_id: user.user_key,
26-
access: 'deposit'
27-
)
28-
# Ensure empty requirement for ldap group authorization
29-
allow(ESSI.config[:authorized_ldap_groups]).to receive(:blank?).and_return(true)
30-
login_as user
31-
end
32-
33-
scenario do
34-
visit '/dashboard'
35-
click_link "Works"
36-
click_link "Add new work"
37-
expect(page).to have_content "Select type of work"
38-
39-
# If you generate more than one work uncomment these lines
40-
choose "payload_concern", option: "Image"
41-
VCR.use_cassette('iucat_libraries_up') do
42-
click_button "Create work"
43-
end
44-
45-
expect(page).to have_content "Add New Image"
46-
click_link "Files" # switch tab
47-
expect(page).to have_content "Add files"
48-
expect(page).to have_content "Add folder"
49-
within('span#addfiles') do
50-
attach_file(RSpec.configuration.fixture_path + "/world.png", make_visible: true)
51-
attach_file(RSpec.configuration.fixture_path + "/rgb.png", make_visible: true)
52-
end
53-
click_link "Descriptions" # switch tab
54-
fill_in('Title', with: 'My Test Work')
55-
click_link 'Additional fields'
56-
fill_in('Publication Place', with: 'Wells')
57-
58-
#select('In Copyright', from: 'Rights statement')
59-
60-
# With selenium and the chrome driver, focus remains on the
61-
# select box. Click outside the box so the next line can't find
62-
# its element
63-
find('body').click
64-
choose('image_visibility_open')
65-
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
66-
page.driver.browser.manage.window.resize_to(1400,1400)
67-
check('agreement')
68-
69-
perform_enqueued_jobs do
70-
click_on('Save')
71-
end
72-
73-
# On works dashboard (would probably need a page refresh in actual use)
74-
expect(page).to have_content('My Test Work', count: 1)
75-
expect(page).to have_content('1 works you own in the repository')
76-
expect(page).to have_content "Your files are being processed by Digital Collections in the background."
77-
click_on('My Test Work')
78-
79-
# On work show page
80-
expect(find('.work-type')).to have_content('My Test Work')
81-
expect(page).to_not have_content "Your files are being processed by Digital Collections in the background."
82-
expect(find('li.attribute-title')).to have_content('My Test Work')
83-
click_on(I18n.t('hyrax.works.form.show_child_items'))
84-
expect(find('table.related-files')).to have_content('rgb.png')
85-
86-
click_on('Go')
87-
within '#facets' do
88-
click_on('Pages')
89-
expect(page).to have_content('0-99')
90-
click_on('Publication Place')
91-
expect(page).to have_content('Wells')
92-
click_on('State')
93-
expect(page).to have_content('deposited')
94-
end
95-
end
96-
end
9+
include_examples "create work feature spec", "Image"
9710
end

spec/features/create_paged_resource_spec.rb

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6,93 +6,5 @@
66

77
# NOTE: If you generated more than one work, you have to set "js: true"
88
RSpec.feature 'Create a PagedResource', type: :system, js: true do
9-
context 'a logged in user', clean: true do
10-
let(:user) do
11-
FactoryBot.create :user
12-
end
13-
let(:admin_set_id) { AdminSet.find_or_create_default_admin_set_id }
14-
let(:permission_template) { Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set_id) }
15-
let(:workflow) { Sipity::Workflow.create!(active: true, name: 'test-workflow', permission_template: permission_template) }
16-
17-
before do
18-
# Create a single action that can be taken
19-
Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow)
20-
21-
# Grant the user access to deposit into the admin set.
22-
Hyrax::PermissionTemplateAccess.create!(
23-
permission_template_id: permission_template.id,
24-
agent_type: 'user',
25-
agent_id: user.user_key,
26-
access: 'deposit'
27-
)
28-
# Ensure empty requirement for ldap group authorization
29-
allow(ESSI.config[:authorized_ldap_groups]).to receive(:blank?).and_return(true)
30-
login_as user
31-
end
32-
33-
scenario do
34-
visit '/dashboard'
35-
click_link "Works"
36-
click_link "Add new work"
37-
expect(page).to have_content "Select type of work"
38-
39-
# If you generate more than one work uncomment these lines
40-
choose "payload_concern", option: "PagedResource"
41-
VCR.use_cassette('iucat_libraries_up') do
42-
click_button "Create work"
43-
end
44-
45-
expect(page).to have_content "Add New Paged Resource"
46-
click_link "Files" # switch tab
47-
expect(page).to have_content "Add files"
48-
expect(page).to have_content "Add folder"
49-
within('span#addfiles') do
50-
attach_file(RSpec.configuration.fixture_path + "/world.png", make_visible: true)
51-
attach_file(RSpec.configuration.fixture_path + "/rgb.png", make_visible: true)
52-
end
53-
click_link "Descriptions" # switch tab
54-
fill_in('Title', with: 'My Test Work')
55-
fill_in('Source Metadata Identifier', with: ' ') # Workaround until the form is fixed for blank field
56-
click_link 'Additional fields'
57-
fill_in('Publication Place', with: 'Wells')
58-
59-
#select('In Copyright', from: 'Rights statement')
60-
61-
# With selenium and the chrome driver, focus remains on the
62-
# select box. Click outside the box so the next line can't find
63-
# its element
64-
find('body').click
65-
choose('paged_resource_visibility_open')
66-
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
67-
page.driver.browser.manage.window.resize_to(1400,1400)
68-
check('agreement')
69-
70-
perform_enqueued_jobs do
71-
click_on('Save')
72-
end
73-
74-
# On works dashboard (would probably need a page refresh in actual use)
75-
expect(page).to have_content('My Test Work', count: 1)
76-
expect(page).to have_content('1 works you own in the repository')
77-
expect(page).to have_content "Your files are being processed by Digital Collections in the background."
78-
click_on('My Test Work')
79-
80-
# On work show page
81-
expect(find('.work-type')).to have_content('My Test Work')
82-
expect(page).to_not have_content "Your files are being processed by Digital Collections in the background."
83-
expect(find('li.attribute-title')).to have_content('My Test Work')
84-
click_on(I18n.t('hyrax.works.form.show_child_items'))
85-
expect(find('table.related-files')).to have_content('rgb.png')
86-
87-
click_on('Go')
88-
within '#facets' do
89-
click_on('Pages')
90-
expect(page).to have_content('0-99')
91-
click_on('Publication Place')
92-
expect(page).to have_content('Wells')
93-
click_on('State')
94-
expect(page).to have_content('deposited')
95-
end
96-
end
97-
end
9+
include_examples "create work feature spec", "PagedResource"
9810
end

0 commit comments

Comments
 (0)