Skip to content

Commit

Permalink
Add spec for back links
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-stefano committed May 22, 2024
1 parent 0fa16c7 commit 317233d
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions spec/features/publish/courses/new_tda_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,29 @@
and_i_do_not_see_the_degree_awarding_option
end

scenario 'back links when choosing a teacher degree apprenticeship' do
given_i_am_authenticated_as_a_school_direct_provider_user
and_the_tda_feature_flag_is_active
when_i_visit_the_courses_page
and_i_click_on_add_course
and_i_choose_a_primary_course
and_i_choose_a_primary_age_range
then_i_see_the_degree_awarding_option
when_i_choose_a_degree_awarding_qualification
then_i_am_on_the_choose_schools_page
and_the_back_link_points_to_outcome_page
when_i_choose_the_school
then_the_back_link_points_to_the_school_page
and_i_choose_the_study_site
then_i_am_on_the_add_applications_open_date_page
and_the_back_link_points_to_the_study_site_page
when_i_choose_the_applications_open_date
and_the_back_link_points_to_applications_open_date_page
and_i_choose_the_first_start_date
and_the_back_link_points_to_start_date_page
then_i_am_on_the_check_your_answers_page
end

def given_i_am_authenticated_as_a_school_direct_provider_user
recruitment_cycle = create(:recruitment_cycle, year: 2025)
@user = create(:user, providers: [build(:provider, recruitment_cycle:, provider_type: 'lead_school', sites: [build(:site), build(:site)], study_sites: [build(:site, :study_site), build(:site, :study_site)])])
Expand Down Expand Up @@ -250,20 +273,44 @@ def then_i_am_on_the_choose_schools_page
expect(page).to have_current_path(new_publish_provider_recruitment_cycle_courses_schools_path(provider_code: provider.provider_code, recruitment_cycle_year: 2025), ignore_query: true)
end

def and_the_back_link_points_to_outcome_page
and_i_click_back
expect(page).to have_current_path(new_publish_provider_recruitment_cycle_courses_outcome_path(provider_code: provider.provider_code, recruitment_cycle_year: 2025), ignore_query: true)
and_i_click_continue
end

def when_i_choose_the_school
check provider.sites.first.location_name
and_i_click_continue
end

def then_the_back_link_points_to_the_school_page
and_i_click_back
expect(page).to have_current_path(new_publish_provider_recruitment_cycle_courses_schools_path(provider_code: provider.provider_code, recruitment_cycle_year: 2025), ignore_query: true)
and_i_click_continue
end

def and_i_choose_the_study_site
check provider.study_sites.first.location_name
and_i_click_continue
end

def and_the_back_link_points_to_the_study_site_page
and_i_click_back
expect(page).to have_current_path(new_publish_provider_recruitment_cycle_courses_study_sites_path(provider_code: provider.provider_code, recruitment_cycle_year: 2025), ignore_query: true)
and_i_click_continue
end

def then_i_am_on_the_add_applications_open_date_page
expect(page).to have_current_path(new_publish_provider_recruitment_cycle_courses_applications_open_path(provider_code: provider.provider_code, recruitment_cycle_year: 2025), ignore_query: true)
end

def and_the_back_link_points_to_applications_open_date_page
and_i_click_back
expect(page).to have_current_path(new_publish_provider_recruitment_cycle_courses_applications_open_path(provider_code: provider.provider_code, recruitment_cycle_year: 2025), ignore_query: true)
and_i_click_continue
end

def when_i_choose_the_applications_open_date
first('input.govuk-radios__input').set(true)
and_i_click_continue
Expand All @@ -274,6 +321,12 @@ def and_i_choose_the_first_start_date
and_i_click_continue
end

def and_the_back_link_points_to_start_date_page
and_i_click_back
expect(page).to have_current_path(new_publish_provider_recruitment_cycle_courses_start_date_path(provider_code: provider.provider_code, recruitment_cycle_year: 2025), ignore_query: true)
and_i_click_continue
end

def then_i_am_on_the_check_your_answers_page
expect(page).to have_current_path(confirmation_publish_provider_recruitment_cycle_courses_path(provider_code: provider.provider_code, recruitment_cycle_year: 2025), ignore_query: true)
end
Expand Down Expand Up @@ -439,5 +492,9 @@ def course_name_and_code
course.decorate.name_and_code
end

def and_i_click_back
click_on 'Back'
end

alias_method :and_i_do_not_see_the_change_links_for_study_mode_funding_type_and_visa_sponsorship, :then_i_do_not_see_the_change_links_for_study_mode_funding_type_and_visa_sponsorship
end

0 comments on commit 317233d

Please sign in to comment.