Skip to content

Commit 9fbce7d

Browse files
authored
chore(testing): Update util waitForStipeElements to accept a state (#6204)
1 parent edc0bfd commit 9fbce7d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

.changeset/eleven-days-sniff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/testing': patch
3+
---
4+
5+
Allow for `waitForStripeElements` helper to accept a `state` of `visible` or `hidden`.

integration/tests/pricing-table.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,9 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withBilling] })('pricing tabl
309309
});
310310
await u.po.checkout.clickPayOrSubscribe();
311311
await expect(u.po.page.locator('.cl-checkout-root').getByText('The card was declined.').first()).toBeVisible();
312-
await u.po.checkout.waitForStipeElements();
312+
// It should unmount and remount the payment element
313+
await u.po.checkout.waitForStripeElements({ state: 'hidden' });
314+
await u.po.checkout.waitForStripeElements({ state: 'visible' });
313315
await u.po.checkout.fillTestCard();
314316
await u.po.checkout.clickPayOrSubscribe();
315317
await expect(u.po.page.locator('.cl-checkout-root').getByText('Payment was successful!')).toBeVisible();

packages/testing/src/playwright/unstable/page-objects/checkout.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ export const createCheckoutPageObject = (testArgs: { page: EnhancedPage }) => {
2828
await frame.getByLabel('Country').selectOption(card.country);
2929
await frame.getByLabel('ZIP code').fill(card.zip);
3030
},
31-
waitForStipeElements: async () => {
32-
return page
33-
.frameLocator('iframe[src*="elements-inner-payment"]')
34-
.getByLabel('Card number')
35-
.waitFor({ state: 'visible' });
31+
waitForStripeElements: async ({ state = 'visible' }: { state?: 'visible' | 'hidden' } = {}) => {
32+
return page.frameLocator('iframe[src*="elements-inner-payment"]').getByLabel('Card number').waitFor({ state });
3633
},
3734
clickPayOrSubscribe: async () => {
3835
await self.root.getByRole('button', { name: /subscribe|pay\s\$/i }).click();

0 commit comments

Comments
 (0)