重构duckduckgo邮箱获取
This commit is contained in:
@@ -352,6 +352,113 @@ test('step 8 submits add-email before polling the email verification code', asyn
|
||||
]);
|
||||
});
|
||||
|
||||
test('step 8 email_in_use recovery preserves the previous registration baseline', async () => {
|
||||
const calls = {
|
||||
contentCalls: 0,
|
||||
setStates: [],
|
||||
updatedUrls: [],
|
||||
};
|
||||
|
||||
const executor = api.createStep8Executor({
|
||||
addLog: async () => {},
|
||||
chrome: {
|
||||
tabs: {
|
||||
update: async (_tabId, payload) => {
|
||||
calls.updatedUrls.push(payload.url);
|
||||
},
|
||||
},
|
||||
},
|
||||
buildRegistrationEmailStateUpdates: () => ({
|
||||
email: null,
|
||||
registrationEmailState: {
|
||||
current: '',
|
||||
previous: 'old.user@example.com',
|
||||
source: 'step8_recovery',
|
||||
updatedAt: 123,
|
||||
},
|
||||
}),
|
||||
CLOUDFLARE_TEMP_EMAIL_PROVIDER: 'cloudflare-temp-email',
|
||||
confirmCustomVerificationStepBypass: async () => {},
|
||||
ensureStep8VerificationPageReady: async () => ({
|
||||
state: 'add_email_page',
|
||||
url: 'https://auth.openai.com/add-email',
|
||||
}),
|
||||
getOAuthFlowRemainingMs: async () => 5000,
|
||||
getOAuthFlowStepTimeoutMs: async (defaultTimeoutMs) => defaultTimeoutMs,
|
||||
getMailConfig: () => ({
|
||||
provider: 'qq',
|
||||
label: 'QQ 閭',
|
||||
source: 'mail-qq',
|
||||
url: 'https://mail.qq.com',
|
||||
navigateOnReuse: false,
|
||||
}),
|
||||
getState: async () => ({
|
||||
email: '',
|
||||
registrationEmailState: {
|
||||
current: '',
|
||||
previous: 'old.user@example.com',
|
||||
source: 'step8_recovery',
|
||||
updatedAt: 123,
|
||||
},
|
||||
oauthUrl: 'https://auth.openai.com/add-email',
|
||||
password: 'secret',
|
||||
}),
|
||||
getTabId: async () => 1,
|
||||
HOTMAIL_PROVIDER: 'hotmail-api',
|
||||
isTabAlive: async () => true,
|
||||
isVerificationMailPollingError: () => false,
|
||||
LUCKMAIL_PROVIDER: 'luckmail-api',
|
||||
resolveSignupEmailForFlow: async () => 'new.user@example.com',
|
||||
resolveVerificationStep: async () => {},
|
||||
rerunStep7ForStep8Recovery: async () => {},
|
||||
reuseOrCreateTab: async () => {},
|
||||
sendToContentScriptResilient: async () => {
|
||||
calls.contentCalls += 1;
|
||||
if (calls.contentCalls === 1) {
|
||||
throw new Error('STEP8_EMAIL_IN_USE::old.user@example.com');
|
||||
}
|
||||
return {
|
||||
submitted: true,
|
||||
displayedEmail: 'new.user@example.com',
|
||||
url: 'https://auth.openai.com/email-verification',
|
||||
};
|
||||
},
|
||||
setState: async (payload) => {
|
||||
calls.setStates.push(payload);
|
||||
},
|
||||
shouldUseCustomRegistrationEmail: () => false,
|
||||
sleepWithStop: async () => {},
|
||||
STANDARD_MAIL_VERIFICATION_RESEND_INTERVAL_MS: 25000,
|
||||
STEP7_MAIL_POLLING_RECOVERY_MAX_ATTEMPTS: 3,
|
||||
throwIfStopped: () => {},
|
||||
});
|
||||
|
||||
await executor.executeStep8({
|
||||
email: 'old.user@example.com',
|
||||
registrationEmailState: {
|
||||
current: 'old.user@example.com',
|
||||
previous: 'old.user@example.com',
|
||||
source: 'generated:duck',
|
||||
updatedAt: 1,
|
||||
},
|
||||
oauthUrl: 'https://auth.openai.com/add-email',
|
||||
password: 'secret',
|
||||
visibleStep: 8,
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(calls.setStates[0], {
|
||||
email: null,
|
||||
registrationEmailState: {
|
||||
current: '',
|
||||
previous: 'old.user@example.com',
|
||||
source: 'step8_recovery',
|
||||
updatedAt: 123,
|
||||
},
|
||||
step8VerificationTargetEmail: '',
|
||||
loginVerificationRequestedAt: null,
|
||||
});
|
||||
});
|
||||
|
||||
test('Plus login-code step reuses step 8 verification logic but completes visible step 11', async () => {
|
||||
let resolvedStep = null;
|
||||
let resolvedOptions = null;
|
||||
|
||||
Reference in New Issue
Block a user