Skip to content

Commit

Permalink
MERGE TO BRANCH - 214 branch in house repair checks - MERGE FIRST (#495)
Browse files Browse the repository at this point in the history
* Edit controlled vocab specs

* Check read-only cons records for access rights

* Remove blank lines, correct disabled fields test

* Rearrange feature tests by subject, add in-house creation testing

* Check in-house repair deletion

* Rubocop and fix broken tests
  • Loading branch information
Janell-Huyck committed May 28, 2024
1 parent 2f81783 commit 07192ba
Show file tree
Hide file tree
Showing 31 changed files with 125 additions and 62 deletions.
14 changes: 0 additions & 14 deletions spec/features/admin_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@
first('a').click
end

# In_House Repair

visit conservation_records_path
click_link(conservation_record.title, match: :prefer_exact)
expect(page).to have_button('Add In-House Repairs')
click_button('Add In-House Repairs')
select(user.display_name, from: 'in_house_repair_record_performed_by_user_id', match: :first)
select('Mend paper', from: 'in_house_repair_record_repair_type', match: :first)
fill_in 'in_house_repair_record_minutes_spent', with: '10'
fill_in 'in_house_repair_record_other_note', with: 'Other Note'
select('test', from: 'in_house_repair_record_staff_code_id', match: :first)
click_button('Create In-House Repair Record')
expect(page).to have_content("Mend paper performed by #{user.display_name}")

# External Repair
expect(page).to have_button('Add External Repair')
click_button('Add External Repair')
Expand Down
35 changes: 0 additions & 35 deletions spec/features/end_to_end_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,7 @@
it 'allows User to login and show Conservation Records' do
# Login
log_in_as_user(user)

# In_House Repair
visit conservation_records_path
click_link(conservation_record.title, match: :prefer_exact)
expect(page).to have_button('Add In-House Repairs')
click_button('Add In-House Repairs')
select('Chuck Greenman', from: 'in_house_repair_record_performed_by_user_id')
select('Soft slipcase', from: 'in_house_repair_record_repair_type', match: :first)
fill_in('in_house_repair_record_other_note', with: 'Some Other note for the in-house repair')
fill_in('in_house_repair_record_minutes_spent', with: '2')
select('test', from: 'in_house_repair_record_staff_code_id', match: :first)
click_button('Create In-House Repair Record')
expect(page).to have_content('Soft slipcase performed by Chuck Greenman in 2 minutes. Other note: Some Other note for the in-house repair')

# External Repair
expect(page).to have_button('Add External Repair')
Expand Down Expand Up @@ -121,28 +109,7 @@
it 'allows User to login and show Conservation Records' do
# Login
log_in_as_user(user)

# Create In_House Repair
visit conservation_records_path
click_link(conservation_record.title, match: :prefer_exact)
expect(page).to have_button('Add In-House Repairs')
click_button('Add In-House Repairs')
select(user.display_name, from: 'in_house_repair_record_performed_by_user_id', match: :first)
# get list of repair_types and check that favorite is first option
repair_types = find('#in_house_repair_record_repair_type').all('option').collect(&:text)
expect(repair_types[1..]).to start_with('key_string')
select('Mend paper', from: 'in_house_repair_record_repair_type', match: :first)
fill_in('in_house_repair_record_other_note', with: 'Some Other note for the in-house repair')
fill_in('in_house_repair_record_minutes_spent', with: '2')
select('test', from: 'in_house_repair_record_staff_code_id', match: :first)
click_button('Create In-House Repair Record')
expect(page).to have_content("Mend paper performed by #{user.display_name} in 2 minutes. Other note: Some Other note for the in-house repair")

# Delete In-house repair
accept_confirm do
find("a[id='delete_in_house_repair_record_1']").click
end
expect(page).not_to have_content("Mend paper performed by #{user.display_name}")

# Create External Repair
expect(page).to have_button('Add External Repair')
Expand Down Expand Up @@ -214,8 +181,6 @@
visit activity_index_path
expect(page).to have_content("#{user.display_name} created the external repair record")
expect(page).to have_content("#{user.display_name} deleted the external repair record")
expect(page).to have_content("#{user.display_name} created the in house repair record")
expect(page).to have_content("#{user.display_name} deleted the in house repair record")
expect(page).to_not have_content("#{user.display_name} created the treatment report")
expect(page).to have_content("#{user.display_name} updated the treatment report")
end
Expand Down
2 changes: 2 additions & 0 deletions spec/features/specs/user_scenarios/admin_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
it_behaves_like 'view conservation record details'
it_behaves_like 'creates new conservation records'
it_behaves_like 'edits conservation records'
it_behaves_like 'creates new in-house repairs'
it_behaves_like 'deletes in-house repairs'
it_behaves_like 'view controlled vocabularies'
it_behaves_like 'creates new controlled vocabularies'
it_behaves_like 'edits controlled vocabularies'
Expand Down
2 changes: 1 addition & 1 deletion spec/features/specs/user_scenarios/read_only_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
it_behaves_like 'index page access for authenticated users'
it_behaves_like 'view conservation record details'
it_behaves_like 'has a read_only user header'
it_behaves_like 'displays conservation records for read-only users correctly'
it_behaves_like 'can read but not edit conservation records'

it 'prevents read-only users from accessing New Conservation Records page' do
prevents_unauthorized_access(new_conservation_record_path)
Expand Down
2 changes: 2 additions & 0 deletions spec/features/specs/user_scenarios/standard_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
it_behaves_like 'view conservation record details'
it_behaves_like 'creates new conservation records'
it_behaves_like 'edits conservation records'
it_behaves_like 'creates new in-house repairs'
it_behaves_like 'deletes in-house repairs'

it 'prevents standard users from accessing Staff Codes page' do
prevents_unauthorized_access(staff_codes_path)
Expand Down
12 changes: 0 additions & 12 deletions spec/features/standard_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,7 @@
it 'allows User to login and show Conservation Records' do
# Login
log_in_as_user(user)

# In_House Repair
visit conservation_records_path
click_link(conservation_record.title, match: :prefer_exact)
expect(page).to have_button('Add In-House Repairs')
click_button('Add In-House Repairs')
select('Chuck Greenman', from: 'in_house_repair_record_performed_by_user_id')
select('Soft slipcase', from: 'in_house_repair_record_repair_type', match: :first)
fill_in 'in_house_repair_record_other_note', with: 'Other Note'
fill_in 'in_house_repair_record_minutes_spent', with: '23'
select('test', from: 'in_house_repair_record_staff_code_id', match: :first)
click_button('Create In-House Repair Record')
expect(page).to have_content('Soft slipcase performed by Chuck Greenman', wait: 3)

# External Repair
expect(page).to have_button('Add External Repair')
Expand Down
14 changes: 14 additions & 0 deletions spec/features/support/helpers/conservation_record_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

def add_in_house_repair(conservation_record)
visit conservation_records_path
click_link(conservation_record.title, match: :prefer_exact)
expect(page).to have_button('Add In-House Repairs')
click_button('Add In-House Repairs')
select(user.display_name, from: 'in_house_repair_record_performed_by_user_id', match: :first)
select('Mend paper', from: 'in_house_repair_record_repair_type', match: :first)
fill_in 'in_house_repair_record_minutes_spent', with: '10'
fill_in 'in_house_repair_record_other_note', with: 'Other Note'
select('test', from: 'in_house_repair_record_staff_code_id', match: :first)
click_button('Create In-House Repair Record')
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.shared_examples 'creates new in-house repairs' do
let(:conservation_record) { create(:conservation_record) }

before do
conservation_record
end

it 'creates a new in-house repair' do
add_in_house_repair(conservation_record)

expect(page).to have_content("Mend paper performed by #{user.display_name}")
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.shared_examples 'deletes in-house repairs' do
let(:conservation_record) { create(:conservation_record) }

before do
conservation_record
end

it 'deletes an in-house repair' do
add_in_house_repair(conservation_record)
expect(page).to have_content("Mend paper performed by #{user.display_name}")

accept_confirm do
find("a[id='delete_in_house_repair_record_1']").click
end
expect(page).not_to have_content("Mend paper performed by #{user.display_name}")
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.shared_examples 'edits in-house repairs' do
let(:conservation_record) { create(:conservation_record) }

before do
conservation_record
end

it 'edits an in-house repair' do
# Currently there is no funtionality to edit an in-house repair.
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.shared_examples 'can read but not edit conservation records' do
let(:cons_record) { create(:conservation_record) }

before do
cons_record
end

it 'does not have buttons that it should not have' do
visit conservation_records_path
expect(page).not_to have_link('New Conservation Record')

within('table tbody') do
first('a').click
end

expect(page).not_to have_link('Edit Conservation Record')
expect(page).not_to have_link('Add In-House Repair')
expect(page).not_to have_link('Add External Repair')
expect(page).not_to have_link('Add Conservators and Technicians')
end

it 'has disabled conservation record buttons' do
visit conservation_records_path
within('table tbody') do
first('a').click
end

expect(page).to have_content('Cost and Return Information')
expect(page).to have_button('Save Cost and Return Information', disabled: true)
expect(page).to have_button('Save Treatment Report', disabled: true)
expect(page).to have_button('Save Cost and Return Information', disabled: true)
end

it 'has disabled input fields in the conservation record form' do
visit conservation_record_path(cons_record)
expect(page).to have_selector('h1', text: cons_record.title)
expect(page).to have_selector('form.disable_input')
all('form.disable_input').each do |form| # There are several forms on the page
within(form) do
# Check disabled state for all input, textarea, and select elements
%w[input textarea select].each do |element_type|
all(element_type).each do |element|
expect(element).to be_disabled
end
end
end
end
end
end

0 comments on commit 07192ba

Please sign in to comment.