mirror of
https://github.com/morluto/rea.git
synced 2026-11-05 06:15:59 +00:00
feat(javascript): retain queryable static route inventories (#6019)
This commit is contained in:
1 parent
933af60eba
commit
7d0efef62d
67 files changed
+74345
-231
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { expect, it, onTestFinished, vi } from "vitest";
|
||||
import * as routeInventory from "../../../../src/domain/javascript/javascriptRouteInventory.js";
|
||||
import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js";
|
||||
import { reconstructJavaScriptArtifact } from "../../../support/javascriptApplicationScope.js";
|
||||
|
||||
it("retains completed route Evidence when cancellation arrives during inventory finalization", async () => {
|
||||
const root = await createTestTempDirectory("rea-route-finalization-");
|
||||
await writeFile(join(root, "routes.js"), "route('/reports');");
|
||||
const controller = new AbortController();
|
||||
const original = routeInventory.buildJavaScriptRouteInventorySteps;
|
||||
let interrupted = false;
|
||||
const hook = vi
|
||||
.spyOn(routeInventory, "buildJavaScriptRouteInventorySteps")
|
||||
.mockImplementation(function* (...args) {
|
||||
const steps: Iterator<void, routeInventory.JavaScriptRouteInventory> =
|
||||
original(...args);
|
||||
try {
|
||||
for (;;) {
|
||||
const step = steps.next();
|
||||
if (step.done) return step.value;
|
||||
// Inject cancellation at the real domain finalization boundary,
|
||||
// after source analysis and its preceding cancellation checkpoint.
|
||||
if (!interrupted) {
|
||||
interrupted = true;
|
||||
controller.abort();
|
||||
}
|
||||
yield;
|
||||
}
|
||||
} finally {
|
||||
steps.return?.();
|
||||
}
|
||||
});
|
||||
onTestFinished(() => hook.mockRestore());
|
||||
await expect(
|
||||
reconstructJavaScriptArtifact({ input_path: root }, controller.signal),
|
||||
).rejects.toMatchObject({
|
||||
reason: "cancelled",
|
||||
partialObservation: {
|
||||
operation: "analyze_javascript_application",
|
||||
normalized_result: {
|
||||
route_inventory: {
|
||||
routes: expect.arrayContaining([
|
||||
expect.objectContaining({ path: "/reports" }),
|
||||
]),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(interrupted).toBe(true);
|
||||
});
|
||||
Reference in new issue
Block a user