Browse Source

Flaky tests

pull/1988/head
Kat 3 years ago
parent
commit
06c640c168
  1. 4
      spec/features/sales_log_spec.rb
  2. 6
      spec/lib/tasks/send_missing_addresses_csv_spec.rb

4
spec/features/sales_log_spec.rb

@ -249,7 +249,7 @@ RSpec.describe "Sales Log Features" do
expect(page).to have_current_path("/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}") expect(page).to have_current_path("/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}")
click_link("Change", href: "/sales-logs/#{duplicate_log.id}/purchaser-code?first_remaining_duplicate_id=#{sales_log.id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs") click_link("Change", href: "/sales-logs/#{duplicate_log.id}/purchaser-code?first_remaining_duplicate_id=#{sales_log.id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
fill_in("sales-log-purchid-field", with: "something else") fill_in("sales-log-purchid-field", with: "something else")
click_button("Save and continue") click_button("Save changes")
expect(page).to have_current_path("/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}&referrer=duplicate_logs") expect(page).to have_current_path("/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}") expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}")
expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success")
@ -260,7 +260,7 @@ RSpec.describe "Sales Log Features" do
it "allows deduplicating logs by changing the answers on the original log" do it "allows deduplicating logs by changing the answers on the original log" do
click_link("Change", href: "/sales-logs/#{sales_log.id}/purchaser-code?first_remaining_duplicate_id=#{duplicate_log.id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs") click_link("Change", href: "/sales-logs/#{sales_log.id}/purchaser-code?first_remaining_duplicate_id=#{duplicate_log.id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
fill_in("sales-log-purchid-field", with: "something else") fill_in("sales-log-purchid-field", with: "something else")
click_button("Save and continue") click_button("Save changes")
expect(page).to have_current_path("/sales-logs/#{duplicate_log.id}/duplicate-logs?original_log_id=#{sales_log.id}&referrer=duplicate_logs") expect(page).to have_current_path("/sales-logs/#{duplicate_log.id}/duplicate-logs?original_log_id=#{sales_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}") expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}")
expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success")

6
spec/lib/tasks/send_missing_addresses_csv_spec.rb

@ -6,6 +6,8 @@ RSpec.describe "correct_addresses" do
subject(:task) { Rake::Task["correct_addresses:send_missing_addresses_lettings_csv"] } subject(:task) { Rake::Task["correct_addresses:send_missing_addresses_lettings_csv"] }
before do before do
Timecop.travel(Time.zone.local(2023, 10, 10))
Singleton.__init__(FormHandler)
organisation.users.destroy_all organisation.users.destroy_all
Rake.application.rake_require("tasks/send_missing_addresses_csv") Rake.application.rake_require("tasks/send_missing_addresses_csv")
Rake::Task.define_task(:environment) Rake::Task.define_task(:environment)
@ -42,6 +44,10 @@ RSpec.describe "correct_addresses" do
.to_return(status: 200, body: body_2, headers: {}) .to_return(status: 200, body: body_2, headers: {})
end end
after do
Timecop.return
end
context "when the rake task is run" do context "when the rake task is run" do
let(:organisation) { create(:organisation, name: "test organisation") } let(:organisation) { create(:organisation, name: "test organisation") }

Loading…
Cancel
Save