tests(e2e): make API key renewal date picker navigation date-independent (#1560)

This commit is contained in:
Alessandro (Ale) Segala
2026-07-02 19:16:47 -07:00
committed by GitHub
parent 931a6c2adb
commit d359438814

View File

@@ -111,8 +111,23 @@ function getDefaultApiKeyExpirationDate() {
async function selectApiKeyExpirationDate(page: Page, date: Date) {
await page.getByRole('button', { name: 'Select a date' }).click();
await page.getByRole('button', { name: 'Next', exact: true }).click();
await page.getByRole('button', { name: getCalendarDayName(date) }).click();
const targetDay = page.getByRole('button', { name: getCalendarDayName(date) });
const nextButton = page.getByRole('button', { name: 'Next', exact: true });
// The calendar opens on the month of the field's current value, which can be an
// arbitrary number of months away from the target date (e.g. when renewing an
// already-expired key, whose proposed date is in the past). Advance one month at
// a time until the target day is rendered, rather than assuming it is exactly one
// month ahead — that assumption is date-dependent and fails on most days.
await expect(async () => {
if (!(await targetDay.isVisible())) {
await nextButton.click();
}
await expect(targetDay).toBeVisible({ timeout: 500 });
}).toPass({ timeout: 8000 });
await targetDay.click();
}
function getCalendarDayName(date: Date) {