Skip to content

Commit

Permalink
Add feature test asserting jobseekers can filter by job roles
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleMacPherson committed May 15, 2024
1 parent adfe294 commit 8df262c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
4 changes: 1 addition & 3 deletions app/form_models/jobseekers/subscription_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class Jobseekers::SubscriptionForm < BaseForm
:phases,
:working_patterns,
:teaching_job_role_options,
:teaching_support_job_role_options,
:non_teaching_support_job_role_options,
:support_job_role_options,
:visa_sponsorship_availability_options,
:ect_status_options,
Expand All @@ -30,7 +28,7 @@ class Jobseekers::SubscriptionForm < BaseForm
validate :unique_job_alert
validate :location_and_one_other_criterion_selected, unless: :organisation_slug

def initialize(params = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
def initialize(params = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
search_criteria = params[:search_criteria]&.symbolize_keys || {}

@email = params[:email]
Expand Down
11 changes: 0 additions & 11 deletions config/locales/forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -800,17 +800,6 @@ en:
deputy_headteacher: Deputy headteacher
headteacher: Headteacher
sendco: SENDCo (special educational needs and disabilities coordinator)
teaching_support_job_role_options:
teaching_assistant: Teaching assistant
higher_level_teaching_assistant: HLTA (higher level teaching assistant)
education_support: Learning support or cover supervisor
non_teaching_support_job_role_options:
administration_hr_data_and_finance: Administration, HR, data and finance
catering_cleaning_and_site_management: Catering, cleaning and site management
it_support: IT support
pastoral_health_and_welfare: Pastoral, health and welfare
other_leadership: Other leadership roles
other_support: Other support roles
support_job_role_options:
teaching_assistant: Teaching assistant
higher_level_teaching_assistant: HLTA (higher level teaching assistant)
Expand Down
2 changes: 1 addition & 1 deletion spec/services/search/criteria_inventor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

describe "support_job_roles" do
it "sets the job_roles with the job roles of the vacancy" do
expect(subject.criteria[:support_job_roles]).to eq(["teaching_assistant", "administration_hr_data_and_finance"])
expect(subject.criteria[:support_job_roles]).to eq(%w[teaching_assistant administration_hr_data_and_finance])
end
end

Expand Down
37 changes: 37 additions & 0 deletions spec/system/jobseekers/jobseekers_can_search_for_jobs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,43 @@
end
end

context "when filtering by job roles" do
let!(:headteacher) { create(:vacancy, :past_publish, job_roles: ["headteacher"], job_title: "Headteacher job", subjects: [], organisations: [school]) }
let!(:deputy_head) { create(:vacancy, :past_publish, job_roles: ["deputy_headteacher"], job_title: "Deputy job", subjects: [], organisations: [school]) }
let!(:senior_leader) { create(:vacancy, :past_publish, job_roles: %w[head_of_year_or_phase head_of_department_or_curriculum], job_title: "Senior leader job", subjects: [], organisations: [school]) }
let!(:teaching_assistant) { create(:vacancy, :past_publish, job_roles: %w[higher_level_teaching_assistant education_support teaching_assistant], job_title: "Assistant job", subjects: [], organisations: [school]) }
let!(:sendco) { create(:vacancy, :past_publish, job_roles: ["sendco"], job_title: "Sendco job", subjects: [], organisations: [school]) }
let!(:it_support) { create(:vacancy, :past_publish, job_roles: ["it_support"], job_title: "IT job", subjects: [], organisations: [school]) }
let!(:pastoral) { create(:vacancy, :past_publish, job_roles: ["pastoral_health_and_welfare"], job_title: "Pastoral job", subjects: [], organisations: [school]) }
let!(:other) { create(:vacancy, :past_publish, job_roles: %w[other_leadership other_support], job_title: "Other job", subjects: [], organisations: [school]) }

it "allows users to filter by job role" do
visit jobs_path
find('span[title="Teaching & leadership"]').click
check "Teacher"
click_on I18n.t("buttons.apply_filters")

expect_page_to_show_jobs([job1, job2, job3, job4, maths_job1, maths_job2])
expect_page_not_to_show_jobs([headteacher, deputy_head, senior_leader, teaching_assistant, sendco, it_support, pastoral, other])

find('span[title="Support"]').click
check "IT support"
check "Head of year or phase"
uncheck "Teacher"
click_on I18n.t("buttons.apply_filters")

expect_page_to_show_jobs([senior_leader, it_support])
expect_page_not_to_show_jobs([job1, job2, job3, job4, maths_job1, maths_job2, headteacher, deputy_head, teaching_assistant, sendco, pastoral, other])

uncheck "IT support"
uncheck "Head of year or phase"
check "Other support"
click_on I18n.t("buttons.apply_filters")
expect_page_to_show_jobs([other])
expect_page_not_to_show_jobs([job1, job2, job3, job4, maths_job1, maths_job2, headteacher, deputy_head, teaching_assistant, sendco, pastoral, senior_leader, it_support])
end
end

def expect_page_to_show_jobs(jobs)
jobs.each do |job|
expect(page).to have_link(job.job_title, count: 1)
Expand Down

0 comments on commit 8df262c

Please sign in to comment.