test(coding-agent): updated job poll displacement tests to use TranscriptContainer

- Replaced manual Container stubs with TranscriptContainer instances in test fixtures.
- Updated test context initialization to utilize the actual container implementation for chat message tracking.
This commit is contained in:
can1357
2026-07-04 14:48:41 +02:00
parent 78126d925c
commit 38565c58cb
@@ -14,12 +14,13 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "bun:
import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
import { resetSettingsForTest, Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
import { ToolExecutionComponent } from "@oh-my-pi/pi-coding-agent/modes/components/tool-execution";
import { TranscriptContainer } from "@oh-my-pi/pi-coding-agent/modes/components/transcript-container";
import { EventController } from "@oh-my-pi/pi-coding-agent/modes/controllers/event-controller";
import { initTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types";
import { UiHelpers } from "@oh-my-pi/pi-coding-agent/modes/utils/ui-helpers";
import type { SessionContext } from "@oh-my-pi/pi-coding-agent/session/session-context";
import { type Component, Container, type TUI } from "@oh-my-pi/pi-tui";
import type { Component, TUI } from "@oh-my-pi/pi-tui";
const uiStub = { requestRender() {} } as unknown as TUI;
@@ -158,7 +159,8 @@ describe("EventController displaces consecutive waiting polls", () => {
});
function createFixture() {
const children: Component[] = [];
const chatContainer = new TranscriptContainer();
const children = chatContainer.children;
const pendingTools = new Map();
const ctx = {
isInitialized: true,
@@ -168,16 +170,7 @@ describe("EventController displaces consecutive waiting polls", () => {
updateEditorTopBorder: vi.fn(),
toolOutputExpanded: false,
pendingTools,
chatContainer: {
children,
addChild: (component: Component) => {
children.push(component);
},
removeChild: (component: Component) => {
const index = children.indexOf(component);
if (index !== -1) children.splice(index, 1);
},
},
chatContainer,
session: { getToolByName: () => undefined },
showWarning: vi.fn(),
viewSession: { getToolByName: () => undefined },
@@ -412,7 +405,7 @@ describe("UiHelpers.renderSessionContext collapses repeated todo snapshots", ()
});
it("removes the earlier todo snapshot when an assistant message replays two todo calls", () => {
const chatContainer = new Container();
const chatContainer = new TranscriptContainer();
let helpers!: UiHelpers;
const ctx = {
chatContainer,
@@ -487,7 +480,7 @@ describe("UiHelpers.renderSessionContext collapses repeated todo snapshots", ()
});
it("hands the trailing todo snapshot to the controller during mid-turn rebuild", () => {
const chatContainer = new Container();
const chatContainer = new TranscriptContainer();
const inheritDisplaceableTodo = vi.fn();
let helpers!: UiHelpers;
const ctx = {