c745405f90
- 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.
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
|
|
test('background imports tab runtime module', () => {
|
|
const source = fs.readFileSync('background.js', 'utf8');
|
|
assert.match(source, /background\/tab-runtime\.js/);
|
|
});
|
|
|
|
test('tab runtime module exposes a factory', () => {
|
|
const source = fs.readFileSync('background/tab-runtime.js', 'utf8');
|
|
const globalScope = {};
|
|
|
|
const api = new Function('self', `${source}; return self.MultiPageBackgroundTabRuntime;`)(globalScope);
|
|
|
|
assert.equal(typeof api?.createTabRuntime, 'function');
|
|
});
|
|
|
|
test('tab runtime waitForTabComplete waits until tab status becomes complete', async () => {
|
|
const source = fs.readFileSync('background/tab-runtime.js', 'utf8');
|
|
const globalScope = {};
|
|
const api = new Function('self', `${source}; return self.MultiPageBackgroundTabRuntime;`)(globalScope);
|
|
|
|
let getCalls = 0;
|
|
const runtime = api.createTabRuntime({
|
|
LOG_PREFIX: '[test]',
|
|
addLog: async () => {},
|
|
buildLocalhostCleanupPrefix: () => '',
|
|
chrome: {
|
|
tabs: {
|
|
get: async () => {
|
|
getCalls += 1;
|
|
return {
|
|
id: 9,
|
|
url: 'https://example.com',
|
|
status: getCalls >= 3 ? 'complete' : 'loading',
|
|
};
|
|
},
|
|
query: async () => [],
|
|
},
|
|
},
|
|
getSourceLabel: (source) => source || 'unknown',
|
|
getState: async () => ({ tabRegistry: {}, sourceLastUrls: {} }),
|
|
matchesSourceUrlFamily: () => false,
|
|
normalizeLocalCpaStep9Mode: () => 'submit',
|
|
parseUrlSafely: () => null,
|
|
registerTab: async () => {},
|
|
setState: async () => {},
|
|
shouldBypassStep9ForLocalCpa: () => false,
|
|
});
|
|
|
|
const result = await runtime.waitForTabComplete(9, {
|
|
timeoutMs: 2000,
|
|
retryDelayMs: 1,
|
|
});
|
|
|
|
assert.equal(result?.status, 'complete');
|
|
assert.equal(getCalls, 3);
|
|
});
|