|
|
@@ -23,6 +23,9 @@ const svc = {
|
|
|
create(input?: SessionNs.CreateInput) {
|
|
|
return run(SessionNs.Service.use((svc) => svc.create(input)))
|
|
|
},
|
|
|
+ list(input?: SessionNs.ListInput) {
|
|
|
+ return run(SessionNs.Service.use((svc) => svc.list(input)))
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
afterEach(async () => {
|
|
|
@@ -55,7 +58,7 @@ describe("session.list", () => {
|
|
|
fn: async () => svc.create({ title: "sibling" }),
|
|
|
})
|
|
|
|
|
|
- const ids = [...svc.list()].map((s) => s.id)
|
|
|
+ const ids = (await svc.list()).map((s) => s.id)
|
|
|
expect(ids).toContain(root.id)
|
|
|
expect(ids).toContain(parent.id)
|
|
|
expect(ids).toContain(current.id)
|
|
|
@@ -88,7 +91,7 @@ describe("session.list", () => {
|
|
|
fn: async () => svc.create({ title: "sibling" }),
|
|
|
})
|
|
|
|
|
|
- const ids = [...svc.list({ directory: path.join(tmp.path, "packages", "opencode") })].map((s) => s.id)
|
|
|
+ const ids = (await svc.list({ directory: path.join(tmp.path, "packages", "opencode") })).map((s) => s.id)
|
|
|
expect(ids).not.toContain(root.id)
|
|
|
expect(ids).not.toContain(parent.id)
|
|
|
expect(ids).toContain(current.id)
|
|
|
@@ -123,9 +126,12 @@ describe("session.list", () => {
|
|
|
fn: async () => svc.create({ title: "sibling" }),
|
|
|
})
|
|
|
|
|
|
- const pathIDs = [
|
|
|
- ...svc.list({ directory: path.join(tmp.path, "packages", "app"), path: "packages/opencode/src" }),
|
|
|
- ].map((s) => s.id)
|
|
|
+ const pathIDs = (
|
|
|
+ await svc.list({
|
|
|
+ directory: path.join(tmp.path, "packages", "app"),
|
|
|
+ path: "packages/opencode/src",
|
|
|
+ })
|
|
|
+ ).map((s) => s.id)
|
|
|
expect(pathIDs).not.toContain(parent.id)
|
|
|
expect(pathIDs).toContain(current.id)
|
|
|
expect(pathIDs).toContain(deeper.id)
|
|
|
@@ -155,9 +161,12 @@ describe("session.list", () => {
|
|
|
Database.use((db) => db.update(SessionTable).set({ path: null }).where(eq(SessionTable.id, current.id)).run())
|
|
|
Database.use((db) => db.update(SessionTable).set({ path: null }).where(eq(SessionTable.id, sibling.id)).run())
|
|
|
|
|
|
- const pathIDs = [
|
|
|
- ...svc.list({ directory: path.join(tmp.path, "packages", "opencode", "src"), path: "packages/opencode/src" }),
|
|
|
- ].map((s) => s.id)
|
|
|
+ const pathIDs = (
|
|
|
+ await svc.list({
|
|
|
+ directory: path.join(tmp.path, "packages", "opencode", "src"),
|
|
|
+ path: "packages/opencode/src",
|
|
|
+ })
|
|
|
+ ).map((s) => s.id)
|
|
|
expect(pathIDs).toContain(current.id)
|
|
|
expect(pathIDs).not.toContain(sibling.id)
|
|
|
},
|
|
|
@@ -172,7 +181,7 @@ describe("session.list", () => {
|
|
|
const root = await svc.create({ title: "root-session" })
|
|
|
const child = await svc.create({ title: "child-session", parentID: root.id })
|
|
|
|
|
|
- const sessions = [...svc.list({ roots: true })]
|
|
|
+ const sessions = await svc.list({ roots: true })
|
|
|
const ids = sessions.map((s) => s.id)
|
|
|
|
|
|
expect(ids).toContain(root.id)
|
|
|
@@ -189,7 +198,7 @@ describe("session.list", () => {
|
|
|
await svc.create({ title: "new-session" })
|
|
|
const futureStart = Date.now() + 86400000
|
|
|
|
|
|
- const sessions = [...svc.list({ start: futureStart })]
|
|
|
+ const sessions = await svc.list({ start: futureStart })
|
|
|
expect(sessions.length).toBe(0)
|
|
|
},
|
|
|
})
|
|
|
@@ -203,7 +212,7 @@ describe("session.list", () => {
|
|
|
await svc.create({ title: "unique-search-term-abc" })
|
|
|
await svc.create({ title: "other-session-xyz" })
|
|
|
|
|
|
- const sessions = [...svc.list({ search: "unique-search" })]
|
|
|
+ const sessions = await svc.list({ search: "unique-search" })
|
|
|
const titles = sessions.map((s) => s.title)
|
|
|
|
|
|
expect(titles).toContain("unique-search-term-abc")
|
|
|
@@ -221,7 +230,7 @@ describe("session.list", () => {
|
|
|
await svc.create({ title: "session-2" })
|
|
|
await svc.create({ title: "session-3" })
|
|
|
|
|
|
- const sessions = [...svc.list({ limit: 2 })]
|
|
|
+ const sessions = await svc.list({ limit: 2 })
|
|
|
expect(sessions.length).toBe(2)
|
|
|
},
|
|
|
})
|