From b08da86c5165ed0bbd9529a6c80f93809ec3428c Mon Sep 17 00:00:00 2001 From: edwh Date: Wed, 2 Sep 2026 12:54:06 +0100 Subject: [PATCH] Stop createEvent picking a past date for a future event The date click lands on the first day of the calendar's final week row - page.click is not strict, so it takes the first of the seven matches, not the last. In the current month that day is near the month's end, so for the last few days of every month it is on or before today. createEvent(past=false) then produced a finished event. EventActions renders a different branch for a finished event, with no Invite volunteers item at all, so the invite test timed out waiting for a dropdown item that was never going to appear. Nothing in the app had changed: the suite went red on 31 August because the calendar picked 30 August, and it had been green on 15 July when the same click landed in the future. Shift a month in the direction we want instead of relying on where today falls, mirroring what the past branch already did, and check the date we ended up with. Without that check a mis-picked date shows up as a puzzling timeout much later in whichever test used the helper. Verified against the local site with the browser clock faked: at 2026-08-31 the old click picks 2026-08-30 and at 2026-12-29 it picks 2026-12-27, both in the past; with the shift both dates land in the following month, and the invite test passes. Co-Authored-By: Claude Opus 5 (1M context) --- tests/Integration/utils.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/Integration/utils.js b/tests/Integration/utils.js index 05d0375cfd..9aedfebf65 100644 --- a/tests/Integration/utils.js +++ b/tests/Integration/utils.js @@ -168,14 +168,31 @@ exports.createEvent = async function(page, baseURL, idgroups, past) { log('Setting event date', { past }) await page.click('#event_date button') + // The click below lands on the first day of the calendar's final week row, + // which is near the end of whichever month is on display. In the current + // month that date is in the past for the last few days of every month, which + // quietly created a finished event when we asked for a future one, so shift a + // month in the direction we want rather than relying on today's position. if (past) { log('Setting past date - going back a month') - // Go back a month await page.locator('[aria-label="Previous month"]').click() + } else { + log('Setting future date - going forward a month') + await page.locator('[aria-label="Next month"]').click() } await page.click('#event_date .b-calendar-grid > .b-calendar-grid-body > .row:last-child .btn:last-child') + // A mis-picked date changes which actions the event offers, which surfaces as + // a puzzling timeout much later in whichever test used this helper. Fail here + // instead, saying what went wrong. + const chosenDate = await page.locator('input[name="event_date"]').inputValue() + const todayDate = await page.evaluate(() => new Date().toISOString().slice(0, 10)) + if (past ? chosenDate >= todayDate : chosenDate <= todayDate) { + throw new Error(`createEvent(past=${past}) picked ${chosenDate}, but today is ${todayDate}`) + } + log('Event date set', { chosenDate, todayDate, past }) + log('Setting event times') await page.click('#event_time input[name="start"]') await page.fill('#event_time input[name="start"]', '13:00')