chore: preserve step-aware logging after upstream sync

- 吸收 master 的核心改动:按可见步骤归类日志显示,覆盖 OAuth、手机号验证、平台验证和内容脚本日志链路。

- 本地补充修复:保留平台验证成功后的手机号接码确认收尾,避免 #193/#194 恢复的手机号复用链路被合并覆盖。

- 影响范围:background routing、phone verification、platform verify、content scripts、sidepanel 与相关测试/文档。
This commit is contained in:
QLHazyCoder
2026-05-04 04:41:49 +08:00
25 changed files with 690 additions and 290 deletions
@@ -8,8 +8,8 @@ function createDeps(overrides = {}) {
const uiCalls = [];
const deps = {
addLog: async (message, level = 'info') => {
logs.push({ message, level });
addLog: async (message, level = 'info', options = {}) => {
logs.push({ message, level, step: options.step, stepKey: options.stepKey });
},
chrome: {
tabs: {
@@ -91,8 +91,8 @@ test('platform verify module submits CPA callback via management API first', asy
},
]);
assert.deepStrictEqual(logs, [
{ message: '步骤 10正在通过 CPA 管理接口提交回调地址...', level: 'info' },
{ message: '步骤 10CPA API 回调提交成功', level: 'ok' },
{ message: '正在通过 CPA 管理接口提交回调地址...', level: 'info', step: 10, stepKey: 'platform-verify' },
{ message: 'CPA API 回调提交成功', level: 'ok', step: 10, stepKey: 'platform-verify' },
]);
} finally {
globalThis.fetch = originalFetch;
@@ -160,8 +160,10 @@ test('platform verify module fails fast when CPA API submit fails', async () =>
assert.equal(uiCalls.length, 0);
assert.equal(completed.length, 0);
assert.equal(logs[0].message, '步骤 10正在通过 CPA 管理接口提交回调地址...');
assert.match(logs[1].message, /步骤 10CPA 接口提交失败:failed to persist oauth callback/);
assert.equal(logs[0].message, '正在通过 CPA 管理接口提交回调地址...');
assert.equal(logs[0].step, 10);
assert.match(logs[1].message, /CPA 接口提交失败:failed to persist oauth callback/);
assert.equal(logs[1].step, 10);
assert.equal(logs[1].level, 'error');
} finally {
globalThis.fetch = originalFetch;