修复bug

This commit is contained in:
brother7 committed 2026-08-30 00:13:22 +08:00
1 parent c65f00c941
commit 98282d127c
33 files changed
+1104 -167

No files matched your search

+41
View File
@@ -25,6 +25,19 @@ function loadPopupBusinessUrlMatcher(popupSource) {
return context.isBusinessSystemUrl;
}
function loadKeepaliveStateNormalizer(backgroundSource) {
const start = backgroundSource.indexOf('function normalizeErpKeepaliveState');
const end = backgroundSource.indexOf('async function readErpKeepaliveState', start);
assert.ok(start >= 0 && end > start, 'background must expose the keepalive state normalizer');
const context = {};
vm.runInNewContext(
`${backgroundSource.slice(start, end)}\nthis.normalizeErpKeepaliveState = normalizeErpKeepaliveState;`,
context,
{ filename: 'background-keepalive-state.js' }
);
return context.normalizeErpKeepaliveState;
}
test('production control-plane origin is recognized and bridge injection is permitted', async () => {
const [manifestText, background, popup] = await Promise.all([
read('chrome-extension/ltjt-order-assistant/manifest.json'),
@@ -105,6 +118,34 @@ test('ERP exception recovery refreshes the existing ERP tab once, then performs
assert.doesNotMatch(recoveryBody, /captureAjaxSubmit|SubmitInfoForm|DoInfo/);
});
test('an interrupted service worker recovery cannot leave ERP dispatch permanently blocked', async () => {
const background = await read('chrome-extension/ltjt-order-assistant/background.js');
const normalizeErpKeepaliveState = loadKeepaliveStateNormalizer(background);
const persistedRunning = {
last_status: 'running',
recovery_status: 'running',
recovery_attempt_at: '2026-08-29T12:00:00.000Z',
recovery_completed_at: '',
recovery_error: ''
};
const active = normalizeErpKeepaliveState(persistedRunning, true);
assert.equal(active.last_status, 'running');
assert.equal(active.recovery_status, 'running');
const interrupted = normalizeErpKeepaliveState(persistedRunning, false);
assert.equal(interrupted.last_status, 'interrupted');
assert.equal(interrupted.recovery_status, 'interrupted');
assert.equal(interrupted.recovery_error, 'erp_link_recovery_interrupted');
const keepaliveBody = background.slice(
background.indexOf('async function runErpSessionKeepalive'),
background.indexOf('async function ensureErpSessionKeepaliveAlarm')
);
assert.match(keepaliveBody, /success && !erpLinkRecoveryInFlight/);
assert.match(keepaliveBody, /recovery_status: 'idle'/);
});
test('keepalive setting and last probe state are visible without changing the business operation contract', async () => {
const [background, bridge, popup, popupHtml] = await Promise.all([
read('chrome-extension/ltjt-order-assistant/background.js'),