mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
f00810b0ea
Merged via squash. Prepared head SHA:58aa59eaf8Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com> Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com> Reviewed-by: @jalehman (cherry picked from commitef47dd610c)
76 lines
2.7 KiB
TypeScript
76 lines
2.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
findSessionAccessorBoundaryViolations,
|
|
migratedSessionAccessorFiles,
|
|
} from "../../scripts/check-session-accessor-boundary.mjs";
|
|
|
|
describe("session accessor boundary guard", () => {
|
|
it("ratchets only the files migrated by the session accessor gateway slice", () => {
|
|
expect(migratedSessionAccessorFiles).toEqual(
|
|
new Set([
|
|
"src/config/sessions/combined-store-gateway.ts",
|
|
"src/gateway/session-utils.ts",
|
|
"src/gateway/sessions-resolve.ts",
|
|
"src/gateway/server-methods/sessions.ts",
|
|
]),
|
|
);
|
|
});
|
|
|
|
it("flags legacy reader imports", () => {
|
|
expect(
|
|
findSessionAccessorBoundaryViolations(`
|
|
import { loadSessionStore, readSessionEntries as readEntries } from "../config/sessions.js";
|
|
`),
|
|
).toEqual([
|
|
{ line: 2, reason: 'imports legacy session store reader "loadSessionStore"' },
|
|
{ line: 2, reason: 'imports legacy session store reader "readSessionEntries"' },
|
|
]);
|
|
});
|
|
|
|
it("flags direct and namespace legacy reader calls", () => {
|
|
expect(
|
|
findSessionAccessorBoundaryViolations(`
|
|
loadSessionStore(storePath);
|
|
sessions.readSessionEntries(storePath);
|
|
sessions["loadSessionStore"](storePath);
|
|
`),
|
|
).toEqual([
|
|
{ line: 2, reason: 'calls legacy session store reader "loadSessionStore"' },
|
|
{ line: 3, reason: 'references legacy session store reader "readSessionEntries"' },
|
|
{ line: 4, reason: 'references legacy session store reader "loadSessionStore"' },
|
|
]);
|
|
});
|
|
|
|
it("flags aliased namespace reader references", () => {
|
|
expect(
|
|
findSessionAccessorBoundaryViolations(`
|
|
const load = sessions.loadSessionStore;
|
|
const { readSessionEntries: readEntries } = sessions;
|
|
const { loadSessionStore } = sessions;
|
|
`),
|
|
).toEqual([
|
|
{ line: 2, reason: 'references legacy session store reader "loadSessionStore"' },
|
|
{ line: 3, reason: 'aliases legacy session store reader "readSessionEntries"' },
|
|
{ line: 4, reason: 'aliases legacy session store reader "loadSessionStore"' },
|
|
]);
|
|
});
|
|
|
|
it("allows migrated accessor reads", () => {
|
|
expect(
|
|
findSessionAccessorBoundaryViolations(`
|
|
import { listSessionEntries } from "../config/sessions/session-accessor.js";
|
|
listSessionEntries({ storePath });
|
|
`),
|
|
).toEqual([]);
|
|
});
|
|
|
|
it("ignores comments and strings that describe legacy readers", () => {
|
|
expect(
|
|
findSessionAccessorBoundaryViolations(`
|
|
// loadSessionStore and readSessionEntries used to be called here.
|
|
const description = "loadSessionStore";
|
|
`),
|
|
).toEqual([]);
|
|
});
|
|
});
|