From e7580d7d3969d0122ade320bcbc03d2ad91c3097 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 4 Nov 2026 10:25:14 -0500 Subject: [PATCH] fix(testing): wait for the API keys expiration dropdown instead of force-clicking --- .changeset/api-keys-select-expiration.md | 5 +++++ .../src/playwright/unstable/page-objects/apiKeys.ts | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/api-keys-select-expiration.md 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();