mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 14:44:45 +00:00
test: tighten channel assertion checks
This commit is contained in:
@@ -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 });
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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([
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user