import { describe, expect, it } from "bun:test"; import { shouldGenerateSessionTitle } from "../../src/routes/chatSession.js"; describe("shouldGenerateSessionTitle", () => { it("allows auto-title generation for the first turn when the title was not edited", () => { expect( shouldGenerateSessionTitle({ recentTurnCount: 0, isTitleManuallyEdited: false, }), ).toBe(true); }); it("blocks auto-title generation after the user edits the title manually", () => { expect( shouldGenerateSessionTitle({ recentTurnCount: 0, isTitleManuallyEdited: true, }), ).toBe(false); }); it("only allows auto-title generation during the first two turns", () => { expect( shouldGenerateSessionTitle({ recentTurnCount: 1, isTitleManuallyEdited: false, }), ).toBe(true); expect( shouldGenerateSessionTitle({ recentTurnCount: 2, isTitleManuallyEdited: false, }), ).toBe(false); }); });