fix: align Plus no-payment flow and step5 completion

This commit is contained in:
QLHazyCoder
2026-05-22 01:35:42 +08:00
parent a7b35ee11a
commit 3f6fc3e1e8
17 changed files with 911 additions and 96 deletions
@@ -110,6 +110,7 @@ async function waitForTabStableComplete() {}
${extractFunction('parseUrlSafely')}
${extractFunction('isSignupEntryHost')}
${extractFunction('isLikelyLoggedInChatgptHomeUrl')}
${extractFunction('isStep5CompletionChatgptUrl')}
${extractFunction('getStep5SubmitStateFromContent')}
${extractFunction('recoverStep5SubmitRetryPageOnTab')}
${extractFunction('validateStep5PostCompletion')}
@@ -138,3 +139,65 @@ return {
true
);
});
test('step 5 post-completion validation rejects non-chatgpt success candidates', async () => {
const api = new Function(`
const logs = [];
const chrome = {
tabs: {
async get() {
return { url: 'https://auth.openai.com/sign-in-with-chatgpt/codex/consent' };
},
},
};
async function sendToContentScriptResilient(source, message) {
if (message.type === 'GET_STEP5_SUBMIT_STATE') {
return {
retryPage: false,
retryEnabled: false,
maxCheckAttemptsBlocked: false,
userAlreadyExistsBlocked: false,
successState: 'oauth_consent',
profileVisible: false,
errorText: '',
unknownAuthPage: false,
url: 'https://auth.openai.com/sign-in-with-chatgpt/codex/consent',
};
}
throw new Error('unexpected message type: ' + message.type);
}
async function addLog(message, level, meta) {
logs.push({ message, level, meta });
}
async function waitForTabStableComplete() {}
${extractFunction('parseUrlSafely')}
${extractFunction('isSignupEntryHost')}
${extractFunction('isLikelyLoggedInChatgptHomeUrl')}
${extractFunction('isStep5CompletionChatgptUrl')}
${extractFunction('getStep5SubmitStateFromContent')}
${extractFunction('recoverStep5SubmitRetryPageOnTab')}
${extractFunction('validateStep5PostCompletion')}
return {
run() {
return validateStep5PostCompletion(99, {});
},
snapshot() {
return { logs };
},
};
`)();
await assert.rejects(
api.run(),
/尚未跳转到 https:\/\/chatgpt\.com/
);
assert.equal(
api.snapshot().logs.some(({ message }) => / chatgpt\.com 的步骤 5 完成候选/.test(message)),
true
);
});