fix(signup): restart phone signup on step 3 phone-exists errors

Treat phone-number-already-exists messages on the signup password page as the same restartable step-3 failure path used for phone/password mismatches.

Also adds a regression test covering the Chinese phone-exists error so the flow stops immediately instead of retrying the password submit loop.
This commit is contained in:
yigedludan8
2026-05-07 21:00:17 +08:00
parent f6fa19a44f
commit da02aa62cf
2 changed files with 92 additions and 3 deletions
+89
View File
@@ -806,3 +806,92 @@ return {
assert.equal(result.clicks.length, 0);
assert.equal(result.logs.some(({ message }) => /检测到密码页报错/.test(message)), true);
});
test('prepareSignupVerificationFlow stops immediately when password page shows phone already exists error', async () => {
const api = new Function(`
const logs = [];
const clicks = [];
let now = 0;
Date.now = () => now;
function throwIfStopped() {}
function log(message, level = 'info') { logs.push({ message, level }); }
async function sleep(ms = 0) { now += ms || 200; }
function isVisibleElement() { return true; }
function isActionEnabled() { return true; }
function getActionText(el) { return el?.textContent || ''; }
function getCurrentAuthRetryPageState() { return null; }
function isPhoneVerificationPageReady() { return false; }
function findResendVerificationCodeTrigger() { return null; }
function isEmailVerificationPage() { return false; }
function getPageTextSnapshot() { return '与此电话号码相关联的帐户已存在'; }
function getVerificationCodeTarget() { return null; }
function is405MethodNotAllowedPage() { return false; }
async function recoverCurrentAuthRetryPage() {}
function createSignupUserAlreadyExistsError() { return new Error('user already exists'); }
function getSignupPasswordInput() { return { value: 'Secret123!' }; }
function getSignupPasswordSubmitButton() { return { textContent: 'Continue' }; }
function isSignupEmailAlreadyExistsPage() { return false; }
function isSignupPasswordErrorPage() { return false; }
function getSignupPasswordTimeoutErrorPageState() { return null; }
function isStep5Ready() { return false; }
function getSignupPasswordFieldErrorText() { return '与此电话号码相关联的帐户已存在'; }
function simulateClick(target) { clicks.push(target?.textContent || 'clicked'); }
async function humanPause() {}
function fillInput() {}
function logSignupPasswordDiagnostics() {}
function createSignupPhonePasswordMismatchError(detailText = '') {
return new Error('SIGNUP_PHONE_PASSWORD_MISMATCH::' + detailText);
}
const location = {
href: 'https://auth.openai.com/log-in/password',
pathname: '/log-in/password',
};
const document = {
readyState: 'complete',
title: '',
body: {
textContent: '与此电话号码相关联的帐户已存在',
innerText: '与此电话号码相关联的帐户已存在',
},
querySelector() {
return null;
},
querySelectorAll() {
return [];
},
};
${extractFunction('isSignupVerificationPageInteractiveReady')}
${extractFunction('isVerificationPageStillVisible')}
${extractFunction('isSignupProfilePageUrl')}
${extractFunction('isLikelyLoggedInChatgptHomeUrl')}
${extractFunction('getStep4PostVerificationState')}
${extractFunction('inspectSignupVerificationState')}
${extractFunction('waitForSignupVerificationTransition')}
${extractFunction('prepareSignupVerificationFlow')}
return {
async run() {
try {
await prepareSignupVerificationFlow({
password: 'Secret123!',
prepareLogLabel: '步骤 3 收尾',
}, 10000);
return { threw: false, logs, clicks };
} catch (error) {
return { threw: true, error: error.message, logs, clicks };
}
},
};
`)();
const result = await api.run();
assert.equal(result.threw, true);
assert.match(result.error, /SIGNUP_PHONE_PASSWORD_MISMATCH::与此电话号码相关联的帐户已存在/);
assert.equal(result.clicks.length, 0);
assert.equal(result.logs.some(({ message }) => /检测到密码页报错/.test(message)), true);
});