fix(k1): stabilize live recovery and media admission
This commit is contained in:
@@ -620,6 +620,53 @@ test("canonical K1 preparation stops before START and guards every async stage",
|
||||
);
|
||||
});
|
||||
|
||||
test("K1 control-phase polling fails closed instead of stacking timed-out state reads", async () => {
|
||||
const hookSource = await readFile(
|
||||
new URL(
|
||||
"../../../plugins/xgrids-k1/frontend/src/useXgridsK1Runtime.ts",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
const controlPollingLoop = hookSource.slice(
|
||||
hookSource.indexOf("async function waitForControlPhase"),
|
||||
hookSource.indexOf("async function waitForPhysicalReconciliationProof"),
|
||||
);
|
||||
|
||||
assert.match(hookSource, /const CONTROL_PHASE_WAIT_TIMEOUT_MS = 120_000/);
|
||||
assert.match(controlPollingLoop, /xgridsK1Api\.getState\(\)/);
|
||||
assert.doesNotMatch(controlPollingLoop, /ApiRequestTimeoutError/);
|
||||
assert.doesNotMatch(controlPollingLoop, /catch \(error\)/);
|
||||
assert.doesNotMatch(
|
||||
controlPollingLoop,
|
||||
/(?:openApplicationControlSession|enterApplicationWorkspace|prepareAcquisition|startAcquisition|stopAcquisition)\(/,
|
||||
);
|
||||
});
|
||||
|
||||
test("K1 frontend coalesces concurrent read-only state requests without caching them", async () => {
|
||||
const apiSource = await readFile(
|
||||
new URL(
|
||||
"../../../plugins/xgrids-k1/frontend/src/api.ts",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
const singleFlight = apiSource.slice(
|
||||
apiSource.indexOf("let stateReadInFlight"),
|
||||
apiSource.indexOf("export const xgridsK1Api"),
|
||||
);
|
||||
const getState = apiSource.slice(
|
||||
apiSource.indexOf("async getState"),
|
||||
apiSource.indexOf("scanBle("),
|
||||
);
|
||||
|
||||
assert.match(singleFlight, /if \(stateReadInFlight\) return stateReadInFlight/);
|
||||
assert.match(singleFlight, /invokeState\(xgridsK1Actions\.stateRead\)/);
|
||||
assert.match(singleFlight, /stateReadInFlight === request[\s\S]*?stateReadInFlight = null/);
|
||||
assert.match(getState, /return readStateSingleFlight\(\)/);
|
||||
assert.doesNotMatch(singleFlight, /setTimeout|setInterval|retry/i);
|
||||
});
|
||||
|
||||
test("K1 control-session CAS is exact, integer-only and mapped for each mutation family", () => {
|
||||
const state = {
|
||||
application_control_session: {
|
||||
|
||||
Reference in New Issue
Block a user