web: integrate QoL slices 1-5 (model switch/rename, history deletes, usage stats, repo prepare+badges+imageUsed, markdown/search/FAB/timestamps) — 263 tests, ≥95% all metrics

This commit is contained in:
Raphael Westphal
2026-08-19 10:35:40 +02:00
parent 698b742cb3
commit c8ad68aaea
17 changed files with 2618 additions and 170 deletions
+20 -1
View File
@@ -1,7 +1,13 @@
import { act, renderHook, waitFor } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { getSettings, saveSettings } from "./settings";
import { classNames, relativeTime, useSessions, useToasts } from "./store";
import {
classNames,
formatTokens,
relativeTime,
useSessions,
useToasts,
} from "./store";
import {
FakeWebSocket,
jsonResponse,
@@ -39,6 +45,19 @@ describe("classNames", () => {
});
});
describe("formatTokens", () => {
it("compacts with one decimal under 100, no decimal above", () => {
expect(formatTokens(0)).toBe("0");
expect(formatTokens(999)).toBe("999");
expect(formatTokens(1000)).toBe("1K");
expect(formatTokens(1234)).toBe("1.2K");
expect(formatTokens(340000)).toBe("340K");
expect(formatTokens(1250000)).toBe("1.3M");
expect(formatTokens(1200000)).toBe("1.2M");
expect(formatTokens(2500000000)).toBe("2.5B");
});
});
describe("useToasts", () => {
beforeEach(() => {
vi.useFakeTimers();