From 3909e83137d4ece463530828a178ab89db7e1728 Mon Sep 17 00:00:00 2001 From: can1357 Date: Mon, 8 Jun 2026 02:55:44 +0200 Subject: [PATCH] test(coding-agent): mocked settings init for ascii bar tests - Stubbed `isSettingsInitialized` to false so crest timing stays deterministic. - Replaced magic timestamp with named `CLASSIC_CREST_VISIBLE_MS` constant. --- .../coding-agent/test/slash-command-format.test.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/coding-agent/test/slash-command-format.test.ts b/packages/coding-agent/test/slash-command-format.test.ts index 807037233..0d6ca2f7a 100644 --- a/packages/coding-agent/test/slash-command-format.test.ts +++ b/packages/coding-agent/test/slash-command-format.test.ts @@ -1,4 +1,5 @@ -import { afterEach, describe, expect, it, vi } from "bun:test"; +import { afterEach, beforeEach, describe, expect, it, vi } from "bun:test"; +import * as settingsModule from "../src/config/settings"; import type { Theme } from "../src/modes/theme/theme"; import { renderAsciiBar } from "../src/slash-commands/helpers/format"; @@ -24,13 +25,20 @@ const testTheme = { }, }; +// 30 cells/s with classic padding 10 positions the crest on the first cell. +const CLASSIC_CREST_VISIBLE_MS = 333; + describe("renderAsciiBar", () => { + beforeEach(() => { + vi.spyOn(settingsModule, "isSettingsInitialized").mockReturnValue(false); + }); + afterEach(() => { vi.restoreAllMocks(); }); it("preserves the visible progress-bar contract", () => { - vi.spyOn(Date, "now").mockReturnValue(834); + vi.spyOn(Date, "now").mockReturnValue(CLASSIC_CREST_VISIBLE_MS); const rendered = renderAsciiBar(0.5, 4, testTheme); @@ -38,7 +46,7 @@ describe("renderAsciiBar", () => { }); it("colors the shimmer band with the theme accent", () => { - vi.spyOn(Date, "now").mockReturnValue(834); + vi.spyOn(Date, "now").mockReturnValue(CLASSIC_CREST_VISIBLE_MS); const rendered = renderAsciiBar(undefined, 4, testTheme);