mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-07-16 04:03:47 +03:00
tests(e2e): make API key renewal date picker navigation date-independent (#1560)
This commit is contained in:
committed by
GitHub
parent
931a6c2adb
commit
d359438814
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user