Skip to content
Merged
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
19 changes: 18 additions & 1 deletion tests/Integration/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading