Skip to content

Commit

Permalink
flaky spec (time travelling)
Browse files Browse the repository at this point in the history
  • Loading branch information
thejonroberts committed Nov 10, 2024
1 parent 5bad3ba commit 6f0dc49
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion spec/models/casa_org_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
expect(subject.org_logo).to eq(Pathname.new("#{Rails.root}/public/logo.jpeg"))

subject.logo.attach(
io: File.open(file_fixture "company_logo.png"),
io: File.open(file_fixture("company_logo.png")),
filename: "company_logo.png", content_type: "image/png"
)

Expand Down
5 changes: 3 additions & 2 deletions spec/system/case_contacts/edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@

visit edit_case_contact_path(case_contact)

uncheck contact_types.first.name
complete_details_page(
case_numbers: [], contact_made: true, medium: "Letter", contact_types: [contact_types.second.name],
case_numbers: [], contact_made: true, medium: "Letter",
occurred_on: Time.zone.today - 5.days, hours: 1, minutes: 5
)
uncheck contact_types.first.name
check contact_types.second.name
click_on "Add Another Discussion Topic"
answer_topic contact_topic.question, "Topic 1 Answer."
fill_in_expenses_page(miles: 50, want_reimbursement: true, address: "123 Form St")
Expand Down
9 changes: 5 additions & 4 deletions spec/system/case_court_reports/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
let(:at_least_transition_age) { volunteer.casa_cases.find(&:in_transition_age?) }
let(:modal_selector) { '[data-bs-target="#generate-docx-report-modal"]' }

let(:date) { Date.current }
let(:formatted_date) { date.strftime("%B %d, %Y") } # January 01, 2021

before do
travel_to Date.new(2021, 1, 1)
sign_in volunteer
visit case_court_reports_path
end
after { travel_back }

context "when first arriving to 'Generate Court Report' page", js: true do
it "generation modal hidden" do
Expand All @@ -31,10 +32,10 @@
# putting all this in the same system test shaves 3 seconds off the test suite
it "modal has correct contents" do
start_date = page.find("#start_date").value
expect(start_date).to eq("January 01, 2021") # default date
expect(start_date).to eq(formatted_date)

end_date = page.find("#end_date").value
expect(end_date).to eq("January 01, 2021") # default date
expect(end_date).to eq(formatted_date)

expect(page).to have_selector "#btnGenerateReport", text: "Generate Report", visible: true
expect(page).to_not have_selector ".select2"
Expand Down
6 changes: 3 additions & 3 deletions spec/system/placements/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
require "rails_helper"

RSpec.describe "placements/new", type: :system do
let(:now) { Date.new(2025, 1, 2) }
let(:now) { Date.current }
let(:formatted_date) { now.strftime("%B %-d, %Y") }
let(:casa_org) { create(:casa_org, :with_placement_types) }
let(:admin) { create(:casa_admin, casa_org:) }
let(:casa_case) { create(:casa_case, casa_org:, case_number: "123") }
let(:placement_type) { create(:placement_type, name: "Reunification", casa_org:) }
let(:placement) { create(:placement, placement_started_at: "2024-08-15 20:40:44 UTC", casa_case:, placement_type:) }

before do
travel_to now
sign_in admin
visit casa_case_placements_path(casa_case)
click_link("New Placement")
Expand All @@ -28,7 +28,7 @@

expect(page).to have_content("Placement was successfully created.")
expect(page).to have_content("123")
expect(page).to have_content("January 2, 2025")
expect(page).to have_content(formatted_date)
expect(page).to have_content("Reunification")
end

Expand Down

0 comments on commit 6f0dc49

Please sign in to comment.