feat: 更新密码页面识别逻辑,支持手机号注册和登录路径,并添加相关测试用例
This commit is contained in:
@@ -16,6 +16,21 @@ test('navigation utils module exposes a factory', () => {
|
||||
assert.equal(typeof api?.createNavigationUtils, 'function');
|
||||
});
|
||||
|
||||
test('navigation utils recognize signup password pages for email and phone signup', () => {
|
||||
const source = fs.readFileSync('background/navigation-utils.js', 'utf8');
|
||||
const globalScope = {};
|
||||
const api = new Function('self', `${source}; return self.MultiPageBackgroundNavigationUtils;`)(globalScope);
|
||||
const utils = api.createNavigationUtils({
|
||||
DEFAULT_CODEX2API_URL: 'http://localhost:8080/admin/accounts',
|
||||
DEFAULT_SUB2API_URL: 'https://sub.example.com/admin/accounts',
|
||||
normalizeLocalCpaStep9Mode: (value) => value,
|
||||
});
|
||||
|
||||
assert.equal(utils.isSignupPasswordPageUrl('https://auth.openai.com/create-account/password'), true);
|
||||
assert.equal(utils.isSignupPasswordPageUrl('https://auth.openai.com/log-in/password'), true);
|
||||
assert.equal(utils.isSignupPasswordPageUrl('https://auth.openai.com/log-in'), false);
|
||||
});
|
||||
|
||||
test('navigation utils treat 126 mail hosts as part of the shared NetEase mail family', () => {
|
||||
const source = fs.readFileSync('background/navigation-utils.js', 'utf8');
|
||||
const globalScope = {};
|
||||
|
||||
@@ -10,6 +10,10 @@ const signupFlowSource = fs.readFileSync('background/signup-flow-helpers.js', 'u
|
||||
const signupFlowGlobalScope = {};
|
||||
const signupFlowApi = new Function('self', `${signupFlowSource}; return self.MultiPageSignupFlowHelpers;`)(signupFlowGlobalScope);
|
||||
|
||||
const navigationSource = fs.readFileSync('background/navigation-utils.js', 'utf8');
|
||||
const navigationGlobalScope = {};
|
||||
const navigationApi = new Function('self', `${navigationSource}; return self.MultiPageBackgroundNavigationUtils;`)(navigationGlobalScope);
|
||||
|
||||
test('step 2 completes with password step skipped when landing on email verification page', async () => {
|
||||
const completedPayloads = [];
|
||||
|
||||
@@ -473,6 +477,69 @@ test('signup flow helper recognizes email verification page as post-email landin
|
||||
assert.equal(passwordReadyChecks, 0);
|
||||
});
|
||||
|
||||
test('signup flow helper accepts phone signup landing on login password page', async () => {
|
||||
let ensureCalls = 0;
|
||||
let passwordReadyChecks = 0;
|
||||
let predicateAcceptedLoginPassword = false;
|
||||
const navigationUtils = navigationApi.createNavigationUtils({
|
||||
DEFAULT_CODEX2API_URL: 'http://localhost:8080/admin/accounts',
|
||||
DEFAULT_SUB2API_URL: 'https://sub.example.com/admin/accounts',
|
||||
normalizeLocalCpaStep9Mode: (value) => value,
|
||||
});
|
||||
|
||||
const helpers = signupFlowApi.createSignupFlowHelpers({
|
||||
buildGeneratedAliasEmail: () => '',
|
||||
chrome: {
|
||||
tabs: {
|
||||
get: async () => ({
|
||||
id: 22,
|
||||
url: 'https://auth.openai.com/log-in/password',
|
||||
}),
|
||||
},
|
||||
},
|
||||
ensureContentScriptReadyOnTab: async () => {
|
||||
ensureCalls += 1;
|
||||
},
|
||||
ensureHotmailAccountForFlow: async () => ({}),
|
||||
ensureLuckmailPurchaseForFlow: async () => ({}),
|
||||
isGeneratedAliasProvider: () => false,
|
||||
isHotmailProvider: () => false,
|
||||
isLuckmailProvider: () => false,
|
||||
isSignupEmailVerificationPageUrl: navigationUtils.isSignupEmailVerificationPageUrl,
|
||||
isSignupPasswordPageUrl: (url) => {
|
||||
const accepted = navigationUtils.isSignupPasswordPageUrl(url);
|
||||
if (accepted && /\/log-in\/password(?:[/?#]|$)/i.test(url || '')) {
|
||||
predicateAcceptedLoginPassword = true;
|
||||
}
|
||||
return accepted;
|
||||
},
|
||||
reuseOrCreateTab: async () => 22,
|
||||
sendToContentScriptResilient: async (_source, message) => {
|
||||
assert.equal(message.type, 'ENSURE_SIGNUP_PASSWORD_PAGE_READY');
|
||||
passwordReadyChecks += 1;
|
||||
return {};
|
||||
},
|
||||
setEmailState: async () => {},
|
||||
SIGNUP_ENTRY_URL: 'https://chatgpt.com/',
|
||||
SIGNUP_PAGE_INJECT_FILES: [],
|
||||
waitForTabUrlMatch: async (_tabId, predicate) => {
|
||||
const url = 'https://auth.openai.com/log-in/password';
|
||||
return predicate(url) ? { id: 22, url } : null;
|
||||
},
|
||||
});
|
||||
|
||||
const result = await helpers.ensureSignupPostIdentityPageReadyInTab(22, 2);
|
||||
|
||||
assert.deepStrictEqual(result, {
|
||||
ready: true,
|
||||
state: 'password_page',
|
||||
url: 'https://auth.openai.com/log-in/password',
|
||||
});
|
||||
assert.equal(predicateAcceptedLoginPassword, true);
|
||||
assert.equal(ensureCalls, 1);
|
||||
assert.equal(passwordReadyChecks, 1);
|
||||
});
|
||||
|
||||
test('signup flow helper reuses existing managed alias email when it is still compatible', async () => {
|
||||
let buildCalls = 0;
|
||||
let setEmailCalls = 0;
|
||||
|
||||
@@ -51,6 +51,17 @@ function extractFunction(name) {
|
||||
return source.slice(start, end);
|
||||
}
|
||||
|
||||
test('signup password detector accepts create-account and phone login password paths', () => {
|
||||
const run = (pathname) => new Function('location', `
|
||||
${extractFunction('isSignupPasswordPage')}
|
||||
return isSignupPasswordPage();
|
||||
`)({ pathname });
|
||||
|
||||
assert.equal(run('/create-account/password'), true);
|
||||
assert.equal(run('/log-in/password'), true);
|
||||
assert.equal(run('/log-in'), false);
|
||||
});
|
||||
|
||||
test('signup entry diagnostics summarizes current page inputs and visible actions', () => {
|
||||
const api = new Function(`
|
||||
const SIGNUP_ENTRY_TRIGGER_PATTERN = /免费注册|立即注册|注册|sign\\s*up|register|create\\s*account|create\\s+account/i;
|
||||
|
||||
Reference in New Issue
Block a user