Skip to content

Commit 9fe4602

Browse files
committed
chore(functional-tests): Speed up test account destroy
Because: - We have a step that will wait for an email up to 45 seconds This Commit: - Runs the email code fetch in parallel with another request to use whichever we get back first, speeding up tests
1 parent 625a4b2 commit 9fe4602

1 file changed

Lines changed: 17 additions & 20 deletions

File tree

packages/functional-tests/lib/testAccountTracker.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -256,27 +256,24 @@ export class TestAccountTracker {
256256
const verifyIfNeeded = async () => {
257257
try {
258258
await this.target.authClient.sessionResendVerifyCode(sessionToken);
259-
// Prefer short (signup) code to confirm account when unverified
260-
try {
261-
const shortCode =
262-
await this.target.emailClient.getVerifyShortCode(account.email);
263-
await this.target.authClient.sessionVerifyCode(
264-
sessionToken,
265-
shortCode
266-
);
267-
return;
268-
} catch (_) {
269-
// Fallback to login verification code for unverified session
270-
}
271-
const loginCode = await this.target.emailClient.getVerifyLoginCode(
272-
account.email
273-
);
274-
await this.target.authClient.sessionVerifyCode(
275-
sessionToken,
276-
loginCode
259+
260+
// Start checking for codes in parallel, whichever is available first will be used
261+
const [shortCodePromise, loginCodePromise] = [
262+
this.target.emailClient.getVerifyShortCode(account.email),
263+
this.target.emailClient.getVerifyLoginCode(account.email),
264+
];
265+
const code = await Promise.any([
266+
shortCodePromise,
267+
loginCodePromise,
268+
]);
269+
await this.target.authClient.sessionVerifyCode(sessionToken, code);
270+
} catch (err) {
271+
// allow console.error so we can capture this message in the trace.
272+
// eslint-disable-next-line no-console
273+
console.error(
274+
`Session verification skipped (might already be verified):`,
275+
err
277276
);
278-
} catch {
279-
// Ignore verification errors - account/session might already be verified
280277
}
281278
};
282279

0 commit comments

Comments
 (0)