feat: 增强2925邮箱处理逻辑,添加邮件预清空机制,更新相关测试用例

This commit is contained in:
QLHazyCoder
2026-04-20 15:42:35 +08:00
parent 4107e4d378
commit 8dd6daccd1
4 changed files with 146 additions and 5 deletions
+7
View File
@@ -431,12 +431,17 @@ test('deleteAllMailboxEmails selects all messages and clicks delete', async () =
const calls = [];
const selectAllControl = { kind: 'select-all' };
const deleteButton = { kind: 'delete' };
let mailboxCleared = false;
async function returnToInbox() {
calls.push('inbox');
return true;
}
function findMailItems() {
return mailboxCleared ? [] : [{ id: 'mail-1' }];
}
function findSelectAllControl() {
return selectAllControl;
}
@@ -456,11 +461,13 @@ function simulateClick(node) {
}
if (node === deleteButton) {
calls.push('delete');
mailboxCleared = true;
return;
}
throw new Error('unexpected node');
}
async function sleep() {}
async function sleepRandom() {}
const console = { warn() {} };
+68 -2
View File
@@ -111,7 +111,7 @@ test('verification flow runs beforeSubmit hook before filling the code', async (
]);
});
test('verification flow triggers 2925 mailbox cleanup only after code submission succeeds', async () => {
test('verification flow clears 2925 mailbox before polling and after successful login code submission', async () => {
const mailMessages = [];
const helpers = api.createVerificationFlowHelpers({
@@ -169,7 +169,73 @@ test('verification flow triggers 2925 mailbox cleanup only after code submission
await new Promise((resolve) => setTimeout(resolve, 0));
assert.deepStrictEqual(mailMessages, ['POLL_EMAIL', 'DELETE_ALL_EMAILS']);
assert.deepStrictEqual(mailMessages, ['DELETE_ALL_EMAILS', 'POLL_EMAIL', 'DELETE_ALL_EMAILS']);
});
test('verification flow clears 2925 mailbox before polling and after successful signup code submission', async () => {
const mailMessages = [];
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 () => ({}),
sendToContentScript: async (_source, message) => {
if (message.type === 'FILL_CODE') {
return {};
}
if (message.type === 'RESEND_VERIFICATION_CODE') {
return {};
}
return {};
},
sendToMailContentScriptResilient: async (_mail, message) => {
mailMessages.push(message.type);
if (message.type === 'POLL_EMAIL') {
return { code: '654321', emailTimestamp: 123 };
}
return { ok: true, deleted: true };
},
setState: async () => {},
setStepStatus: async () => {},
sleepWithStop: async () => {},
throwIfStopped: () => {},
VERIFICATION_POLL_MAX_ROUNDS: 5,
});
await helpers.resolveVerificationStep(
4,
{
email: 'user@example.com',
mailProvider: '2925',
lastSignupCode: null,
},
{ provider: '2925', label: '2925 邮箱' },
{
requestFreshCodeFirst: false,
}
);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.deepStrictEqual(mailMessages, ['DELETE_ALL_EMAILS', 'POLL_EMAIL', 'DELETE_ALL_EMAILS']);
});
test('verification flow treats add-phone after login code submit as fatal instead of completing step 8', async () => {