test: fix CI failures in heartbeat and typing tests

This commit is contained in:
Peter Steinberger
2026-02-25 02:28:42 +00:00
parent d42ef2ac62
commit 45b5c35b21
3 changed files with 24 additions and 24 deletions

View File

@@ -123,7 +123,7 @@ describe("typing controller", () => {
] as const;
for (const testCase of cases) {
const onReplyStart = vi.fn(async () => {});
const onReplyStart = vi.fn();
const typing = createTypingController({
onReplyStart,
typingIntervalSeconds: 1,
@@ -133,7 +133,7 @@ describe("typing controller", () => {
await typing.startTypingLoop();
expect(onReplyStart, testCase.name).toHaveBeenCalledTimes(1);
vi.advanceTimersByTime(2_000);
await vi.advanceTimersByTimeAsync(2_000);
expect(onReplyStart, testCase.name).toHaveBeenCalledTimes(3);
if (testCase.first === "run") {
@@ -141,7 +141,7 @@ describe("typing controller", () => {
} else {
typing.markDispatchIdle();
}
vi.advanceTimersByTime(2_000);
await vi.advanceTimersByTimeAsync(2_000);
expect(onReplyStart, testCase.name).toHaveBeenCalledTimes(5);
if (testCase.second === "run") {
@@ -149,14 +149,14 @@ describe("typing controller", () => {
} else {
typing.markDispatchIdle();
}
vi.advanceTimersByTime(2_000);
await vi.advanceTimersByTimeAsync(2_000);
expect(onReplyStart, testCase.name).toHaveBeenCalledTimes(5);
}
});
it("does not start typing after run completion", async () => {
vi.useFakeTimers();
const onReplyStart = vi.fn(async () => {});
const onReplyStart = vi.fn();
const typing = createTypingController({
onReplyStart,
typingIntervalSeconds: 1,
@@ -165,13 +165,13 @@ describe("typing controller", () => {
typing.markRunComplete();
await typing.startTypingOnText("late text");
vi.advanceTimersByTime(2_000);
await vi.advanceTimersByTimeAsync(2_000);
expect(onReplyStart).not.toHaveBeenCalled();
});
it("does not restart typing after it has stopped", async () => {
vi.useFakeTimers();
const onReplyStart = vi.fn(async () => {});
const onReplyStart = vi.fn();
const typing = createTypingController({
onReplyStart,
typingIntervalSeconds: 1,
@@ -184,12 +184,12 @@ describe("typing controller", () => {
typing.markRunComplete();
typing.markDispatchIdle();
vi.advanceTimersByTime(5_000);
await vi.advanceTimersByTimeAsync(5_000);
expect(onReplyStart).toHaveBeenCalledTimes(1);
// Late callbacks should be ignored and must not restart the interval.
await typing.startTypingOnText("late tool result");
vi.advanceTimersByTime(5_000);
await vi.advanceTimersByTimeAsync(5_000);
expect(onReplyStart).toHaveBeenCalledTimes(1);
});
});