Skip to content

Commit 49bf7da

Browse files
authored
Merge pull request #19528 from mozilla/chore/functional-test-account-cleaup-speed
chore(functional-tests): Speed up test account destroy
2 parents 625a4b2 + 9fe4602 commit 49bf7da

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)