feat(session): support directory moves from slash commands
This commit is contained in:
parent
e8964ce672
commit
c1d2d7aba3
23 changed files with 521 additions and 206 deletions
|
|
@ -495,10 +495,12 @@ test("updates session location when moved", async () => {
|
|||
data: {
|
||||
sessionID: "ses_test",
|
||||
location: { directory: destination },
|
||||
projectID: "project-moved",
|
||||
subpath: "packages/cli",
|
||||
},
|
||||
})
|
||||
await wait(() => data.session.get("ses_test")?.location.directory === destination)
|
||||
expect(data.session.get("ses_test")?.projectID).toBe("project-moved")
|
||||
expect(data.session.get("ses_test")?.subpath).toBe("packages/cli")
|
||||
} finally {
|
||||
app.renderer.destroy()
|
||||
|
|
|
|||
44
packages/tui/test/cli/tui/keymap-arguments.test.tsx
Normal file
44
packages/tui/test/cli/tui/keymap-arguments.test.tsx
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/** @jsxImportSource @opentui/solid */
|
||||
import { testRender } from "@opentui/solid"
|
||||
import { expect, test } from "bun:test"
|
||||
import { ConfigProvider } from "../../../src/config"
|
||||
import { Keymap } from "../../../src/context/keymap"
|
||||
import { createTuiResolvedConfig } from "../../fixture/tui-runtime"
|
||||
|
||||
test("dispatch passes slash input through the registered command", async () => {
|
||||
const received: Array<string | undefined> = []
|
||||
let dispatch: ReturnType<typeof Keymap.use>["dispatch"]
|
||||
|
||||
function Commands() {
|
||||
const keymap = Keymap.use()
|
||||
dispatch = keymap.dispatch
|
||||
Keymap.createLayer(() => ({
|
||||
mode: "global",
|
||||
commands: [
|
||||
{
|
||||
id: "project.cd",
|
||||
slash: { name: "cd", arguments: true },
|
||||
run: (input) => {
|
||||
received.push(input)
|
||||
},
|
||||
},
|
||||
],
|
||||
}))
|
||||
return <box />
|
||||
}
|
||||
|
||||
const app = await testRender(() => (
|
||||
<ConfigProvider config={createTuiResolvedConfig()}>
|
||||
<Keymap.Provider>
|
||||
<Commands />
|
||||
</Keymap.Provider>
|
||||
</ConfigProvider>
|
||||
))
|
||||
try {
|
||||
dispatch!("project.cd")
|
||||
dispatch!("project.cd", "src/components with spaces")
|
||||
expect(received).toEqual([undefined, "src/components with spaces"])
|
||||
} finally {
|
||||
app.renderer.destroy()
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue