Skip to content

Commit

Permalink
Port feature specs to RSpec from Cypress
Browse files Browse the repository at this point in the history
- Port the LP Partnership landing page scenarios
- Port the LP Viewing my schools scenario
- Port the LP Searching my schools list scenario
- Port the LP viewing schools with pupil premiums scenarios
- Port the Admin viewing school participants scenarios
- Port the Admin Participant Management scenarios

Additionally:
- Remove the "Delete participant" spec since the delete action is not functioning
- Consolidate the specs for participant details into a single file
- Fix the HTML for the participant table
  • Loading branch information
leoapost committed May 29, 2024
1 parent bfea512 commit e80dc5e
Show file tree
Hide file tree
Showing 17 changed files with 319 additions and 207 deletions.
24 changes: 11 additions & 13 deletions app/components/admin/participants/table_row.html.erb
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
<tr class="govuk-table__row nhsuk-table__row">
<td class="govuk-table__cell nhsuk-table__cell">
<td class="govuk-table__cell nhsuk-table__cell" data-test="full-name">
<span class="nhsuk-table-responsive__heading">Full name</span>
<div class="school-name-with-tag">
<%= govuk_link_to profile.user.full_name, admin_participant_path(profile) %>
</div>
<%= govuk_link_to profile.user.full_name, admin_participant_path(profile) %>
</td>
<td class="govuk-table__cell nhsuk-table__cell">
<span class="nhsuk-table-responsive__heading">Type</span>
<td class="govuk-table__cell nhsuk-table__cell" data-test="role">
<span class="nhsuk-table-responsive__heading">Role</span>
<%= I18n.t(profile.participant_type, scope: "schools.participants.type") %>
</td>
<td class="govuk-table__cell nhsuk-table__cell">
<span class="nhsuk-table-responsive__heading">School</span>
<td class="govuk-table__cell nhsuk-table__cell" data-test="trn">
<span class="nhsuk-table-responsive__heading">TRN</span>
<%= profile.teacher_profile.trn %>
</td>
<td class="govuk-table__cell nhsuk-table__cell">
<span class="nhsuk-table-responsive__heading">School</span>
<td class="govuk-table__cell nhsuk-table__cell" data-test="school-name">
<span class="nhsuk-table-responsive__heading">School name</span>
<%= school&.name %>
</td>
<td class="govuk-table__cell nhsuk-table__cell">
<td class="govuk-table__cell nhsuk-table__cell" data-test="school-urn">
<span class="nhsuk-table-responsive__heading">School URN</span>
<%= school_urn %>
</td>
<td class="govuk-table__cell nhsuk-table__cell">
<td class="govuk-table__cell nhsuk-table__cell" data-test="date-added">
<span class="nhsuk-table-responsive__heading">Date added</span>
<%= profile.created_at.to_date.to_fs(:govuk_short) %>
</td>
<td class="govuk-table__cell nhsuk-table__cell">
<td class="govuk-table__cell nhsuk-table__cell" data-test="training-record-state">
<span class="nhsuk-table-responsive__heading">Training record state</span>
<%= render StatusTags::AdminParticipantStatusTag.new(participant_profile: profile,
induction_record: profile.latest_current_induction_record) %>
Expand Down
59 changes: 0 additions & 59 deletions spec/cypress/integration/admin/ParticipantManagment.feature

This file was deleted.

20 changes: 0 additions & 20 deletions spec/cypress/integration/admin/ViewSchoolParticipants.feature

This file was deleted.

This file was deleted.

88 changes: 0 additions & 88 deletions spec/cypress/integration/lead_providers/YourSchools.feature

This file was deleted.

3 changes: 3 additions & 0 deletions spec/features/admin/participants/participant_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def then_i_should_see_the_mentors_details
def then_i_should_see_a_list_of_participants
expect(page).to have_text("Fip School")
expect(page).to have_text("Sally Teacher")
expect(page).to have_text("Billy Mentor")
expect(page).to have_text("Early career teacher")
expect(page).to have_text("Mentor")
end

def then_i_should_be_in_the_admin_participants_dashboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "rails_helper"
require_relative "./participant_steps"

RSpec.feature "Admin should be able to update participants details", js: true, rutabaga: false do
RSpec.feature "Admin should be able to manage participants details", js: true, rutabaga: false do
include ParticipantSteps

before do
Expand Down Expand Up @@ -60,4 +60,36 @@
when_i_click_on_the_participants_name "Billy Mentor"
then_the_participants_email_should_have_updated "[email protected]"
end

scenario "Admin can validate the identity of NPQ participants" do
npq = NewSeeds::Scenarios::NPQ.new.build

when_i_visit_the_details_page_of_the_participant(npq.participant_profile.id)
and_i_click_on_the_identity_confirmation(npq.participant_profile.id)
and_i_approve_the_identity_confirmation
then_i_should_see_the_confirmation_message
end

def when_i_visit_the_details_page_of_the_participant(participant_id)
@details_page = Pages::AdminSupportParticipantDetail.load(participant_id:)
end

def and_i_click_on_the_identity_confirmation(participant_id)
@details_page.edit_identity_confirmation
@identity_confirmation_page = Pages::AdminParticipantIdentityValidation.loaded(participant_id:)
end

def and_i_click_on_the_override_decision
@details_page.edit_decision
end

def and_i_approve_the_identity_confirmation
@identity_confirmation_page.approved.click
@identity_confirmation_page.decision_notes.set "Looks good"
@identity_confirmation_page.confirm_button.click
end

def then_i_should_see_the_confirmation_message
expect(page).to have_text("Participant task 'Identity' has been approved")
end
end
53 changes: 53 additions & 0 deletions spec/features/admin/participants/participants_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

require "rails_helper"
require_relative "./participant_steps"

RSpec.feature "Admin finding participants", js: true, rutabaga: false do
include ParticipantSteps

before do
given_there_is_a_school_that_has_chosen_fip_for_2021_and_partnered
and_i_am_signed_in_as_an_admin
and_i_have_added_an_ect
and_i_have_added_a_mentor
when_i_visit_admin_participants_dashboard
end

scenario "Viewing a list of participants" do
@page = Pages::AdminSupportParticipantList.load

then_i_should_see_a_list_of_participants
end

scenario "Searching participants" do
@page = Pages::AdminSupportParticipantList.load

then_i_see_the_search_bar

when_i_search_for_participant "Sally Teacher"
then_the_search_results_are_displayed

when_i_search_for_participant "random keyword"
then_the_search_results_are_empty
end

def when_i_search_for_participant(keyword)
@page.search_field.send_keys(keyword)
@page.search_button.click
end

def then_i_see_the_search_bar
expect(@page).to have_search_field
expect(@page).to have_search_button
end

def then_the_search_results_are_displayed
expect(@page).to have_search_results
expect(@page.search_results.first.full_name.text).to eq("Sally Teacher")
end

def then_the_search_results_are_empty
expect(@page).to_not have_search_results
end
end
15 changes: 13 additions & 2 deletions spec/features/admin/schools/view_school_participants_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
when_i_visit the_school_participants_page
then_i_should_see_all_the_current_and_transferring_participants
and_the_page_should_be_accessible

when_i_click_on_the_participants_name "Charlie Current"
then_i_am_taken_to_the_admin_participant_details_page
end

private
Expand All @@ -18,7 +21,7 @@ def given_there_is_a_school_with_current_and_transferring_participants
cohort = create(:cohort, start_year: 2021)
school_cohort = create(:school_cohort, :fip, school:, cohort:)

charlie = create(:ect_participant_profile, school_cohort:, user: create(:user, full_name: "Charlie Current"))
@charlie = create(:ect_participant_profile, school_cohort:, user: create(:user, full_name: "Charlie Current"))
theresa = create(:ect_participant_profile, user: create(:user, full_name: "Theresa Transfer-In"))
linda = create(:ect_participant_profile, school_cohort:, user: create(:user, full_name: "Linda Leaving"))

Expand All @@ -29,7 +32,7 @@ def given_there_is_a_school_with_current_and_transferring_participants
programme2 = create(:induction_programme, :fip, school_cohort: theresa.school_cohort)
induction_record = Induction::Enrol.call(participant_profile: theresa, induction_programme: programme2, start_date: Date.new(2021, 9, 1))
induction_record.leaving!(2.months.from_now)
Induction::Enrol.call(participant_profile: charlie, induction_programme: programme, start_date: Date.new(2021, 12, 1))
Induction::Enrol.call(participant_profile: @charlie, induction_programme: programme, start_date: Date.new(2021, 12, 1))
Induction::Enrol.call(participant_profile: linda, induction_programme: programme, start_date: Date.new(2021, 9, 1))
Induction::Enrol.call(participant_profile: theresa, induction_programme: programme, start_date: induction_record.end_date, school_transfer: true)
linda.current_induction_record.leaving!(1.week.from_now)
Expand All @@ -44,4 +47,12 @@ def then_i_should_see_all_the_current_and_transferring_participants
expect(page).to have_content "Theresa Transfer-In"
expect(page).to have_content "Linda Leaving"
end

def when_i_click_on_the_participants_name(name)
click_on name
end

def then_i_am_taken_to_the_admin_participant_details_page
expect(current_path).to eq(admin_participant_details_path(@charlie))
end
end
Loading

0 comments on commit e80dc5e

Please sign in to comment.