test: tighten channel assertion checks

This commit is contained in:
Peter Steinberger
2026-05-11 15:12:38 +01:00
parent 5ad73cb995
commit 9074f08fc3
5 changed files with 28 additions and 31 deletions

View File

@@ -38,7 +38,8 @@ vi.spyOn(cliCoreApiModule.defaultRuntime, "exit").mockImplementation(browserCliR
const { registerBrowserStateCommands } = await import("./browser-cli-state.js");
describe("browser state option collisions", () => {
const stripAnsi = (value: string) => value.replace(/\u001b\[[0-9;]*m/g, "");
const ansiPattern = new RegExp(String.raw`\u001b\[[0-9;]*m`, "g");
const stripAnsi = (value: string) => value.replace(ansiPattern, "");
const createStateProgram = ({ withGatewayUrl = false } = {}) => {
const { program, browser, parentOpts } = createBrowserProgramShared({ withGatewayUrl });

View File

@@ -222,13 +222,11 @@ describe("bundled channel entry shape guards", () => {
);
const plugin = bundled.requireBundledChannelPlugin("alpha");
expect(plugin.meta).toMatchObject({
id: "alpha",
label: "Alpha",
selectionLabel: "Use Alpha",
docsPath: "/channels/alpha",
blurb: "Alpha channel metadata.",
});
expect(plugin.meta.id).toBe("alpha");
expect(plugin.meta.label).toBe("Alpha");
expect(plugin.meta.selectionLabel).toBe("Use Alpha");
expect(plugin.meta.docsPath).toBe("/channels/alpha");
expect(plugin.meta.blurb).toBe("Alpha channel metadata.");
} finally {
restoreBundledPluginsDir(previousBundledPluginsDir);
fs.rmSync(tempRoot, { recursive: true, force: true });

View File

@@ -5,9 +5,10 @@ const discordSessionBindingAdapterChannels = ["discord"] as const;
describe("channel contract registry", () => {
function expectSessionBindingCoverage(expectedChannelIds: readonly string[]) {
expect([...sessionBindingContractChannelIds]).toEqual(
expect.arrayContaining([...expectedChannelIds]),
);
const registeredIds = new Set<string>(sessionBindingContractChannelIds);
for (const expectedChannelId of expectedChannelIds) {
expect(registeredIds.has(expectedChannelId)).toBe(true);
}
}
it.each([

View File

@@ -141,20 +141,15 @@ describe("session conversation bundled fallback", () => {
it("delegates repeated fallback calls through the public-surface loader", () => {
enableThreadedFallback();
expect(resolveSessionConversationRef("agent:main:mock-threaded:group:room:topic:42")).toEqual(
expect.objectContaining({
channel: "mock-threaded",
id: "room",
threadId: "42",
}),
);
expect(resolveSessionConversationRef("agent:main:mock-threaded:group:room:topic:43")).toEqual(
expect.objectContaining({
channel: "mock-threaded",
id: "room",
threadId: "43",
}),
);
const firstRef = resolveSessionConversationRef("agent:main:mock-threaded:group:room:topic:42");
expect(firstRef?.channel).toBe("mock-threaded");
expect(firstRef?.id).toBe("room");
expect(firstRef?.threadId).toBe("42");
const secondRef = resolveSessionConversationRef("agent:main:mock-threaded:group:room:topic:43");
expect(secondRef?.channel).toBe("mock-threaded");
expect(secondRef?.id).toBe("room");
expect(secondRef?.threadId).toBe("43");
expect(fallbackState.loadCalls).toBe(2);
});
});

View File

@@ -2118,12 +2118,14 @@ describe("resolveAccountIdForConfigure", () => {
});
expect(accountId).toBe("prompted-id");
expect(prompter.select).toHaveBeenCalledWith(
expect.objectContaining({
message: "Signal account",
initialValue: "fallback",
}),
);
const selectCalls = prompter.select.mock.calls as unknown as Array<
[{ message?: string; initialValue?: string }]
>;
const selectOptions = selectCalls[0]?.[0] as
| { message?: string; initialValue?: string }
| undefined;
expect(selectOptions?.message).toBe("Signal account");
expect(selectOptions?.initialValue).toBe("fallback");
expect(prompter.text).not.toHaveBeenCalled();
});
});