A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
test(api): keep the lookup captcha test in one window (#3682)
Hampus4e38842557d7
diff --git a/fluxer_api/src/api/auth/tests/IdentifierFirstSignIn.test.ts b/fluxer_api/src/api/auth/tests/IdentifierFirstSignIn.test.tsindex 06a1927ba..052f4badc 100644--- a/fluxer_api/src/api/auth/tests/IdentifierFirstSignIn.test.ts+++ b/fluxer_api/src/api/auth/tests/IdentifierFirstSignIn.test.ts@@ -94,6 +94,12 @@ describe('Identifier-first sign-in', () => {await getUserRepository().patchUpsert(user.id, {password_hash: null}, user.toRow());}+ async function stayInsideOneLookupWindow(): Promise<void> {+ const windowMs = 10 * 60 * 1000;+ const remainingMs = windowMs - (Date.now() % windowMs);+ if (remainingMs < 15_000) await new Promise((resolve) => setTimeout(resolve, remainingMs + 100));+ }+function lastCode(email: string, type: string, emails: Awaited<ReturnType<typeof listTestEmails>>): string {const record = findLastTestEmail(emails.filter((entry) => entry.to.toLowerCase() === email.toLowerCase()),@@ -515,6 +521,7 @@ describe('Identifier-first sign-in', () => {it('asks a stranger for a captcha once one network looks up too many addresses', async () => {await useCheapCaptcha();+ await stayInsideOneLookupWindow();const lookups = async (count: number) => {for (let index = 0; index < count; index++) {await createBuilderWithoutAuth(harness)