refactor(viewer): profile rerun loading by playback stage
This commit is contained in:
@@ -7,6 +7,7 @@ let createLiveViewerDiagnosticLifecycle;
|
||||
let createAbortFencedBuildVerifier;
|
||||
let createUiBuildStaleCoordinator;
|
||||
let liveViewerDiagnosticBody;
|
||||
let reloadRecordedViewerAfterStaleModuleFailure;
|
||||
let server;
|
||||
let uiBuildIdFromModuleScripts;
|
||||
let verifyLiveViewerClientBuild;
|
||||
@@ -22,6 +23,7 @@ before(async () => {
|
||||
createLiveViewerDiagnosticLifecycle,
|
||||
createUiBuildStaleCoordinator,
|
||||
liveViewerDiagnosticBody,
|
||||
reloadRecordedViewerAfterStaleModuleFailure,
|
||||
uiBuildIdFromModuleScripts,
|
||||
verifyLiveViewerClientBuild,
|
||||
} = await server.ssrLoadModule("/src/core/observation/liveViewerDiagnostics.ts"));
|
||||
@@ -204,6 +206,36 @@ test("build drift is reported once with the exact loaded build", async () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("a recorded viewer reloads only when its failed lazy module belongs to a stale build", async () => {
|
||||
const reloads = [];
|
||||
const loadedUiBuildId = "/assets/index-abcdefgh.js";
|
||||
const currentUiBuildId = "/assets/index-ijklmnop.js";
|
||||
const fetcher = async (_url, options) => {
|
||||
assert.equal(options.headers["X-MissionCore-UI-Build"], loadedUiBuildId);
|
||||
return new Response(JSON.stringify({}), {
|
||||
status: 200,
|
||||
headers: { "X-MissionCore-UI-Build": currentUiBuildId },
|
||||
});
|
||||
};
|
||||
|
||||
assert.equal(await reloadRecordedViewerAfterStaleModuleFailure({
|
||||
loadedUiBuildId,
|
||||
fetcher,
|
||||
reload: () => reloads.push("reload"),
|
||||
}), true);
|
||||
assert.deepEqual(reloads, ["reload"]);
|
||||
|
||||
assert.equal(await reloadRecordedViewerAfterStaleModuleFailure({
|
||||
loadedUiBuildId: currentUiBuildId,
|
||||
fetcher: async () => new Response(JSON.stringify({}), {
|
||||
status: 200,
|
||||
headers: { "X-MissionCore-UI-Build": currentUiBuildId },
|
||||
}),
|
||||
reload: () => reloads.push("unexpected"),
|
||||
}), false);
|
||||
assert.deepEqual(reloads, ["reload"]);
|
||||
});
|
||||
|
||||
test("last unsubscribe fences an already queued build verification callback", () => {
|
||||
const controller = new AbortController();
|
||||
const observedSignals = [];
|
||||
|
||||
Reference in New Issue
Block a user