Skip to content

Commit 80db618

Browse files
committed
Update spec to add passing/failing cases
1 parent 37562b6 commit 80db618

1 file changed

Lines changed: 37 additions & 20 deletions

File tree

modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -163,44 +163,61 @@
163163
end
164164
end
165165

166-
context "when the occurrence has been rescheduled to an earlier time (Bug #73741)", skip: "Needs more investigating" do
166+
# Was flaky depending on when the test ran
167+
# Now there are two cases that reliably pass/fail without code changes to capture that
168+
context "when the occurrence has been rescheduled to an earlier time (Bug #73741)" do
167169
let(:current_user) { user_with_manage_permissions }
168-
let(:first_occurrence_time) { series.next_occurrence(from_time: Time.current) }
170+
let(:scheduled_occurrence_time) { DateTime.parse("2025-02-04T10:30:00Z") }
169171

170172
let!(:rescheduled_occurrence) do
171173
call = RecurringMeetings::InitOccurrenceService
172174
.new(user: User.system, recurring_meeting: series)
173-
.call(start_time: first_occurrence_time)
175+
.call(start_time: scheduled_occurrence_time)
174176
occurrence_meeting = call.result
175-
176-
# Reschedule to an earlier time
177-
# This updates meeting.start_time, but not meeting.scheduled_meeting.start_time
178-
occurrence_meeting.update!(start_time: first_occurrence_time - 1.day)
177+
occurrence_meeting.update!(start_time: scheduled_occurrence_time - 1.day)
179178
occurrence_meeting
180179
end
181180

182181
let(:meeting) { rescheduled_occurrence }
183182

184-
it "moves the item to the occurrence after the original scheduled time" do
185-
meeting_page.expect_agenda_item(title: "Test notes")
183+
shared_examples "moves to a different meeting" do
184+
it "moves the item to the occurrence after the original scheduled time" do
185+
meeting_page.expect_agenda_item(title: "Test notes")
186186

187-
meeting_page.select_action(agenda_item, "Move to next meeting")
188-
expect(page).to have_text("Move to next meeting?")
187+
meeting_page.select_action(agenda_item, "Move to next meeting")
188+
expect(page).to have_text("Move to next meeting?")
189189

190-
page.within_modal "Move to next meeting?" do
191-
click_on "Move"
190+
page.within_modal "Move to next meeting?" do
191+
click_on "Move"
192+
end
193+
194+
expect_and_dismiss_flash(message: "Agenda item moved to the next meeting")
195+
meeting_page.expect_no_agenda_item(title: "Test notes")
196+
197+
next_meeting = Meeting.find(agenda_item.reload.meeting_id)
198+
expect(next_meeting.id).not_to eq(rescheduled_occurrence.id)
199+
200+
next_meeting_page = Pages::Meetings::Show.new(next_meeting)
201+
next_meeting_page.visit!
202+
next_meeting_page.expect_agenda_item(title: "Test notes")
192203
end
204+
end
193205

194-
expect_and_dismiss_flash(message: "Agenda item moved to the next meeting")
206+
context "when the rescheduled time is still in the future" do
207+
# Passing case
208+
# Frozen time Monday 08:00, rescheduled time Monday 10:30, original scheduled time Tuesday 10:30
209+
around { |example| travel_to(DateTime.parse("2025-02-03T08:00:00Z")) { example.run } }
195210

196-
meeting_page.expect_no_agenda_item(title: "Test notes")
211+
include_examples "moves to a different meeting"
212+
end
197213

198-
next_meeting = Meeting.find(agenda_item.reload.meeting_id)
199-
expect(next_meeting.id).not_to eq(rescheduled_occurrence.id)
214+
context "when the rescheduled time is past but the scheduled time is still future" do
215+
# Failing/flaky case
216+
# Frozen time Monday 12:00, rescheduled time Monday 10:30, original scheduled time Tuesday 10:30
217+
# Current time is in between new time and original scheduled time
218+
around { |example| travel_to(DateTime.parse("2025-02-03T12:00:00Z")) { example.run } }
200219

201-
next_meeting_page = Pages::Meetings::Show.new(next_meeting)
202-
next_meeting_page.visit!
203-
next_meeting_page.expect_agenda_item(title: "Test notes")
220+
include_examples "moves to a different meeting"
204221
end
205222
end
206223

0 commit comments

Comments
 (0)