fix: improve LuckMail verification resend flow

This commit is contained in:
zhangkun
2026-04-28 13:12:20 +08:00
parent 5c5296afec
commit 96e6fa9242
3 changed files with 137 additions and 1 deletions
+69
View File
@@ -1030,6 +1030,75 @@ test('verification flow waits during resend cooldown instead of tight-looping',
assert.ok(sleepCalls[0] >= 1000);
});
test('verification flow clicks resend before waiting for the next LuckMail /code retry', async () => {
const events = [];
let pollCalls = 0;
const helpers = api.createVerificationFlowHelpers({
addLog: async () => {},
chrome: { tabs: { update: async () => {} } },
CLOUDFLARE_TEMP_EMAIL_PROVIDER: 'cloudflare-temp-email',
completeStepFromBackground: async () => {},
confirmCustomVerificationStepBypassRequest: async () => ({ confirmed: true }),
getHotmailVerificationPollConfig: () => ({}),
getHotmailVerificationRequestTimestamp: () => 0,
getState: async () => ({}),
getTabId: async () => 1,
HOTMAIL_PROVIDER: 'hotmail-api',
isStopError: () => false,
LUCKMAIL_PROVIDER: 'luckmail-api',
MAIL_2925_VERIFICATION_INTERVAL_MS: 15000,
MAIL_2925_VERIFICATION_MAX_ATTEMPTS: 15,
pollCloudflareTempEmailVerificationCode: async () => ({}),
pollHotmailVerificationCode: async () => ({}),
pollLuckmailVerificationCode: async (_step, _state, payload) => {
pollCalls += 1;
events.push(['poll', payload.maxAttempts, payload.intervalMs]);
if (pollCalls === 1) {
throw new Error('步骤 4LuckMail /code 接口暂未返回新的验证码。');
}
return {
code: '654321',
emailTimestamp: 123,
};
},
sendToContentScript: async (_source, message) => {
if (message.type === 'RESEND_VERIFICATION_CODE') {
events.push(['resend', message.step]);
}
return {};
},
sendToMailContentScriptResilient: async () => ({}),
setState: async () => {},
setStepStatus: async () => {},
sleepWithStop: async (ms) => {
events.push(['sleep', ms]);
},
throwIfStopped: () => {},
VERIFICATION_POLL_MAX_ROUNDS: 5,
});
const result = await helpers.pollFreshVerificationCode(
4,
{
email: 'user@example.com',
lastSignupCode: null,
},
{ provider: 'luckmail-api', label: 'LuckMailAPI 购邮)' },
{
resendIntervalMs: 15000,
}
);
assert.equal(result.code, '654321');
assert.deepStrictEqual(events, [
['poll', 1, 15000],
['resend', 4],
['sleep', 15000],
['poll', 1, 15000],
]);
});
test('verification flow uses resilient signup-page transport when submitting verification code', async () => {
const resilientCalls = [];