Skip to content

Commit

Permalink
Specs
Browse files Browse the repository at this point in the history
  • Loading branch information
CatalinVoineag committed Sep 2, 2024
1 parent bff8d58 commit fbdb1f2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
1 change: 1 addition & 0 deletions spec/factories/application_volunteering_experience.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FactoryBot.define do
factory :application_volunteering_experience do
role { ['Teacher', 'Teaching Assistant'].sample }
currently_working { true }
organisation { Faker::Educator.secondary_school }
details { Faker::Lorem.paragraph_by_chars(number: 300) }
working_with_children { [true, true, true, false].sample }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
TestSection.new(:interview_availability, 'Interview availability'),
TestSection.new(:equality_and_diversity_information, 'Equality and diversity questions'),
TestSection.new(:personal_statement, 'Your personal statement'),
TestSection.new(:work_history, 'Work history'),
TestSection.new(:unpaid_experience, 'Unpaid experience'),
].each do |section|
scenario "candidate can edit section '#{section.title}' after submission" do
@section = section
Expand All @@ -35,7 +37,14 @@
end

def given_i_already_have_one_submitted_application
application_form = create(:application_form, :completed, candidate: current_candidate)
application_form = create(
:application_form,
:completed,
candidate: current_candidate,
volunteering_experiences_count: 1,
full_work_history: true,
work_history_status: :can_complete,
)
create(:application_choice, :awaiting_provider_decision, application_form:)
end

Expand Down Expand Up @@ -132,6 +141,34 @@ def and_i_can_edit_the_section_personal_statement
expect(current_candidate.current_application.reload.becoming_a_teacher).to eq('Repellat qui et')
end

def and_i_can_edit_the_section_work_history
work_experience = current_candidate.current_application.application_work_experiences.first
work_break = current_candidate.current_application.application_work_history_breaks.first
click_link_or_button "Change job #{work_experience.role} for #{work_experience.organisation}"
fill_in 'Name of employer', with: 'New employer'
when_i_save_and_continue

click_link_or_button(
'Change entry for break between ' \
"#{work_break.start_date.to_fs(:short_month_and_year)} and " \
"#{work_break.end_date.to_fs(:short_month_and_year)}",
)
fill_in 'Enter reasons for break in work history', with: 'New reason'
when_i_click_continue

expect(work_experience.reload.organisation).to eq('New employer')
expect(work_break.reload.reason).to eq('New reason')
end

def and_i_can_edit_the_section_unpaid_experience
volunteering = current_candidate.current_application.application_volunteering_experiences.first
click_link_or_button "Change role for #{volunteering.role}, #{volunteering.organisation}"
fill_in 'Your role', with: 'New role'
when_i_save_and_continue

expect(volunteering.reload.role).to eq('New role')
end

def section_status
page.find(:xpath, "//a[contains(text(),'#{@section.title}')]/..").text
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
NonEditableSection.new(:degree, 'Degree'),
NonEditableSection.new(:references, 'References to be requested if you accept an offer'),
NonEditableSection.new(:safeguarding, 'Declare any safeguarding issues'),
NonEditableSection.new(:work_history, 'Work history'),
NonEditableSection.new(:unpaid_experience, 'Unpaid experience'),
].each do |section|
scenario "candidate can not edit section '#{section.title}' after submission" do
@section = section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
RSpec.describe 'Trying to enter work history' do
include CandidateHelper

scenario 'Candidate does not see Add job or Add another job buttons' do
scenario 'Candidate does see Add job or Add another job buttons' do
given_i_am_signed_in
and_i_have_completed_work_history
and_i_have_a_submitted_application
when_i_view_work_history
then_i_do_not_see_an_option_to_add_another_job
then_i_do_see_an_option_to_add_another_job
end

def given_i_am_signed_in
Expand All @@ -31,9 +31,8 @@ def and_i_have_a_submitted_application
create(:application_choice, :awaiting_provider_decision, application_form: @application_form_can_complete_work_history)
end

def then_i_do_not_see_an_option_to_add_another_job
def then_i_do_see_an_option_to_add_another_job
expect(page).to have_content 'Work history'
expect(page).to have_no_content 'Add another job'
expect(page).to have_no_content 'Add job'
expect(page).to have_content 'Add another job'
end
end

0 comments on commit fbdb1f2

Please sign in to comment.