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

Fix tests to respect DST #23420

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
6 changes: 5 additions & 1 deletion spec/feature/hearings/virtual_hearings/daily_docket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ def check_email_events(hearing, current_user)

context "Formerly Video Virtual Hearing" do
let(:expected_central_office_time) do
time_str = "#{updated_hearing_time} #{hearing.hearing_day.scheduled_for} America/New_York"
tz_abbr = Time.zone.parse(time_str).dst? ? "ET" : "EST"

Time
.parse(updated_hearing_time)
.strftime("%F %T")
.in_time_zone(regional_office_timezone) # cast the updated hearing time to the ro timezone
.in_time_zone(HearingTimeService::CENTRAL_OFFICE_TIMEZONE) # convert it to the central office timezone
.strftime("%-l:%M %p ET") # and render it in the format expected in the modal
.strftime("%-l:%M %p #{tz_abbr}") # and render it in the format expected in the modal
end

scenario "Virtual hearing time is updated" do
Expand All @@ -55,6 +58,7 @@ def check_email_events(hearing, current_user)
click_dropdown(name: "optionalHearingTime0", text: updated_video_hearing_time)
expect(page).to have_content(COPY::VIRTUAL_HEARING_MODAL_CHANGE_HEARING_TIME_TITLE)
expect(page).to have_content(COPY::VIRTUAL_HEARING_MODAL_CHANGE_HEARING_TIME_BUTTON)

expect(page).to have_content("Time: #{expected_central_office_time} / #{expected_regional_office_time}")
click_button(COPY::VIRTUAL_HEARING_MODAL_CHANGE_HEARING_TIME_BUTTON)

Expand Down
9 changes: 7 additions & 2 deletions spec/models/hearings/forms/hearing_update_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,18 @@
end

it "should update scheduled_datetime if it is not null already" do
date_str = "#{hearing.hearing_day.scheduled_for} America/New_York"
is_dst = Time.zone.parse(date_str).dst?

hearing.update(
scheduled_datetime: "2021-04-23T11:30:00-04:00", scheduled_in_timezone: "America/New_York"
scheduled_datetime: "2021-04-23T11:30:00#{is_dst ? '-04:00' : '-05:00'}",
scheduled_in_timezone: "America/New_York"
)
subject.update
updated_scheduled_datetime = hearing.scheduled_datetime

expect(updated_scheduled_datetime.strftime("%Y-%m-%d %H:%M %z"))
.to eq "#{hearing.hearing_day.scheduled_for.strftime('%Y-%m-%d')} 21:45 -0400"
.to eq "#{hearing.hearing_day.scheduled_for.strftime('%Y-%m-%d')} 21:45 #{is_dst ? '-0400' : '-0500'}"
end

it "should not update scheduled_datetime if it is null already" do
Expand Down
Loading