Skip to content

Commit

Permalink
[CPDNPQ-2419] Fix some flakey tests (#2095)
Browse files Browse the repository at this point in the history
* [CPDNPQ-2419] Fix some flakey tests

* Fix another test that flakes on statement month
  • Loading branch information
rwrrll authored Jan 14, 2025
1 parent f320496 commit bdb8c54
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
expect(page).to have_css("td:nth-child(1)", text: voided_declaration.id)
expect(page).to have_css("td:nth-child(2)", text: voided_declaration.user.id)
expect(page).to have_css("td:nth-child(3)", text: voided_declaration.declaration_type)
expect(page).to have_css("td:nth-child(4)", text: voided_declaration.course.name)
expect(page).to have_css("td:nth-child(4)", text: voided_declaration.reload.course.name)

expect(page).not_to have_css("td:nth-child(1)", text: eligible_declaration.id)
expect(page).not_to have_css("td:nth-child(1)", text: other_voided_declaration.id)
Expand Down
12 changes: 6 additions & 6 deletions spec/models/lead_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@

before do
# Not output fee
create(:statement, output_fee: false, cohort:, lead_provider:, deadline_date: 1.hour.from_now, month: 1)
create(:statement, :next_period, output_fee: false, cohort:, lead_provider:, deadline_date: 1.hour.from_now)
# Paid
create(:statement, :paid, :next_output_fee, cohort:, lead_provider:, deadline_date: 2.hours.from_now, month: 2)
create(:statement, :next_period, :paid, :next_output_fee, cohort:, lead_provider:, deadline_date: 2.hours.from_now)
# Payable
create(:statement, :payable, :next_output_fee, cohort:, lead_provider:, deadline_date: 3.hours.from_now, month: 3)
create(:statement, :next_period, :payable, :next_output_fee, cohort:, lead_provider:, deadline_date: 3.hours.from_now)
# Deadline is later
create(:statement, output_fee: true, cohort:, lead_provider:, deadline_date: 2.days.from_now, month: 4)
create(:statement, :next_period, output_fee: true, cohort:, lead_provider:, deadline_date: 2.days.from_now)
# Wrong cohort
create(:statement, output_fee: true, cohort: create(:cohort, start_year: cohort.start_year + 1), lead_provider:, deadline_date: 1.hour.from_now, month: 5)
create(:statement, :next_period, output_fee: true, cohort: create(:cohort, start_year: cohort.start_year + 1), lead_provider:, deadline_date: 1.hour.from_now)
# In the past
create(:statement, output_fee: true, cohort:, lead_provider:, deadline_date: 1.day.ago, month: 6)
create(:statement, :next_period, output_fee: true, cohort:, lead_provider:, deadline_date: 1.day.ago)
end

subject { lead_provider.next_output_fee_statement(cohort) }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/assurance_reports/query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
let(:assurance_report) { query.declarations.first }
let(:lead_provider) { create(:lead_provider) }
let(:other_lead_provider) { create(:lead_provider) }
let(:statement) { create(:statement, lead_provider:) }
let(:statement) { create(:statement, :next_period, lead_provider:) }
let(:training_status) { :active }

let :declaration do
Expand Down
8 changes: 4 additions & 4 deletions spec/services/statements/summary_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
create(:declaration, :paid, declaration_type:, lead_provider:, application:, cohort:, statement: paid_statement)
end
end
let!(:statement) { create(:statement, :next_output_fee, deadline_date: paid_statement.deadline_date + 1.month, lead_provider:) }
let!(:statement) { create(:statement, :next_period, :next_output_fee, deadline_date: paid_statement.deadline_date + 1.month, lead_provider:) }

before do
travel_to statement.deadline_date do
Expand Down Expand Up @@ -153,7 +153,7 @@
create(:declaration, :paid, declaration_type: "retained-1", lead_provider:, application:, statement: paid_statement)
end
end
let!(:statement) { create(:statement, :next_output_fee, deadline_date: paid_statement.deadline_date + 1.month, lead_provider:) }
let!(:statement) { create(:statement, :next_period, :next_output_fee, deadline_date: paid_statement.deadline_date + 1.month, lead_provider:) }

before do
travel_to statement.deadline_date do
Expand Down Expand Up @@ -274,7 +274,7 @@
end

let!(:to_be_awaiting_clawed_back) do
travel_to create(:statement, :next_output_fee, deadline_date: statement.deadline_date - 1.month, lead_provider:).deadline_date do
travel_to create(:statement, :next_period, :next_output_fee, deadline_date: statement.deadline_date - 1.month, lead_provider:).deadline_date do
create(:declaration, :paid, declaration_type:, application:, lead_provider:)
end
end
Expand Down Expand Up @@ -307,7 +307,7 @@
end

let!(:to_be_awaiting_clawed_back) do
travel_to create(:statement, :next_output_fee, deadline_date: statement.deadline_date - 1.month, lead_provider:).deadline_date do
travel_to create(:statement, :next_period, :next_output_fee, deadline_date: statement.deadline_date - 1.month, lead_provider:).deadline_date do
create(:declaration, :paid, declaration_type:, application:, lead_provider:, statement:)
end
end
Expand Down

0 comments on commit bdb8c54

Please sign in to comment.