feat: 更新2925邮箱处理逻辑,增强验证码重发机制,调整测试用例

This commit is contained in:
QLHazyCoder
2026-04-20 13:15:39 +08:00
parent 8a16d81e01
commit ffecba6ab3
8 changed files with 108 additions and 48 deletions
+17 -5
View File
@@ -60,13 +60,22 @@ let refreshCalls = 0;
const clickOrder = [];
const readAndDeleteCalls = [];
const seenCodes = new Set();
const deletedMailIds = new Set();
const baselineMail = { id: 'baseline', text: 'OpenAI newsletter without code' };
const newMail = { id: 'new', text: 'OpenAI verification code 654321' };
function findMailItems() {
if (state === 'detail') return [];
if (state === 'baseline') return [baselineMail];
return [baselineMail, newMail];
const items = [];
if (state === 'detail') return items;
if (state === 'baseline' || state === 'with-new') {
if (!deletedMailIds.has('baseline')) {
items.push(baselineMail);
}
}
if (state === 'with-new' && !deletedMailIds.has('new')) {
items.push(newMail);
}
return items;
}
function getMailItemId(item) {
@@ -99,7 +108,9 @@ async function sleepRandom() {}
async function returnToInbox() {
clickOrder.push('inbox');
state = 'baseline';
if (state === 'detail') {
state = 'baseline';
}
return true;
}
@@ -113,6 +124,7 @@ async function refreshInbox() {
async function openMailAndDeleteAfterRead(item) {
readAndDeleteCalls.push(item.id);
deletedMailIds.add(item.id);
return item.id === 'new' ? 'Your ChatGPT code is 654321' : 'No code here';
}
@@ -142,7 +154,7 @@ return {
assert.equal(result.code, '654321');
assert.deepEqual(api.getClickOrder(), ['inbox', 'refresh', 'inbox', 'refresh']);
assert.deepEqual(api.getReadAndDeleteCalls(), ['new']);
assert.deepEqual(api.getReadAndDeleteCalls(), ['baseline', 'new']);
});
test('handlePollEmail ignores targetEmail and still tests any matching ChatGPT mail', async () => {