Skip to content

Commit 6d25941

Browse files
committed
Revert: M2M scope poll and @clerk/testing timeout bumps
These three changes — the M2M `expect.poll`, the `userButton.waitForMounted` 30s timeout, and the `resolveResetPasswordTask` 30s waitFor — didn't move the failing tests, because each one bumped into Playwright's 30s default test timeout before the new budget could matter. The underlying failures are real product/backend issues (cl-userButtonTrigger never paints; reset-password user lands on the wrong task screen; new M2M tokens stay 401 after a fresh scope grant) that need a code fix outside this PR. Reverting the test-side bandages keeps this PR focused on what actually helped. Kept from earlier commits: - Strong random fake-user passwords (`fakerPassword()`) - Defensive optional-chained afterAll in `components.test.ts` and the three `registerXxxAuthTests` helpers in `machineAuthHelpers.ts`. Restored to `main`: - `userButton.waitForMounted` (no explicit timeout) - `resolveResetPasswordTask` (no explicit waitFor) - M2M `authorizes after dynamically granting scope` (no `expect.poll`) - empty changeset
1 parent 7743e98 commit 6d25941

4 files changed

Lines changed: 14 additions & 41 deletions

File tree

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
---
2-
'@clerk/testing': patch
32
---
4-
5-
Increase timeouts in two `unstable_PageObjects` Playwright helpers so they hold up on slower CI runners:
6-
7-
- `userButton.waitForMounted` now waits up to 30s for the `.cl-userButtonTrigger` element to attach (previously inherited the global 10s `actionTimeout`).
8-
- `sessionTask.resolveResetPasswordTask` now explicitly waits up to 30s for the new-password input to become visible before filling it.

integration/testUtils/machineAuthHelpers.ts

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -349,40 +349,21 @@ export const registerM2MAuthTests = (adapter: MachineAuthTestAdapter): void => {
349349
const u = createTestUtils({ app, page, context });
350350

351351
await u.services.clerk.machines.createScope(network.unscopedSender.id, network.primaryServer.id);
352-
353-
const url = new URL(adapter.m2m.path, app.serverUrl).toString();
354-
const issuedTokenIds: string[] = [];
352+
const m2mToken = await u.services.clerk.m2m.createToken({
353+
machineSecretKey: network.unscopedSender.secretKey,
354+
secondsUntilExpiration: 60 * 30,
355+
});
355356

356357
try {
357-
// The new scope can take a moment to propagate to token-issuance, so
358-
// mint a fresh token on each poll iteration and stop once the issued
359-
// token is accepted by the primary server.
360-
let body: { subject: string; tokenType: string } | undefined;
361-
await expect
362-
.poll(
363-
async () => {
364-
const m2mToken = await u.services.clerk.m2m.createToken({
365-
machineSecretKey: network.unscopedSender.secretKey,
366-
secondsUntilExpiration: 60 * 30,
367-
});
368-
issuedTokenIds.push(m2mToken.id);
369-
const res = await u.page.request.get(url, {
370-
headers: { Authorization: `Bearer ${m2mToken.token}` },
371-
});
372-
if (res.status() !== 200) return res.status();
373-
body = await res.json();
374-
return 200;
375-
},
376-
{ timeout: 30_000, intervals: [500, 1000, 2000, 2000, 3000] },
377-
)
378-
.toBe(200);
379-
380-
expect(body!.subject).toBe(network.unscopedSender.id);
381-
expect(body!.tokenType).toBe(TokenType.M2MToken);
358+
const res = await u.page.request.get(new URL(adapter.m2m.path, app.serverUrl).toString(), {
359+
headers: { Authorization: `Bearer ${m2mToken.token}` },
360+
});
361+
expect(res.status()).toBe(200);
362+
const body = await res.json();
363+
expect(body.subject).toBe(network.unscopedSender.id);
364+
expect(body.tokenType).toBe(TokenType.M2MToken);
382365
} finally {
383-
for (const id of issuedTokenIds) {
384-
await u.services.clerk.m2m.revokeToken({ m2mTokenId: id }).catch(() => {});
385-
}
366+
await u.services.clerk.m2m.revokeToken({ m2mTokenId: m2mToken.id });
386367
}
387368
});
388369

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ export const createSessionTaskComponentPageObject = (testArgs: { page: EnhancedP
2727
newPassword: string;
2828
confirmPassword: string;
2929
}) => {
30-
const newPasswordInput = page.locator('input[name=newPassword]');
31-
await newPasswordInput.waitFor({ state: 'visible', timeout: 30_000 });
32-
await newPasswordInput.fill(newPassword);
30+
await page.locator('input[name=newPassword]').fill(newPassword);
3331
await page.locator('input[name=confirmPassword]').fill(confirmPassword);
3432

3533
const resetPasswordButton = page.getByRole('button', { name: /reset password/i });

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const createUserButtonPageObject = (testArgs: { page: EnhancedPage }) =>
77

88
const self = {
99
waitForMounted: () => {
10-
return page.waitForSelector('.cl-userButtonTrigger', { state: 'attached', timeout: 30_000 });
10+
return page.waitForSelector('.cl-userButtonTrigger', { state: 'attached' });
1111
},
1212
toggleTrigger: () => {
1313
return page.locator('.cl-userButtonTrigger').click();

0 commit comments

Comments
 (0)