2026-01-10 21:44:20 +00:00
|
|
|
import { describe, expect, test } from "bun:test"
|
|
|
|
|
import { createFirstMessageVariantGate } from "./first-message-variant"
|
|
|
|
|
|
|
|
|
|
describe("createFirstMessageVariantGate", () => {
|
|
|
|
|
test("marks new sessions and clears after apply", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given
|
2026-01-10 21:44:20 +00:00
|
|
|
const gate = createFirstMessageVariantGate()
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when
|
2026-01-10 21:44:20 +00:00
|
|
|
gate.markSessionCreated({ id: "session-1" })
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then
|
2026-01-10 21:44:20 +00:00
|
|
|
expect(gate.shouldOverride("session-1")).toBe(true)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when
|
2026-01-10 21:44:20 +00:00
|
|
|
gate.markApplied("session-1")
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then
|
2026-01-10 21:44:20 +00:00
|
|
|
expect(gate.shouldOverride("session-1")).toBe(false)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("ignores forked sessions", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given
|
2026-01-10 21:44:20 +00:00
|
|
|
const gate = createFirstMessageVariantGate()
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when
|
2026-01-10 21:44:20 +00:00
|
|
|
gate.markSessionCreated({ id: "session-2", parentID: "session-parent" })
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then
|
2026-01-10 21:44:20 +00:00
|
|
|
expect(gate.shouldOverride("session-2")).toBe(false)
|
|
|
|
|
})
|
|
|
|
|
})
|