Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions services/kiloclaw/plugins/kilo-chat/src/channel.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { readFile } from 'node:fs/promises';
import { describe, expect, it, vi } from 'vitest';
import { __pluginInternals, kiloChatPlugin } from './channel';

Expand Down Expand Up @@ -260,22 +259,6 @@ describe('kilo-chat actions adapter', () => {
expect(adapter?.resolveExecutionMode?.({ action: 'react' as never })).toBe('local');
});

it('routes send actions before constructing the shared action client', async () => {
const source = await readFile(new URL('./channel.ts', import.meta.url), 'utf8');
const handleActionIndex = source.indexOf(
'handleAction: async (ctx: ChannelMessageActionContext)'
);
const sendBranchIndex = source.indexOf(
"if (ctx.action === 'send' || ctx.action === 'upload-file')",
handleActionIndex
);
const sharedClientIndex = source.indexOf('const client = makeClient();', handleActionIndex);

expect(handleActionIndex).toBeGreaterThanOrEqual(0);
expect(sendBranchIndex).toBeGreaterThan(handleActionIndex);
expect(sharedClientIndex).toBeGreaterThan(sendBranchIndex);
});

it('handles send with a base64 buffer as an arbitrary attachment', async () => {
const calls: Array<{ url: string; init: RequestInit }> = [];
const fetchImpl = vi.fn(async (input: string | URL, init?: RequestInit) => {
Expand Down
29 changes: 0 additions & 29 deletions services/kiloclaw/plugins/kilo-chat/src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,35 +128,6 @@ describe('createKiloChatClient', () => {
const body = JSON.parse((init as RequestInit).body as string);
expect(body.inReplyToMessageId).toBeUndefined();
});

it('createMessage posts to /_kilo/kilo-chat/send and returns messageId', async () => {
const fetchImpl = vi.fn(
async () =>
new Response(JSON.stringify(createMessageResponse()), {
status: 200,
headers: { 'content-type': 'application/json' },
})
);
const client = createKiloChatClient({
controllerBaseUrl: 'http://127.0.0.1:18789',
gatewayToken: 'gwt',
fetchImpl: fetchImpl as unknown as typeof fetch,
});

const result = await client.createMessage({
conversationId: 'c1',
content: [{ type: 'text', text: 'hello' }],
});

expect(fetchImpl).toHaveBeenCalledTimes(1);
const [url, init] = fetchImpl.mock.calls[0]!;
expect(url).toBe('http://127.0.0.1:18789/_kilo/kilo-chat/send');
const init2 = init as RequestInit;
expect(init2.method).toBe('POST');
const body = JSON.parse(init2.body as string);
expect(body).toEqual({ conversationId: 'c1', content: [{ type: 'text', text: 'hello' }] });
expect(result.messageId).toBe('m1');
});
});

describe('editMessage', () => {
Expand Down

This file was deleted.