test(tmux): align placeholder command expectations
This commit is contained in:
@@ -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("\\$")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -102,21 +102,23 @@ describe("spawnTmuxSession runner integration", () => {
|
||||
expect(newSessionCall[1].slice(0, 4)).toEqual(["new-session", "-d", "-s", newSessionCall[1][3]])
|
||||
expect(String(newSessionCall[1][3]).startsWith("omo-agents-")).toBe(true)
|
||||
expect(selectPaneCall[1]).toEqual(["select-pane", "-t", "%42", "-T", "omo-subagent-worker"])
|
||||
expect(harness.getSpawnCommand()).toContain(` --dir '${directory}'`)
|
||||
expect(harness.getSpawnCommand()).toContain("Focus this pane to attach.")
|
||||
expect(harness.getSpawnCommand()).toContain("tail -f /dev/null")
|
||||
expect(harness.getSpawnCommand()).not.toContain("opencode attach")
|
||||
})
|
||||
|
||||
it("#given directory with spaces #when spawnTmuxSession called #then wraps --dir value in single quotes", async () => {
|
||||
it("#given description with spaces #when spawnTmuxSession called #then includes it in the placeholder", async () => {
|
||||
// given
|
||||
const harness = createHarness()
|
||||
|
||||
// when
|
||||
await spawnTmuxSession("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", "%0", harness.deps)
|
||||
await spawnTmuxSession("session-1", "worker with spaces", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", "%0", harness.deps)
|
||||
|
||||
// then
|
||||
expect(harness.getSpawnCommand()).toContain("--dir '/path with spaces/here'")
|
||||
expect(harness.getSpawnCommand()).toContain("OMO subagent pane ready: worker with spaces")
|
||||
})
|
||||
|
||||
it("#given empty directory #when spawnTmuxSession called #then falls back to process cwd", async () => {
|
||||
it("#given empty directory #when spawnTmuxSession called #then keeps the placeholder detached from attach", async () => {
|
||||
// given
|
||||
const harness = createHarness()
|
||||
|
||||
@@ -124,17 +126,18 @@ describe("spawnTmuxSession runner integration", () => {
|
||||
await spawnTmuxSession("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "", "%0", harness.deps)
|
||||
|
||||
// then
|
||||
expect(harness.getSpawnCommand()).toContain(`--dir '${process.cwd()}'`)
|
||||
expect(harness.getSpawnCommand()).not.toContain("--dir")
|
||||
})
|
||||
|
||||
it("#given directory with single quotes #when spawnTmuxSession called #then escapes the value with POSIX-safe single quoting", async () => {
|
||||
it("#given description with shell metacharacters #when spawnTmuxSession called #then escapes the placeholder", async () => {
|
||||
// given
|
||||
const harness = createHarness()
|
||||
|
||||
// when
|
||||
await spawnTmuxSession("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", "%0", harness.deps)
|
||||
await spawnTmuxSession("session-1", 'worker "$(whoami)"', enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", "%0", harness.deps)
|
||||
|
||||
// then
|
||||
expect(harness.getSpawnCommand()).toContain("--dir '/path/with'\\''quote'")
|
||||
expect(harness.getSpawnCommand()).toContain('\\"')
|
||||
expect(harness.getSpawnCommand()).toContain("\\$")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -90,21 +90,23 @@ describe("spawnTmuxWindow runner integration", () => {
|
||||
expect(result).toEqual({ success: true, paneId: "%42" })
|
||||
expect(firstCall[1].slice(0, 7)).toEqual(["new-window", "-d", "-n", "omo-agents", "-P", "-F", "#{pane_id}"])
|
||||
expect(secondCall[1]).toEqual(["select-pane", "-t", "%42", "-T", "omo-subagent-worker"])
|
||||
expect(harness.getNewWindowCommand()).toContain(` --dir '${directory}'`)
|
||||
expect(harness.getNewWindowCommand()).toContain("Focus this pane to attach.")
|
||||
expect(harness.getNewWindowCommand()).toContain("tail -f /dev/null")
|
||||
expect(harness.getNewWindowCommand()).not.toContain("opencode attach")
|
||||
})
|
||||
|
||||
it("#given directory with spaces #when spawnTmuxWindow called #then wraps --dir value in single quotes", async () => {
|
||||
it("#given description with spaces #when spawnTmuxWindow called #then includes it in the placeholder", async () => {
|
||||
// given
|
||||
const harness = createHarness()
|
||||
|
||||
// when
|
||||
await spawnTmuxWindow("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", harness.deps)
|
||||
await spawnTmuxWindow("session-1", "worker with spaces", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", harness.deps)
|
||||
|
||||
// then
|
||||
expect(harness.getNewWindowCommand()).toContain("--dir '/path with spaces/here'")
|
||||
expect(harness.getNewWindowCommand()).toContain("OMO subagent pane ready: worker with spaces")
|
||||
})
|
||||
|
||||
it("#given empty directory #when spawnTmuxWindow called #then falls back to process cwd", async () => {
|
||||
it("#given empty directory #when spawnTmuxWindow called #then keeps the placeholder detached from attach", async () => {
|
||||
// given
|
||||
const harness = createHarness()
|
||||
|
||||
@@ -112,17 +114,18 @@ describe("spawnTmuxWindow runner integration", () => {
|
||||
await spawnTmuxWindow("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "", harness.deps)
|
||||
|
||||
// then
|
||||
expect(harness.getNewWindowCommand()).toContain(`--dir '${process.cwd()}'`)
|
||||
expect(harness.getNewWindowCommand()).not.toContain("--dir")
|
||||
})
|
||||
|
||||
it("#given directory with single quotes #when spawnTmuxWindow called #then escapes the value with POSIX-safe single quoting", async () => {
|
||||
it("#given description with shell metacharacters #when spawnTmuxWindow called #then escapes the placeholder", async () => {
|
||||
// given
|
||||
const harness = createHarness()
|
||||
|
||||
// when
|
||||
await spawnTmuxWindow("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", harness.deps)
|
||||
await spawnTmuxWindow("session-1", 'worker "$(whoami)"', enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", harness.deps)
|
||||
|
||||
// then
|
||||
expect(harness.getNewWindowCommand()).toContain("--dir '/path/with'\\''quote'")
|
||||
expect(harness.getNewWindowCommand()).toContain('\\"')
|
||||
expect(harness.getNewWindowCommand()).toContain("\\$")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user