fix: align Plus no-payment flow and step5 completion
This commit is contained in:
@@ -61,6 +61,7 @@ function getStep5OutcomeBundle() {
|
||||
extractFunction('waitForStep5SubmitButton'),
|
||||
extractFunction('isStep5SubmitButtonClickable'),
|
||||
extractFunction('isStep5ProfileStillVisible'),
|
||||
extractFunction('isStep5CompletionChatgptUrl'),
|
||||
extractFunction('getStep5PostSubmitSuccessState'),
|
||||
extractFunction('installStep5NavigationCompletionReporter'),
|
||||
extractFunction('waitForStep5SubmitOutcome'),
|
||||
@@ -1057,6 +1058,7 @@ function isOAuthConsentPage() { return false; }
|
||||
function isAddPhonePageReady() { return false; }
|
||||
function isStep5ProfileStillVisible() { return false; }
|
||||
|
||||
${extractFunction('isStep5CompletionChatgptUrl')}
|
||||
${extractFunction('getStep5PostSubmitSuccessState')}
|
||||
|
||||
return {
|
||||
@@ -1068,3 +1070,99 @@ return {
|
||||
|
||||
assert.equal(api.run(), null);
|
||||
});
|
||||
|
||||
test('step 5 completion requires https chatgpt.com and rejects auth-success-like pages', () => {
|
||||
const api = new Function(`
|
||||
const location = {
|
||||
href: 'https://auth.openai.com/sign-in-with-chatgpt/codex/consent',
|
||||
};
|
||||
|
||||
function getStep5AuthRetryPageState() { return null; }
|
||||
function isStep5ProfileStillVisible() { return false; }
|
||||
|
||||
${extractFunction('isStep5CompletionChatgptUrl')}
|
||||
${extractFunction('getStep5PostSubmitSuccessState')}
|
||||
|
||||
return {
|
||||
run(url) {
|
||||
location.href = url;
|
||||
return getStep5PostSubmitSuccessState();
|
||||
},
|
||||
isCompletion(url) {
|
||||
return isStep5CompletionChatgptUrl(url);
|
||||
},
|
||||
};
|
||||
`)();
|
||||
|
||||
assert.deepStrictEqual(api.run('https://chatgpt.com/'), {
|
||||
state: 'logged_in_home',
|
||||
url: 'https://chatgpt.com/',
|
||||
});
|
||||
assert.deepStrictEqual(api.run('https://www.chatgpt.com/c/abc'), {
|
||||
state: 'logged_in_home',
|
||||
url: 'https://www.chatgpt.com/c/abc',
|
||||
});
|
||||
assert.equal(api.run('https://auth.openai.com/sign-in-with-chatgpt/codex/consent'), null);
|
||||
assert.equal(api.run('https://auth.openai.com/add-phone'), null);
|
||||
assert.equal(api.run('https://chat.openai.com/'), null);
|
||||
assert.equal(api.run('http://chatgpt.com/'), null);
|
||||
assert.equal(api.isCompletion('https://chatgpt.com/add-phone'), false);
|
||||
});
|
||||
|
||||
test('step 5 navigation reporter does not complete on beforeunload alone', () => {
|
||||
const api = new Function(`
|
||||
const events = [];
|
||||
const listeners = new Map();
|
||||
const location = {
|
||||
href: 'https://auth.openai.com/about-you',
|
||||
};
|
||||
const window = {
|
||||
addEventListener(type, handler) {
|
||||
listeners.set(type, handler);
|
||||
},
|
||||
removeEventListener(type) {
|
||||
listeners.delete(type);
|
||||
},
|
||||
};
|
||||
|
||||
function log(message, level = 'info') {
|
||||
events.push({ type: 'log', message, level });
|
||||
}
|
||||
function getStep5SubmitState() {
|
||||
return {
|
||||
url: location.href,
|
||||
retryPage: true,
|
||||
retryEnabled: true,
|
||||
successState: '',
|
||||
profileVisible: true,
|
||||
unknownAuthPage: false,
|
||||
maxCheckAttemptsBlocked: false,
|
||||
userAlreadyExistsBlocked: false,
|
||||
errorText: '',
|
||||
};
|
||||
}
|
||||
|
||||
${extractFunction('logStep5SubmitDebug')}
|
||||
${extractFunction('installStep5NavigationCompletionReporter')}
|
||||
|
||||
return {
|
||||
run() {
|
||||
let completionCount = 0;
|
||||
const cleanup = installStep5NavigationCompletionReporter(() => {
|
||||
completionCount += 1;
|
||||
events.push({ type: 'complete' });
|
||||
});
|
||||
const beforeUnload = listeners.get('beforeunload');
|
||||
if (beforeUnload) {
|
||||
beforeUnload({ type: 'beforeunload' });
|
||||
}
|
||||
cleanup();
|
||||
return { completionCount, events };
|
||||
},
|
||||
};
|
||||
`)();
|
||||
|
||||
const result = api.run();
|
||||
assert.equal(result.completionCount, 0);
|
||||
assert.equal(result.events.some((entry) => entry.type === 'log' && /检测到页面开始导航/.test(entry.message)), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user