mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
Merge branch 'main' into docs/clarify-kilo-install-artifact
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { test, expect } from "bun:test"
|
||||
import { parseShareUrl, transformShareData, type ShareData } from "../../src/cli/cmd/import"
|
||||
import {
|
||||
parseShareUrl,
|
||||
transformShareData,
|
||||
bootstrapImportedSessionIngest,
|
||||
ingestBootstrapWarning,
|
||||
type ShareData,
|
||||
} from "../../src/cli/cmd/import"
|
||||
|
||||
// parseShareUrl tests
|
||||
test("parses valid share URLs", () => {
|
||||
@@ -36,3 +42,41 @@ test("returns null for invalid share data", () => {
|
||||
expect(transformShareData([{ type: "message", data: {} as any }])).toBeNull()
|
||||
expect(transformShareData([{ type: "session", data: { id: "s" } as any }])).toBeNull() // no messages
|
||||
})
|
||||
|
||||
test("formats ingest bootstrap warning", () => {
|
||||
expect(ingestBootstrapWarning("session-123", new Error("network failed"))).toContain("session-123")
|
||||
expect(ingestBootstrapWarning("session-123", new Error("network failed"))).toContain("network failed")
|
||||
expect(ingestBootstrapWarning("session-123", "oops")).toContain("oops")
|
||||
})
|
||||
|
||||
test("bootstrapImportedSessionIngest runs bootstrap and does not warn on success", async () => {
|
||||
const calls: string[] = []
|
||||
const warnings: string[] = []
|
||||
|
||||
await bootstrapImportedSessionIngest("session-success", {
|
||||
bootstrap: async (sessionId) => {
|
||||
calls.push(sessionId)
|
||||
},
|
||||
warn: (message) => warnings.push(message),
|
||||
})
|
||||
|
||||
expect(calls).toEqual(["session-success"])
|
||||
expect(warnings).toHaveLength(0)
|
||||
})
|
||||
|
||||
test("bootstrapImportedSessionIngest warns and continues on failure", async () => {
|
||||
const warnings: string[] = []
|
||||
|
||||
await expect(
|
||||
bootstrapImportedSessionIngest("session-fail", {
|
||||
bootstrap: async () => {
|
||||
throw new Error("boom")
|
||||
},
|
||||
warn: (message) => warnings.push(message),
|
||||
}),
|
||||
).resolves.toBeUndefined()
|
||||
|
||||
expect(warnings).toHaveLength(1)
|
||||
expect(warnings[0]).toContain("session-fail")
|
||||
expect(warnings[0]).toContain("boom")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user