From 17cefe8b2a49704fe4e1b9875c19ea745255a982 Mon Sep 17 00:00:00 2001 From: EmptyDust <1422492074@qq.com> Date: Sat, 2 May 2026 12:39:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=81=A2=E5=A4=8D=20step4=20=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=90=8E=E7=9A=84=E5=8E=9F=E6=9C=89=E8=B5=84=E6=96=99?= =?UTF-8?q?=E9=A1=B5=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/signup-page.js | 9 ++--- tests/step4-submit-retry-recovery.test.js | 41 +++++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/content/signup-page.js b/content/signup-page.js index 7ea1cb7..bf01a03 100644 --- a/content/signup-page.js +++ b/content/signup-page.js @@ -1144,10 +1144,11 @@ function isLikelyLoggedInChatgptHomeUrl(rawUrl = location.href) { } } -function getStep4PostVerificationState() { +function getStep4PostVerificationState(options = {}) { + const { ignoreVerificationVisibility = false } = options; // Newer auth flows can briefly render profile fields before the email-verification // form fully exits. Do not advance to Step 5 while verification UI is still present. - if (isVerificationPageStillVisible()) { + if (!ignoreVerificationVisibility && isVerificationPageStillVisible()) { return null; } @@ -2388,7 +2389,7 @@ async function waitForVerificationSubmitOutcome(step, timeout) { } if (step === 4) { - const postVerificationState = getStep4PostVerificationState(); + const postVerificationState = getStep4PostVerificationState({ ignoreVerificationVisibility: true }); if (postVerificationState?.state === 'logged_in_home') { return { success: true, @@ -2423,7 +2424,7 @@ async function waitForVerificationSubmitOutcome(step, timeout) { throw createSignupUserAlreadyExistsError(); } - const postVerificationState = getStep4PostVerificationState(); + const postVerificationState = getStep4PostVerificationState({ ignoreVerificationVisibility: true }); if (postVerificationState?.state === 'logged_in_home') { return { success: true, diff --git a/tests/step4-submit-retry-recovery.test.js b/tests/step4-submit-retry-recovery.test.js index 3324cb3..c5d856f 100644 --- a/tests/step4-submit-retry-recovery.test.js +++ b/tests/step4-submit-retry-recovery.test.js @@ -198,3 +198,44 @@ return { url: 'https://chatgpt.com/', }); }); + +test('waitForVerificationSubmitOutcome treats step 5 as success after submit even when verification ui residue remains', async () => { + const api = new Function(` +const location = { href: 'https://auth.openai.com/email-verification/register' }; + +function throwIfStopped() {} +function log() {} +function getVerificationErrorText() { return ''; } +function isStep5Ready() { return true; } +function isStep8Ready() { return false; } +function isAddPhonePageReady() { return false; } +function isVerificationPageStillVisible() { return true; } +function createSignupUserAlreadyExistsError() { + return new Error('SIGNUP_USER_ALREADY_EXISTS::步骤 4:检测到 user_already_exists,说明当前用户已存在,当前轮将直接停止。'); +} +function getCurrentAuthRetryPageState() { + return null; +} +async function recoverCurrentAuthRetryPage() { + throw new Error('should not recover retry page'); +} +async function sleep() {} + +${extractFunction('isSignupProfilePageUrl')} +${extractFunction('isLikelyLoggedInChatgptHomeUrl')} +${extractFunction('getStep4PostVerificationState')} +${extractFunction('waitForVerificationSubmitOutcome')} + +return { + run() { + return waitForVerificationSubmitOutcome(4, 1000); + }, +}; +`)(); + + const result = await api.run(); + + assert.deepStrictEqual(result, { + success: true, + }); +});