update with waitForCondition

This commit is contained in:
uinstinct 2025-12-03 18:21:46 +05:30
parent c1ac9fc845
commit 50f38286c2
2 changed files with 8 additions and 7 deletions

View file

@ -1,5 +1,5 @@
import { renderInMode, testSingleMode } from "./TUIChat.dualModeHelper.js";
import { waitForNextRender } from "./TUIChat.testHelper.js";
import { waitForCondition } from "./TUIChat.testHelper.js";
describe("TUIChat - @ File Search Tests", () => {
testSingleMode("shows @ character when user types @", "local", async () => {
@ -34,11 +34,10 @@ describe("TUIChat - @ File Search Tests", () => {
// Type @ followed by text to filter files
stdin.write("@READ");
// Wait for file search to filter and display results
await new Promise((resolve) => setTimeout(resolve, 500));
const frame = lastFrame()!;
waitForCondition(() => lastFrame()!.includes("@READ"));
// Should show the typed text
expect(frame).toContain("@READ");
@ -58,10 +57,11 @@ describe("TUIChat - @ File Search Tests", () => {
// Type multiple @ characters
stdin.write("@@test");
// Wait for UI update
await waitForNextRender();
const frame = lastFrame();
await waitForCondition(() => lastFrame()?.includes("@@test") ?? false);
// Should handle multiple @ without crashing
expect(frame).toBeDefined();
expect(frame).toContain("@@test");

View file

@ -1,5 +1,5 @@
import { renderInMode, testBothModes } from "./TUIChat.dualModeHelper.js";
import { waitForNextRender } from "./TUIChat.testHelper.js";
import { waitForCondition, waitForNextRender } from "./TUIChat.testHelper.js";
describe("TUIChat - Slash Commands Tests", () => {
testBothModes("shows slash when user types /", async (mode) => {
@ -28,10 +28,11 @@ describe("TUIChat - Slash Commands Tests", () => {
// Type /exi to trigger slash command filtering
stdin.write("/exi");
await waitForNextRender();
const frame = lastFrame();
waitForCondition(() => lastFrame()?.includes("/exi") ?? false);
// Should show the typed command
expect(frame).toContain("/exi");