|
163 | 163 | end |
164 | 164 | end |
165 | 165 |
|
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 |
167 | 169 | 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") } |
169 | 171 |
|
170 | 172 | let!(:rescheduled_occurrence) do |
171 | 173 | call = RecurringMeetings::InitOccurrenceService |
172 | 174 | .new(user: User.system, recurring_meeting: series) |
173 | | - .call(start_time: first_occurrence_time) |
| 175 | + .call(start_time: scheduled_occurrence_time) |
174 | 176 | 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) |
179 | 178 | occurrence_meeting |
180 | 179 | end |
181 | 180 |
|
182 | 181 | let(:meeting) { rescheduled_occurrence } |
183 | 182 |
|
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") |
186 | 186 |
|
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?") |
189 | 189 |
|
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") |
192 | 203 | end |
| 204 | + end |
193 | 205 |
|
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 } } |
195 | 210 |
|
196 | | - meeting_page.expect_no_agenda_item(title: "Test notes") |
| 211 | + include_examples "moves to a different meeting" |
| 212 | + end |
197 | 213 |
|
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 } } |
200 | 219 |
|
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" |
204 | 221 | end |
205 | 222 | end |
206 | 223 |
|
|
0 commit comments