{"version":3,"file":"interactive-mode-notification.test.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-mode-notification.test.ts"],"names":[],"mappings":"","sourcesContent":["import { describe, expect, it, vi } from \"vitest\";\nimport { InteractiveMode } from \"./interactive-mode.js\";\n\ntype NotificationHarness = {\n\thandleEvent: (event: { type: string; [key: string]: unknown }) => Promise<void>;\n\tshowStatus: (message: string) => void;\n\tui: { requestRender: () => void };\n\tsessionEpoch: number;\n};\n\ndescribe(\"InteractiveMode notification event handling\", () => {\n\tdescribe(\"operator_discipline_advisory\", () => {\n\t\tit(\"shows advisory as status message when delegation occurs without task/todo state\", async () => {\n\t\t\tconst events: string[] = [];\n\t\t\tconst showStatus = vi.fn((message: string) => {\n\t\t\t\tevents.push(`showStatus:${message}`);\n\t\t\t});\n\t\t\tconst requestRender = vi.fn(() => {\n\t\t\t\tevents.push(\"requestRender\");\n\t\t\t});\n\t\t\tconst footer = { invalidate: vi.fn() };\n\n\t\t\tconst mode = Object.assign(Object.create(InteractiveMode.prototype), {\n\t\t\t\tisInitialized: true,\n\t\t\t\tsessionEpoch: 1,\n\t\t\t\tshowStatus,\n\t\t\t\tui: { requestRender },\n\t\t\t\tfooter,\n\t\t\t\tlastStatusText: undefined,\n\t\t\t\tlastStatusSpacer: undefined,\n\t\t\t\tchatContainer: { children: [] },\n\t\t\t}) as NotificationHarness;\n\n\t\t\t// Simulate the notification event that fires when delegating without task/todo state\n\t\t\tconst notificationEvent = {\n\t\t\t\ttype: \"notification\",\n\t\t\t\tkind: \"operator_discipline_advisory\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"Delegating without visible task or todo state. Consider creating tracking entries before delegating.\",\n\t\t\t};\n\n\t\t\tawait mode.handleEvent(notificationEvent);\n\n\t\t\texpect(showStatus).toHaveBeenCalledTimes(1);\n\t\t\texpect(showStatus).toHaveBeenCalledWith(notificationEvent.message);\n\t\t});\n\n\t\tit(\"does not show status for unknown notification kinds\", async () => {\n\t\t\tconst showStatus = vi.fn();\n\t\t\tconst footer = { invalidate: vi.fn() };\n\n\t\t\tconst mode = Object.assign(Object.create(InteractiveMode.prototype), {\n\t\t\t\tisInitialized: true,\n\t\t\t\tsessionEpoch: 1,\n\t\t\t\tshowStatus,\n\t\t\t\tui: { requestRender: vi.fn() },\n\t\t\t\tfooter,\n\t\t\t}) as NotificationHarness;\n\n\t\t\t// Simulate an unknown notification type\n\t\t\tconst unknownNotificationEvent = {\n\t\t\t\ttype: \"notification\",\n\t\t\t\tkind: \"unknown_advisory_type\",\n\t\t\t\tmessage: \"This is an unknown notification.\",\n\t\t\t};\n\n\t\t\tawait mode.handleEvent(unknownNotificationEvent);\n\n\t\t\texpect(showStatus).not.toHaveBeenCalled();\n\t\t});\n\n\t\tit(\"handles notification event correctly without regression on other event types\", async () => {\n\t\t\tconst showStatus = vi.fn();\n\t\t\tconst requestRender = vi.fn();\n\t\t\tconst updateSidebarTodoPanel = vi.fn();\n\t\t\tconst updateSidebarTaskPanel = vi.fn();\n\t\t\tconst footer = { invalidate: vi.fn() };\n\n\t\t\tconst mode = Object.assign(Object.create(InteractiveMode.prototype), {\n\t\t\t\tisInitialized: true,\n\t\t\t\tsessionEpoch: 1,\n\t\t\t\tshowStatus,\n\t\t\t\tui: { requestRender },\n\t\t\t\tupdateSidebarTodoPanel,\n\t\t\t\tupdateSidebarTaskPanel,\n\t\t\t\tfooter,\n\t\t\t\tlastStatusText: undefined,\n\t\t\t\tlastStatusSpacer: undefined,\n\t\t\t\tchatContainer: { children: [] },\n\t\t\t\tsession: {\n\t\t\t\t\tgetTodos: vi.fn(() => []),\n\t\t\t\t\tgetTasks: vi.fn(() => []),\n\t\t\t\t},\n\t\t\t}) as NotificationHarness;\n\n\t\t\t// Verify task_update still works (different event type)\n\t\t\tconst taskUpdateEvent = {\n\t\t\t\ttype: \"task_update\",\n\t\t\t\ttasks: [{ id: \"1\", content: \"Test task\", status: \"in_progress\" }],\n\t\t\t};\n\n\t\t\tawait mode.handleEvent(taskUpdateEvent);\n\n\t\t\texpect(updateSidebarTodoPanel).toHaveBeenCalled();\n\t\t\texpect(updateSidebarTaskPanel).toHaveBeenCalled();\n\t\t\texpect(showStatus).not.toHaveBeenCalled();\n\t\t});\n\t});\n});\n"]}