Skip to content

Commit 825fabf

Browse files
committed
tests: add UI smoke test for custom slash commands
1 parent 818b30b commit 825fabf

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* UI smoke test for custom executable slash commands (.mux/commands/*).
3+
*
4+
* This test uses the mock AI router (via createAppHarness) to avoid calling real LLMs.
5+
* It validates the end-to-end UI flow:
6+
* - User sends `/<name>`
7+
* - mux discovers and runs `.mux/commands/<name>` in the workspace
8+
* - stdout becomes the user message sent to the model
9+
*/
10+
11+
import * as fs from "fs/promises";
12+
import * as path from "path";
13+
14+
import { preloadTestModules } from "../ipc/setup";
15+
16+
import { createAppHarness } from "./harness";
17+
18+
async function createCustomCommand(options: {
19+
workspacePath: string;
20+
name: string;
21+
script: string;
22+
}): Promise<void> {
23+
const commandsDir = path.join(options.workspacePath, ".mux", "commands");
24+
await fs.mkdir(commandsDir, { recursive: true });
25+
26+
const commandPath = path.join(commandsDir, options.name);
27+
await fs.writeFile(commandPath, options.script);
28+
await fs.chmod(commandPath, 0o755);
29+
}
30+
31+
describe("Custom Slash Commands UI (mock router)", () => {
32+
beforeAll(async () => {
33+
await preloadTestModules();
34+
});
35+
36+
test("runs a custom command and sends stdout as the message", async () => {
37+
const app = await createAppHarness({ branchPrefix: "slash-ui" });
38+
39+
try {
40+
await createCustomCommand({
41+
workspacePath: app.metadata.namedWorkspacePath,
42+
name: "hello",
43+
script: '#!/usr/bin/env bash\necho "Hello from custom command"',
44+
});
45+
46+
await app.chat.send("/hello");
47+
48+
// The command output should become the user message sent to the model.
49+
await app.chat.expectTranscriptContains("Mock response: Hello from custom command");
50+
} finally {
51+
await app.dispose();
52+
}
53+
}, 60_000);
54+
});

0 commit comments

Comments
 (0)