fix: align Plus no-payment flow and step5 completion
This commit is contained in:
@@ -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
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user