Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CPDNPQ-2419] Fix some flakey tests #2095

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the declaration is needing to be reloaded, presumably because data may have changed, shouldn't the first usage of the declaration on line 20 be the one doing the reload?


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)
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)
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)
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)
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)
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)
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
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
Loading