Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/retrigger-core-2-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
43 changes: 31 additions & 12 deletions integration/tests/reverification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,22 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withReverification] })(
await u.page.getByRole('button', { name: /LogUserId/i }).click();
await expect(u.page.getByText(/\{\s*"userId"\s*:\s*"user_[^"]+"\s*\}/i)).toBeVisible();

// Hack to reset fva
// startVerification no longer resets fva server-side, so age the signed-in factor past afterMinutes
await u.po.expect.toBeSignedIn();
await page.evaluate(async () => {
return window.Clerk.session.startVerification({
level: 'first_factor',
});
});
await expect
.poll(
() =>
page.evaluate(async () => {
const token = await window.Clerk.session?.getToken({ skipCache: true });
if (!token) {
return -1;
}
const payload = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
return JSON.parse(atob(payload)).fva?.[0] ?? -1;
}),
{ intervals: [5_000], timeout: 120_000 },
)
.toBeGreaterThanOrEqual(1);
await u.page.goToRelative(`/requires-re-verification`);
await u.page.getByRole('button', { name: /LogUserId/i }).click();
await expect(
Expand All @@ -248,6 +257,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withReverification] })(
});

test(`reverification recovery from ${capitalize(type)}`, async ({ page, context }) => {
test.setTimeout(270_000);
const u = createTestUtils({ app, page, context });

await u.po.signIn.goTo();
Expand All @@ -263,13 +273,22 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withReverification] })(
await u.page.getByRole('button', { name: /LogUserId/i }).click();
await expect(u.page.getByText(/\{\s*"userId"\s*:\s*"user_[^"]+"\s*\}/i)).toBeVisible();

// Hack to reset fva
// startVerification no longer resets fva server-side, so age the signed-in factor past afterMinutes
await u.po.expect.toBeSignedIn();
await page.evaluate(async () => {
return window.Clerk.session.startVerification({
level: 'first_factor',
});
});
await expect
.poll(
() =>
page.evaluate(async () => {
const token = await window.Clerk.session?.getToken({ skipCache: true });
if (!token) {
return -1;
}
const payload = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
return JSON.parse(atob(payload)).fva?.[0] ?? -1;
}),
{ intervals: [5_000], timeout: 120_000 },
)
.toBeGreaterThanOrEqual(1);

await u.page.goToRelative(`/action-with-use-reverification`);
await u.po.expect.toBeSignedIn();
Expand Down
Loading