Files
FlowPilot/tests/background-logging-status-module.test.js
T
QLHazyCoder e37a0269f2 fix: handle signup phone entry mode before email submission
- 同步最新 dev 到 PR #113,并保留 dev 上更完整的 163 邮箱实现\n- 补充 Step 2 的手机号入口切邮箱逻辑与本地化邮箱输入识别\n- 避免把 Step 2 的 phone entry 提示误判成 auth add-phone 致命错误
2026-04-25 14:53:13 +08:00

43 lines
1.6 KiB
JavaScript

const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
test('background imports logging/status module', () => {
const source = fs.readFileSync('background.js', 'utf8');
assert.match(source, /background\/logging-status\.js/);
});
test('logging/status module exposes a factory', () => {
const source = fs.readFileSync('background/logging-status.js', 'utf8');
const globalScope = {};
const api = new Function('self', `${source}; return self.MultiPageBackgroundLoggingStatus;`)(globalScope);
assert.equal(typeof api?.createLoggingStatus, 'function');
});
test('logging/status add-phone detection ignores step 2 phone-entry switch failures', () => {
const source = fs.readFileSync('background/logging-status.js', 'utf8');
const globalScope = {};
const api = new Function('self', `${source}; return self.MultiPageBackgroundLoggingStatus;`)(globalScope);
const loggingStatus = api.createLoggingStatus({
chrome: { runtime: { sendMessage() { return Promise.resolve(); } } },
DEFAULT_STATE: { stepStatuses: {} },
getState: async () => ({ stepStatuses: {} }),
isRecoverableStep9AuthFailure: () => false,
LOG_PREFIX: '[test]',
setState: async () => {},
STOP_ERROR_MESSAGE: 'stopped',
});
assert.equal(
loggingStatus.isAddPhoneAuthFailure('Step 2: the signup dialog is still in phone entry mode and has not switched back to email entry. URL: https://chatgpt.com/'),
false
);
assert.equal(
loggingStatus.isAddPhoneAuthFailure('Step 8: verification submitted but the auth flow entered the phone number page. URL: https://auth.openai.com/add-phone'),
true
);
});