From 1c66fb9f5e7c60fe1d355f9dda748e6b70c66c51 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Thu, 28 Nov 2024 16:08:30 +0000 Subject: [PATCH] fix flakey test --- spec/factories/reminders.rb | 8 ++++++++ spec/features/admin/admin_configure_services_spec.rb | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/spec/factories/reminders.rb b/spec/factories/reminders.rb index 3227a5d3c4..fe72cc3990 100644 --- a/spec/factories/reminders.rb +++ b/spec/factories/reminders.rb @@ -3,5 +3,13 @@ full_name { Faker::Name.name } email_address { Faker::Internet.email } journey_class { Journeys.all.sample.to_s } + + trait :with_additonal_payments_reminder do + journey_class { Journeys::AdditionalPaymentsForTeaching.to_s } + end + + trait :with_fe_reminder do + journey_class { Journeys::FurtherEducationPayments.to_s } + end end end diff --git a/spec/features/admin/admin_configure_services_spec.rb b/spec/features/admin/admin_configure_services_spec.rb index 306d607ffd..c64f5dfc11 100644 --- a/spec/features/admin/admin_configure_services_spec.rb +++ b/spec/features/admin/admin_configure_services_spec.rb @@ -63,11 +63,11 @@ let(:count) { [*1..5].sample } before do - create_list(:reminder, count, email_verified: true, itt_academic_year: AcademicYear.current) + create_list(:reminder, count, :with_additonal_payments_reminder, email_verified: true, itt_academic_year: AcademicYear.current) # should not be included - create(:reminder, email_verified: true, itt_academic_year: AcademicYear.next) - create(:reminder, email_verified: true, itt_academic_year: AcademicYear.current, email_sent_at: Date.today) - create(:reminder, email_verified: false, itt_academic_year: AcademicYear.current) + create(:reminder, :with_fe_reminder, email_verified: true, itt_academic_year: AcademicYear.next) + create(:reminder, :with_fe_reminder, email_verified: true, itt_academic_year: AcademicYear.current, email_sent_at: Date.today) + create(:reminder, :with_fe_reminder, email_verified: false, itt_academic_year: AcademicYear.current) end scenario "Service operator opens an ECP service for submissions" do @@ -89,7 +89,7 @@ within_fieldset("Service status") { choose("Open") } expect(page).to have_content(I18n.t("admin.journey_configuration.reminder_warning", count: count)) - # make sure email reminder jobjob is queued + # make sure email reminder job is queued expect { click_on "Save" }.to enqueue_job(SendReminderEmailsJob) expect(current_path).to eq(admin_journey_configurations_path)