-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editing and adding ratifying provider
- Loading branch information
1 parent
73cfb8e
commit 4add6c1
Showing
7 changed files
with
259 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
spec/features/publish/courses/add_ratifying_provider_when_publishing_a_course_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
feature 'Publishing a course when course accrediting provider is invalid', { can_edit_current_and_next_cycles: false } do | ||
before do | ||
allow(Settings.features).to receive(:provider_partnerships).and_return(true) | ||
given_i_am_authenticated_as_a_provider_user | ||
end | ||
|
||
scenario 'Add accrediting provider to provider and provider has no accrediting providers, change accrediting provider of course then publish' do | ||
and_the_provider_has_no_accredited_provider | ||
and_there_is_a_draft_course_with_an_unaccredited_provider | ||
|
||
# Publising is invalid | ||
when_i_visit_the_course_page | ||
and_i_click_the_publish_button | ||
then_i_should_see_an_error_message_that_accredited_provider_is_not_accredited | ||
|
||
# Add accrediting provider to provider | ||
when_i_click_the_error_message_link | ||
then_it_takes_me_to_the_accredited_providers_page | ||
when_i_click_add_an_accredited_provider | ||
and_i_search_for_an_accredited_provider | ||
and_i_fill_in_the_accredited_provider_form | ||
and_i_confirm_creation_of_the_accredited_provider | ||
then_i_see_that_the_accredited_provider_has_been_added | ||
|
||
# Publishing is invalid | ||
when_i_visit_the_course_page | ||
and_i_click_the_publish_button | ||
then_i_should_see_an_error_message_that_accredited_provider_is_not_accredited | ||
|
||
# Clicking error message allows user to select accrediting provider | ||
when_i_click_the_error_message_link | ||
and_i_choose_the_new_accredited_provider | ||
and_i_click_the_publish_button | ||
then_i_should_see_a_success_message | ||
end | ||
|
||
scenario 'Select valid accrediting provider to course and publish' do | ||
and_the_provider_has_a_valid_accrediting_provider | ||
and_there_is_a_draft_course_without_accrediting_provider | ||
and_an_accredited_provider_exists | ||
|
||
# Publising is invalid | ||
when_i_visit_the_course_page | ||
and_i_click_the_publish_button | ||
then_i_should_see_an_error_message_for_the_accrediting_provider | ||
|
||
# Clicking error message allows user to select accrediting provider | ||
when_i_click_the_select_accredited_provider_error_message_link | ||
and_i_choose_the_new_accredited_provider | ||
and_i_click_the_publish_button | ||
then_i_should_see_a_success_message | ||
end | ||
|
||
def given_i_am_authenticated_as_a_provider_user | ||
@user = create(:user, :with_provider) | ||
given_i_am_authenticated(user: @user) | ||
end | ||
|
||
def and_the_provider_has_a_valid_accrediting_provider | ||
provider = @user.providers.first | ||
provider.accredited_partnerships.create(accredited_provider:accredited_provider, description: 'Description') | ||
end | ||
|
||
def and_the_provider_has_no_accredited_provider | ||
expect(provider.accredited_providers).to be_empty | ||
end | ||
|
||
def and_there_is_a_draft_course_without_accrediting_provider | ||
given_a_course_exists( | ||
:with_gcse_equivalency, | ||
enrichments: [create(:course_enrichment, :initial_draft)], | ||
sites: [create(:site, location_name: 'location 1')], | ||
study_sites: [create(:site, :study_site)] | ||
) | ||
end | ||
|
||
def and_there_is_a_draft_course_with_an_unaccredited_provider | ||
given_a_course_exists( | ||
:with_gcse_equivalency, | ||
accrediting_provider: provider, | ||
enrichments: [create(:course_enrichment, :initial_draft)], | ||
sites: [create(:site, location_name: 'location 1')], | ||
study_sites: [create(:site, :study_site)] | ||
) | ||
end | ||
|
||
def when_i_visit_the_course_page | ||
publish_provider_courses_show_page.load( | ||
provider_code: provider.provider_code, | ||
recruitment_cycle_year: provider.recruitment_cycle_year, | ||
course_code: course.course_code | ||
) | ||
end | ||
|
||
def then_i_should_see_a_success_message | ||
expect(page).to have_content('Your course has been published.') | ||
end | ||
|
||
def then_i_should_see_an_error_message_that_accredited_provider_is_not_accredited | ||
expect(publish_provider_courses_show_page.error_messages).to include('Update the accredited provider') | ||
end | ||
|
||
def then_i_should_see_an_error_message_for_the_accrediting_provider | ||
expect(publish_provider_courses_show_page.error_messages).to include('Select an accredited provider') | ||
end | ||
|
||
def when_i_click_the_error_message_link | ||
publish_provider_courses_show_page.errors.first.link.click | ||
end | ||
|
||
def then_it_takes_me_to_the_accredited_providers_page | ||
expect(publish_courses_ratifying_providers_page).to be_displayed | ||
end | ||
|
||
def when_i_click_add_an_accredited_provider | ||
publish_courses_accredited_providers_page.add_new_link.click | ||
expect(publish_provider_accredited_providers_search_page).to be_displayed | ||
end | ||
|
||
def and_i_search_for_an_accredited_provider | ||
publish_provider_accredited_providers_search_page.search_input.set(accredited_provider.provider_name) | ||
publish_provider_accredited_providers_search_page.continue_button.click | ||
choose accredited_provider.name_and_code | ||
publish_provider_accredited_providers_search_page.continue_button.click | ||
end | ||
|
||
def and_i_fill_in_the_accredited_provider_form | ||
publish_courses_new_accredited_provider_page.about_section_input.set('About course') | ||
|
||
publish_courses_new_accredited_provider_page.submit.click | ||
end | ||
|
||
def and_i_confirm_creation_of_the_accredited_provider | ||
publish_courses_new_accredited_provider_page.submit.click | ||
end | ||
|
||
def then_i_see_that_the_accredited_provider_has_been_added | ||
expect(page).to have_content('Accredited partnership added') | ||
end | ||
|
||
def and_i_click_the_publish_button | ||
publish_provider_courses_show_page.publish_button.click | ||
end | ||
|
||
def when_i_click_the_select_accredited_provider_error_message_link | ||
page.click_link_or_button('Select an accredited provider') | ||
end | ||
|
||
def and_i_choose_the_new_accredited_provider | ||
choose accredited_provider.provider_name | ||
page.click_link_or_button('Update ratifying partner') | ||
expect(page).to have_content('Accredited provider updated') | ||
end | ||
|
||
def and_an_accredited_provider_exists | ||
accredited_provider | ||
end | ||
|
||
def accredited_provider | ||
@accredited_provider ||= create(:provider, :accredited_provider) | ||
end | ||
|
||
def provider | ||
@current_user.providers.first | ||
end | ||
end |
61 changes: 61 additions & 0 deletions
61
spec/features/publish/courses/new_schools_provider_partnerships_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
feature 'selection schools', { can_edit_current_and_next_cycles: false } do | ||
before do | ||
allow(Settings.features).to receive(:provider_partnerships).and_return(true) | ||
given_i_am_authenticated_as_a_provider_user | ||
and_that_sites_exist | ||
when_i_visit_the_publish_courses_new_schools_page | ||
end | ||
|
||
scenario 'selecting multiple schools' do | ||
when_i_select_a_school | ||
and_i_click_continue | ||
then_i_am_met_with_the_accredited_provider_page | ||
end | ||
|
||
scenario 'invalid entries' do | ||
and_i_click_continue | ||
then_i_am_met_with_errors | ||
end | ||
|
||
private | ||
|
||
def given_i_am_authenticated_as_a_provider_user | ||
@user = create(:user, :with_provider) | ||
given_i_am_authenticated(user: @user) | ||
end | ||
|
||
def and_that_sites_exist | ||
provider.sites << create_list(:site, 3) | ||
end | ||
|
||
def when_i_visit_the_publish_courses_new_schools_page | ||
publish_courses_new_schools_page.load(provider_code: provider.provider_code, recruitment_cycle_year: Settings.current_recruitment_cycle_year, query: schools_params) | ||
end | ||
|
||
def when_i_select_a_school | ||
publish_courses_new_schools_page.check(provider.sites.first.location_name) | ||
publish_courses_new_schools_page.check(provider.sites.second.location_name) | ||
end | ||
|
||
def and_i_click_continue | ||
publish_courses_new_schools_page.continue.click | ||
end | ||
|
||
def provider | ||
@provider ||= @user.providers.first | ||
end | ||
|
||
def then_i_am_met_with_the_accredited_provider_page | ||
expect(page).to have_current_path("/publish/organisations/#{provider.provider_code}/#{Settings.current_recruitment_cycle_year}/courses/ratifying-provider/new", ignore_query: true) | ||
expect(page).to have_content('Ratifying provider') | ||
end | ||
|
||
def then_i_am_met_with_errors | ||
expect(page).to have_content('There is a problem') | ||
expect(page).to have_content('Select at least one school') | ||
end | ||
end |
16 changes: 16 additions & 0 deletions
16
spec/support/page_objects/publish/courses/ratifying_providers.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module PageObjects | ||
module Publish | ||
module Courses | ||
class RatifyingProviders < PageObjects::Base | ||
set_url '/publish/organisations/{provider_code}/{recruitment_cycle_year}/courses/{course_code}/ratifying-provider' | ||
|
||
elements :suggested_accredited_bodies, '[data-qa="course__accredited_provider_option"]' | ||
element :add_new_link, '[data-qa="course__add"]' | ||
|
||
element :update_button, 'input[type=submit]' | ||
end | ||
end | ||
end | ||
end |