Files
FlowPilot/tests/background-step5-submit-short-circuit.test.js
T
QLHazyCoder c745405f90 feat: Enhance Step 9 diagnostics and error handling
- Refactor getStatusBadgeEntries to use createStep9Entry for better encapsulation.
- Introduce error visual signals detection in createStep9Entry.
- Add functions to identify OAuth callback timeout failures and step 9 failure texts.
- Update buildStep9StatusDiagnostics to include error visual summaries and handle conflicts between success and failure states.
- Implement new tests for step 9 diagnostics, ensuring correct behavior with success badges and error banners.
- Remove outdated tests related to step 5 onboarding and redirect race conditions.
- Add new tests for auto-run behavior in step 6 restart scenarios.
2026-04-17 04:33:14 +08:00

48 lines
1.4 KiB
JavaScript

const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const source = fs.readFileSync('background/steps/fill-profile.js', 'utf8');
const globalScope = {};
const api = new Function('self', `${source}; return self.MultiPageBackgroundStep5;`)(globalScope);
test('step 5 forwards generated profile data and relies on completion signal flow', async () => {
const events = {
logs: [],
messages: [],
};
const executor = api.createStep5Executor({
addLog: async (message, level) => {
events.logs.push({ message, level: level || 'info' });
},
generateRandomBirthday: () => ({ year: 2003, month: 6, day: 19 }),
generateRandomName: () => ({ firstName: 'Test', lastName: 'User' }),
sendToContentScript: async (source, message) => {
events.messages.push({ source, message });
return { accepted: true };
},
});
await executor.executeStep5();
assert.deepStrictEqual(events.messages, [
{
source: 'signup-page',
message: {
type: 'EXECUTE_STEP',
step: 5,
source: 'background',
payload: {
firstName: 'Test',
lastName: 'User',
year: 2003,
month: 6,
day: 19,
},
},
},
]);
assert.ok(events.logs.some(({ message }) => /已生成姓名 Test User/.test(message)));
});