fix: restart signup phone mismatch without duplicate logs
This commit is contained in:
@@ -717,3 +717,92 @@ return {
|
||||
assert.equal(snapshot.sleepCalls >= 3, true);
|
||||
assert.equal(snapshot.targetChecks >= 1, true);
|
||||
});
|
||||
|
||||
test('prepareSignupVerificationFlow stops immediately when password page shows phone/password mismatch', 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 'Incorrect phone number or password'; }
|
||||
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 'Incorrect phone number or password'; }
|
||||
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: 'Incorrect phone number or password',
|
||||
innerText: 'Incorrect phone number or password',
|
||||
},
|
||||
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::Incorrect phone number or password/);
|
||||
assert.equal(result.clicks.length, 0);
|
||||
assert.equal(result.logs.some(({ message }) => /检测到密码页报错/.test(message)), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user