From ae74e87fa796575a0a5b1774548275941fa9d007 Mon Sep 17 00:00:00 2001 From: QLHazycoder <2825305047@qq.com> Date: Sun, 3 May 2026 03:41:36 +0800 Subject: [PATCH] fix(flow): preserve combined signup skip reason --- background/verification-flow.js | 3 + tests/verification-flow-polling.test.js | 80 +++++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/background/verification-flow.js b/background/verification-flow.js index 9926498..aa1d8bd 100644 --- a/background/verification-flow.js +++ b/background/verification-flow.js @@ -1254,6 +1254,9 @@ code: result.code, phoneVerificationRequired: Boolean(submitResult.addPhonePage), ...(step === 4 && submitResult?.skipProfileStep ? { skipProfileStep: true } : {}), + ...(step === 4 && submitResult?.skipProfileStepReason + ? { skipProfileStepReason: submitResult.skipProfileStepReason } + : {}), }); triggerPostSuccessMailboxCleanup(step, mail); return { diff --git a/tests/verification-flow-polling.test.js b/tests/verification-flow-polling.test.js index 3ab3d53..85a5ea8 100644 --- a/tests/verification-flow-polling.test.js +++ b/tests/verification-flow-polling.test.js @@ -1342,6 +1342,86 @@ test('verification flow forwards optional signup profile payload when submitting }); }); +test('verification flow keeps combined signup profile skip reason when completing signup verification', async () => { + const completed = []; + const resilientCalls = []; + + const helpers = api.createVerificationFlowHelpers({ + addLog: async () => {}, + chrome: { + tabs: { + update: async () => {}, + }, + }, + CLOUDFLARE_TEMP_EMAIL_PROVIDER: 'cloudflare-temp-email', + completeStepFromBackground: async (step, payload) => { + completed.push({ step, payload }); + }, + 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 () => { + throw new Error('should not use non-resilient channel'); + }, + sendToContentScriptResilient: async (_source, message) => { + resilientCalls.push(message); + return { + success: true, + skipProfileStep: true, + skipProfileStepReason: 'combined_verification_profile', + }; + }, + sendToMailContentScriptResilient: async () => ({ + code: '654321', + emailTimestamp: 123, + }), + setState: async () => {}, + setStepStatus: async () => {}, + sleepWithStop: async () => {}, + throwIfStopped: () => {}, + VERIFICATION_POLL_MAX_ROUNDS: 5, + }); + + await helpers.resolveVerificationStep( + 4, + { email: 'user@example.com', lastSignupCode: null }, + { provider: 'qq', label: 'QQ 邮箱' }, + { + signupProfile: { + firstName: 'Ada', + lastName: 'Lovelace', + year: 2003, + month: 6, + day: 19, + }, + } + ); + + assert.equal(resilientCalls[0].payload.signupProfile.firstName, 'Ada'); + assert.deepStrictEqual(completed, [ + { + step: 4, + payload: { + emailTimestamp: 123, + code: '654321', + phoneVerificationRequired: false, + skipProfileStep: true, + skipProfileStepReason: 'combined_verification_profile', + }, + }, + ]); +}); + test('verification flow treats retryable submit transport failure as success when step 4 already redirected to logged-in home', async () => { const logs = [];