-
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.
- Loading branch information
1 parent
d1b1ffe
commit 484dc5a
Showing
6 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
spec/features/publish/viewing_training_partners_and_their_courses_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,71 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
feature 'Viewing courses as an accredited provider', { 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_an_accredited_provider_user | ||
and_some_courses_exist_with_one_i_accredit | ||
when_i_visit_the_publish_training_partner_index_page | ||
end | ||
|
||
scenario 'i can see who lists me as their accredited provider' do | ||
then_i_should_see_a_list_of_training_partners | ||
and_i_should_see_a_count_of_the_courses_i_accredit | ||
end | ||
|
||
scenario 'i can see which courses i am the accredited provider for' do | ||
and_i_click_on_a_training_provider | ||
then_i_see_the_courses_i_accredit_for | ||
end | ||
|
||
def given_i_am_authenticated_as_an_accredited_provider_user | ||
given_i_am_authenticated(user: create(:user, providers: [create(:provider, :accredited_provider)])) | ||
end | ||
|
||
def and_some_courses_exist_with_one_i_accredit | ||
create(:provider_partnership, training_provider:, accredited_provider: accrediting_provider) | ||
given_a_course_exists( | ||
enrichments: [build(:course_enrichment, :published)], | ||
provider: training_provider, | ||
accrediting_provider: | ||
) | ||
|
||
create(:course, enrichments: [build(:course_enrichment, :published)], provider: training_provider) | ||
end | ||
|
||
def when_i_visit_the_publish_training_partner_index_page | ||
publish_training_partner_index_page.load( | ||
provider_code: accrediting_provider.provider_code, recruitment_cycle_year: accrediting_provider.recruitment_cycle_year | ||
) | ||
end | ||
|
||
def then_i_should_see_a_list_of_training_partners | ||
expect(publish_training_partner_index_page.training_provider_rows.size).to eq(1) | ||
|
||
expect(publish_training_partner_index_page.training_provider_rows.first.name).to have_text(training_provider.provider_name) | ||
end | ||
|
||
def and_i_should_see_a_count_of_the_courses_i_accredit | ||
expect(publish_training_partner_index_page.training_provider_rows.first.course_count).to have_text('1') | ||
end | ||
|
||
def and_i_click_on_a_training_provider | ||
publish_training_partner_index_page.training_provider_rows.first.name.click | ||
end | ||
|
||
def then_i_see_the_courses_i_accredit_for | ||
expect(publish_training_partners_course_index_page).to be_displayed | ||
expect(publish_training_partners_course_index_page.courses.size).to eq(1) | ||
expect(publish_training_partners_course_index_page.courses.first.name).to have_text(course.name) | ||
end | ||
|
||
def accrediting_provider | ||
@current_user.providers.first | ||
end | ||
|
||
def training_provider | ||
@training_partner ||= create(:provider) | ||
end | ||
end |
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
13 changes: 13 additions & 0 deletions
13
spec/support/page_objects/publish/training_partner_index.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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../sections/training_partner' | ||
|
||
module PageObjects | ||
module Publish | ||
class TrainingPartnerIndex < PageObjects::Base | ||
set_url '/publish/organisations/{provider_code}/{recruitment_cycle_year}/training-partners' | ||
|
||
sections :training_provider_rows, Sections::TrainingPartner, '[data-qa="provider__training_partners_list"]' | ||
end | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
spec/support/page_objects/publish/training_partners/course_index.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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module PageObjects | ||
module Publish | ||
module TrainingPartners | ||
class CourseIndex < PageObjects::Base | ||
set_url '/publish/organisations/{provider_code}/{recruitment_cycle_year}/training-partners/{training_provider_code}/courses' | ||
|
||
sections :courses, '[data-qa="courses__table-section"]' do | ||
element :name, '[data-qa="courses-table__course-name"]' | ||
end | ||
end | ||
end | ||
end | ||
end |
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'base' | ||
|
||
module PageObjects | ||
module Sections | ||
class TrainingPartner < PageObjects::Sections::Base | ||
element :name, '[data-qa="training_partner_name"]' | ||
element :course_count, '[data-qa="course_count"]' | ||
end | ||
end | ||
end |