test: avoid status module reload

This commit is contained in:
Shakker
2026-05-09 16:53:32 +01:00
parent 3307478282
commit 8437ccf5a2

View File

@@ -34,6 +34,8 @@ vi.mock("../plugins/commands.js", () => ({
afterEach(() => {
vi.restoreAllMocks();
listPluginCommands.mockReset();
listPluginCommands.mockImplementation(() => []);
MODEL_CONTEXT_TOKEN_CACHE.clear();
});
@@ -2131,9 +2133,7 @@ describe("buildCommandsMessagePaginated", () => {
];
listPluginCommands.mockImplementation(() => pluginCommands);
expect(listPluginCommands()).toEqual(pluginCommands);
vi.resetModules();
const { buildCommandsMessagePaginated: buildPaginatedCommands } = await import("./status.js");
const firstPage = buildPaginatedCommands(
const firstPage = buildCommandsMessagePaginated(
{
commands: { config: false, debug: false },
} as unknown as OpenClawConfig,
@@ -2141,7 +2141,7 @@ describe("buildCommandsMessagePaginated", () => {
{ surface: "telegram", page: 1, forcePaginatedList: true },
);
const pages = Array.from({ length: firstPage.totalPages }, (_, index) =>
buildPaginatedCommands(
buildCommandsMessagePaginated(
{
commands: { config: false, debug: false },
} as unknown as OpenClawConfig,