diff --git a/.changeset/api-keys-select-expiration.md b/.changeset/api-keys-select-expiration.md new file mode 100644 index 00000000000..67dd480b899 --- /dev/null +++ b/.changeset/api-keys-select-expiration.md @@ -0,0 +1,5 @@ +--- +'@clerk/testing': patch +--- + +Make the unstable API keys page object's `selectExpiration` wait for the expiration dropdown to open and close, instead of force-clicking the option while the list is still animating. diff --git a/packages/testing/src/playwright/unstable/page-objects/apiKeys.ts b/packages/testing/src/playwright/unstable/page-objects/apiKeys.ts index 589c2a2f80f..1ca766dc125 100644 --- a/packages/testing/src/playwright/unstable/page-objects/apiKeys.ts +++ b/packages/testing/src/playwright/unstable/page-objects/apiKeys.ts @@ -1,3 +1,5 @@ +import { expect } from '@playwright/test'; + import type { EnhancedPage } from './app'; import { common } from './common'; @@ -51,8 +53,11 @@ export const createAPIKeysComponentPageObject = (testArgs: { page: EnhancedPage return page.getByLabel(/Description/i).fill(value); }, selectExpiration: async (value?: keyof typeof expirationOptions) => { - await page.getByRole('button', { name: /Select date/i }).click(); - return page.getByText(expirationOptions[value ?? 'never'], { exact: true }).click({ force: true }); + const trigger = page.locator('.cl-selectButton__apiKeyExpiration'); + await trigger.click(); + await expect(trigger).toHaveAttribute('aria-expanded', 'true'); + await page.getByRole('option', { name: expirationOptions[value ?? 'never'], exact: true }).click(); + await expect(trigger).toHaveAttribute('aria-expanded', 'false'); }, clickSaveButton: () => { return page.getByText(/Create key/i).click();