test(tmux): align placeholder command expectations

This commit is contained in:
YeonGyu-Kim
2026-05-16 00:14:06 +09:00
parent 91f1cf5fbc
commit 54a7256a71
4 changed files with 43 additions and 33 deletions
@@ -115,21 +115,23 @@ describe("spawnTmuxPane runner integration", () => {
expect(result).toEqual({ success: true, paneId: "%42" })
expect(firstCall[1].slice(0, 8)).toEqual(["split-window", "-h", "-d", "-P", "-F", "#{pane_id}", "-t", "%0"])
expect(secondCall[1]).toEqual(["select-pane", "-t", "%42", "-T", "omo-subagent-worker"])
expect(getSplitWindowCommand()).toContain(` --dir '${directory}'`)
expect(getSplitWindowCommand()).toContain("Focus this pane to attach.")
expect(getSplitWindowCommand()).toContain("tail -f /dev/null")
expect(getSplitWindowCommand()).not.toContain("opencode attach")
})
it("#given directory with spaces #when spawnTmuxPane called #then wraps --dir value in single quotes", async () => {
it("#given description with spaces #when spawnTmuxPane called #then includes it in the placeholder", async () => {
// given
const spawnTmuxPane = await loadSpawnTmuxPane()
// when
await spawnTmuxPane("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", "%0", "-h", createDeps())
await spawnTmuxPane("session-1", "worker with spaces", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", "%0", "-h", createDeps())
// then
expect(getSplitWindowCommand()).toContain("--dir '/path with spaces/here'")
expect(getSplitWindowCommand()).toContain("OMO subagent pane ready: worker with spaces")
})
it("#given empty directory #when spawnTmuxPane called #then falls back to process cwd", async () => {
it("#given empty directory #when spawnTmuxPane called #then keeps the placeholder detached from attach", async () => {
// given
const spawnTmuxPane = await loadSpawnTmuxPane()
@@ -137,17 +139,18 @@ describe("spawnTmuxPane runner integration", () => {
await spawnTmuxPane("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "", "%0", "-h", createDeps())
// then
expect(getSplitWindowCommand()).toContain(`--dir '${process.cwd()}'`)
expect(getSplitWindowCommand()).not.toContain("--dir")
})
it("#given directory with single quotes #when spawnTmuxPane called #then escapes the value with POSIX-safe single quoting", async () => {
it("#given description with shell metacharacters #when spawnTmuxPane called #then escapes the placeholder", async () => {
// given
const spawnTmuxPane = await loadSpawnTmuxPane()
// when
await spawnTmuxPane("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", "%0", "-h", createDeps())
await spawnTmuxPane("session-1", 'worker "$(whoami)"', enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", "%0", "-h", createDeps())
// then
expect(getSplitWindowCommand()).toContain("--dir '/path/with'\\''quote'")
expect(getSplitWindowCommand()).toContain('\\"')
expect(getSplitWindowCommand()).toContain("\\$")
})
})