test(web): remove tests for unreachable helpers (#8738)

Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
This commit is contained in:
t3-code[bot] authored and GitHub committed 2026-08-30 05:31:02 +00:00
1 parent 8dcb96314c
commit 2daff8c25a
13 files changed
+3 -282

No files matched your search

-15
View File
@@ -5,9 +5,6 @@ import {
clampCodeFontSize,
clampInterfaceFontSize,
clampPromptFontSize,
DEFAULT_CODE_FONT_STACK,
DEFAULT_SANS_FONT_STACK,
appearanceFontStack,
cssFontFamilies,
resolveDefaultFamilyLabel,
resolveTerminalFontPreference,
@@ -58,18 +55,6 @@ describe("resolveDefaultFamilyLabel", () => {
});
});
describe("appearanceFontStack", () => {
it("prepends the custom family to the default stack", () => {
expect(appearanceFontStack("Fira Code", DEFAULT_CODE_FONT_STACK)).toBe(
`"Fira Code", ${DEFAULT_CODE_FONT_STACK}`,
);
});
it("falls back to the default stack when unset", () => {
expect(appearanceFontStack("", DEFAULT_SANS_FONT_STACK)).toBe(DEFAULT_SANS_FONT_STACK);
});
});
describe("resolveTerminalFontPreference", () => {
it("inherits the code font in simple mode", () => {
expect(
-6
View File
@@ -71,12 +71,6 @@ export function cssFontFamilies(input: string): string | null {
return families.length > 0 ? families.join(", ") : null;
}
/** The full stack a preference resolves to: custom families before the default. */
export function appearanceFontStack(custom: string, defaultStack: string): string {
const families = cssFontFamilies(custom);
return families === null ? defaultStack : `${families}, ${defaultStack}`;
}
export interface AppearanceFontPreferences {
readonly sans: string;
readonly code: string;
@@ -20,7 +20,6 @@ import {
isTrailingDoubleClick,
orderItemsByPreferredIds,
resolveProjectStatusIndicator,
resolveSidebarStageBadgeLabel,
resolveThreadRowClassName,
resolveSidebarThreadStatus,
resolveThreadStatusPill,
@@ -236,44 +235,6 @@ describe("buildMultiSelectThreadContextMenuItems", () => {
});
});
describe("resolveSidebarStageBadgeLabel", () => {
it("returns Nightly for nightly primary server versions", () => {
expect(
resolveSidebarStageBadgeLabel({
primaryServerVersion: "0.0.28-nightly.20260616.12",
fallbackStageLabel: "Alpha",
}),
).toBe("Nightly");
});
it("returns the fallback label for stable primary server versions", () => {
expect(
resolveSidebarStageBadgeLabel({
primaryServerVersion: "0.0.27",
fallbackStageLabel: "Alpha",
}),
).toBe("Alpha");
});
it("returns the fallback label when the primary server version is missing", () => {
expect(
resolveSidebarStageBadgeLabel({
primaryServerVersion: null,
fallbackStageLabel: "Dev",
}),
).toBe("Dev");
});
it("returns the fallback label for malformed nightly prerelease versions", () => {
expect(
resolveSidebarStageBadgeLabel({
primaryServerVersion: "0.0.28-nightly.20260616",
fallbackStageLabel: "Alpha",
}),
).toBe("Alpha");
});
});
function makeLatestTurn(overrides?: {
completedAt?: string | null;
startedAt?: string | null;
-8
View File
@@ -13,7 +13,6 @@ import type { SidebarThreadSummary, Thread } from "../types";
import type { ThreadRouteTarget } from "../threadRoutes";
import { cn } from "../lib/utils";
import { isLatestTurnSettled } from "../session-logic";
import { resolveServerBackedAppStageLabel } from "../branding.logic";
export const THREAD_SELECTION_SAFE_SELECTOR = "[data-thread-item], [data-thread-selection-safe]";
export const THREAD_JUMP_HINT_SHOW_DELAY_MS = 200;
@@ -170,13 +169,6 @@ export interface ThreadJumpHintVisibilityController {
dispose: () => void;
}
export function resolveSidebarStageBadgeLabel(input: {
primaryServerVersion: string | null | undefined;
fallbackStageLabel: string;
}): string {
return resolveServerBackedAppStageLabel(input);
}
export function createThreadJumpHintVisibilityController(input: {
delayMs: number;
onVisibilityChange: (visible: boolean) => void;
-24
View File
@@ -4,7 +4,6 @@ import {
buildPendingUserInputAnswers,
countAnsweredPendingUserInputQuestions,
derivePendingUserInputProgress,
findFirstUnansweredPendingUserInputQuestionIndex,
resolvePendingUserInputAnswer,
setPendingUserInputCustomAnswer,
togglePendingUserInputOptionSelection,
@@ -182,29 +181,6 @@ describe("pending user input question progress", () => {
).toBe(1);
});
it("finds the first unanswered question", () => {
expect(
findFirstUnansweredPendingUserInputQuestionIndex(questions, {
scope: {
selectedOptionLabels: ["Orchestration-first"],
},
}),
).toBe(1);
});
it("returns the last question index when all answers are complete", () => {
expect(
findFirstUnansweredPendingUserInputQuestionIndex(questions, {
scope: {
selectedOptionLabels: ["Orchestration-first"],
},
compat: {
customAnswer: "Keep it for one release window",
},
}),
).toBe(1);
});
it("derives the active question and advancement state", () => {
expect(
derivePendingUserInputProgress(
-11
View File
@@ -128,17 +128,6 @@ export function countAnsweredPendingUserInputQuestions(
}, 0);
}
export function findFirstUnansweredPendingUserInputQuestionIndex(
questions: ReadonlyArray<UserInputQuestion>,
draftAnswers: Record<string, PendingUserInputDraftAnswer>,
): number {
const unansweredIndex = questions.findIndex(
(question) => !resolvePendingUserInputAnswer(question, draftAnswers[question.id]),
);
return unansweredIndex === -1 ? Math.max(questions.length - 1, 0) : unansweredIndex;
}
export function derivePendingUserInputProgress(
questions: ReadonlyArray<UserInputQuestion>,
draftAnswers: Record<string, PendingUserInputDraftAnswer>,
@@ -1,23 +0,0 @@
import { beforeEach, describe, expect, it } from "vite-plus/test";
import { removeLocalStorageItem } from "./hooks/useLocalStorage";
import {
dismissProviderUpdateNotification,
isProviderUpdateNotificationDismissed,
PROVIDER_UPDATE_DISMISSALS_STORAGE_KEY,
} from "./providerUpdateDismissal";
describe("providerUpdateDismissal", () => {
beforeEach(() => {
removeLocalStorageItem(PROVIDER_UPDATE_DISMISSALS_STORAGE_KEY);
});
it("persists provider update dismissals by notification key", () => {
expect(isProviderUpdateNotificationDismissed("opencode:1.14.33")).toBe(false);
dismissProviderUpdateNotification("opencode:1.14.33");
expect(isProviderUpdateNotificationDismissed("opencode:1.14.33")).toBe(true);
expect(isProviderUpdateNotificationDismissed("opencode:1.14.34")).toBe(false);
});
});
+2 -55
View File
@@ -1,67 +1,14 @@
import { useCallback, useMemo } from "react";
import * as Schema from "effect/Schema";
import { getLocalStorageItem, setLocalStorageItem, useLocalStorage } from "./hooks/useLocalStorage";
import { useLocalStorage } from "./hooks/useLocalStorage";
export const PROVIDER_UPDATE_DISMISSALS_STORAGE_KEY = "t3code:provider-update-dismissals:v1";
const PROVIDER_UPDATE_DISMISSALS_STORAGE_KEY = "t3code:provider-update-dismissals:v1";
const ProviderUpdateDismissalsSchema = Schema.Struct({
keys: Schema.Array(Schema.String),
});
type ProviderUpdateDismissals = typeof ProviderUpdateDismissalsSchema.Type;
function readProviderUpdateDismissals(): ProviderUpdateDismissals {
try {
return (
getLocalStorageItem(
PROVIDER_UPDATE_DISMISSALS_STORAGE_KEY,
ProviderUpdateDismissalsSchema,
) ?? {
keys: [],
}
);
} catch (error) {
console.error("Could not read provider-update dismissals.", error);
return { keys: [] };
}
}
function writeProviderUpdateDismissals(document: ProviderUpdateDismissals): void {
try {
setLocalStorageItem(
PROVIDER_UPDATE_DISMISSALS_STORAGE_KEY,
document,
ProviderUpdateDismissalsSchema,
);
} catch (error) {
console.error("Could not persist provider-update dismissals.", error);
}
}
export function isProviderUpdateNotificationDismissed(
dismissalKey: string | null | undefined,
): boolean {
if (!dismissalKey) {
return false;
}
return readProviderUpdateDismissals().keys.includes(dismissalKey);
}
export function dismissProviderUpdateNotification(dismissalKey: string | null | undefined): void {
const trimmedKey = dismissalKey?.trim();
if (!trimmedKey) {
return;
}
const document = readProviderUpdateDismissals();
if (document.keys.includes(trimmedKey)) {
return;
}
writeProviderUpdateDismissals({
keys: [...document.keys, trimmedKey],
});
}
export function useDismissedProviderUpdateNotificationKeys() {
const [dismissals, setDismissals] = useLocalStorage(
PROVIDER_UPDATE_DISMISSALS_STORAGE_KEY,
+1 -8
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vite-plus/test";
import { resolveThreadSyncPhase, threadSyncLabel } from "./threadSync";
import { resolveThreadSyncPhase } from "./threadSync";
describe("resolveThreadSyncPhase", () => {
it("loads when only shell data is available", () => {
@@ -40,10 +40,3 @@ describe("resolveThreadSyncPhase", () => {
).toBeNull();
});
});
describe("threadSyncLabel", () => {
it("uses the same loading and syncing language as mobile", () => {
expect(threadSyncLabel("loading")).toBe("Loading messages...");
expect(threadSyncLabel("syncing")).toBe("Syncing messages...");
});
});
-39
View File
@@ -6,10 +6,7 @@ import {
formatExpiresInLabel,
formatRelativeTime,
formatRelativeTimeLabel,
formatRelativeTimeUntil,
formatRelativeTimeUntilLabel,
formatShortTimestamp,
formatTimestamp,
getRelativeTimeState,
getTimestampFormatOptions,
resolveTimestampLocale,
@@ -76,33 +73,6 @@ describe("resolveTimestampLocale", () => {
});
});
describe("formatRelativeTimeUntilLabel", () => {
beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date("2026-04-07T12:00:00.000Z"));
});
afterEach(() => {
vi.useRealTimers();
});
it("returns Expired when the instant is in the past", () => {
expect(formatRelativeTimeUntilLabel("2026-04-07T11:59:00.000Z")).toBe("Expired");
});
it("formats seconds remaining", () => {
expect(formatRelativeTimeUntilLabel("2026-04-07T12:00:45.000Z")).toBe("45s left");
});
it("formats minutes remaining", () => {
expect(formatRelativeTimeUntilLabel("2026-04-07T12:15:00.000Z")).toBe("15m left");
});
it("formats hours remaining", () => {
expect(formatRelativeTimeUntilLabel("2026-04-07T18:00:00.000Z")).toBe("6h left");
});
});
describe("formatExpiresInLabel", () => {
beforeEach(() => {
vi.useFakeTimers();
@@ -196,10 +166,6 @@ describe("formatDayAwareTimestamp", () => {
});
describe("invalid timestamp inputs", () => {
it("returns an empty timestamp instead of throwing", () => {
expect(formatTimestamp("not-a-date", "12-hour")).toBe("");
});
it("returns an empty short timestamp instead of throwing", () => {
expect(formatShortTimestamp("not-a-date", "12-hour")).toBe("");
});
@@ -218,11 +184,6 @@ describe("invalid timestamp inputs", () => {
expect(formatElapsedDurationLabel("not-a-date")).toBe("");
});
it("returns an empty relative time until label instead of a NaN label", () => {
expect(formatRelativeTimeUntil("not-a-date")).toBeNull();
expect(formatRelativeTimeUntilLabel("not-a-date")).toBe("");
});
it("returns an empty expires-in label instead of a NaN label", () => {
expect(formatExpiresInLabel("not-a-date")).toBe("");
});
-31
View File
@@ -78,12 +78,6 @@ export function parseTimestampDate(isoDate: string): Date | null {
return Number.isNaN(date.getTime()) ? null : date;
}
export function formatTimestamp(isoDate: string, timestampFormat: TimestampFormat): string {
const date = parseTimestampDate(isoDate);
if (!date) return "";
return getTimestampFormatter(timestampFormat, true).format(date);
}
// Deliberately not the host locale: the tooltip's ordinal suffix and
// day-before-month order below are English, so a localized month alone would
// read "4th Juni 2026". Localizing the whole label is a separate change.
@@ -228,31 +222,6 @@ export function formatElapsedDurationLabel(isoDate: string, nowMs: number = Date
return `${days}d`;
}
/**
* Relative time until an ISO instant (e.g. expiry). Mirrors {@link formatRelativeTime} but for future times.
*/
export function formatRelativeTimeUntil(isoDate: string): RelativeTimeParts | null {
const date = parseTimestampDate(isoDate);
if (!date) return null;
const diffMs = date.getTime() - Date.now();
if (diffMs <= 0) return { value: "Expired", suffix: null };
const seconds = Math.floor(diffMs / 1000);
if (seconds < 5) return { value: "Soon", suffix: null };
if (seconds < 60) return { value: `${seconds}s`, suffix: "left" };
const minutes = Math.floor(seconds / 60);
if (minutes < 60) return { value: `${minutes}m`, suffix: "left" };
const hours = Math.floor(minutes / 60);
if (hours < 24) return { value: `${hours}h`, suffix: "left" };
const days = Math.floor(hours / 24);
return { value: `${days}d`, suffix: "left" };
}
export function formatRelativeTimeUntilLabel(isoDate: string): string {
const relative = formatRelativeTimeUntil(isoDate);
if (!relative) return "";
return relative.suffix ? `${relative.value} ${relative.suffix}` : relative.value;
}
/**
* Countdown for a future instant (e.g. link expiry): "Expires in 4m 12s", with second precision under one hour.
* Pass `nowMs` when a parent tick drives re-renders so the diff matches that snapshot.
-9
View File
@@ -8,7 +8,6 @@ vi.mock("./branding", () => branding);
import { APP_VERSION } from "./branding";
import {
appendVersionMismatchHint,
buildVersionMismatchDismissalKey,
dismissVersionMismatch,
isVersionMismatchDismissed,
@@ -139,14 +138,6 @@ describe("versionSkew", () => {
).toBe(false);
});
it("appends a hint to connection errors when the server is behind", () => {
const mismatch = resolveVersionMismatch("0.0.33");
expect(appendVersionMismatchHint("Socket closed.", mismatch)).toBe(
`Socket closed. Hint: ${MISMATCH_HINT}`,
);
});
it("reads desktop-managed update capabilities from config descriptors", () => {
expect(
resolveServerSelfUpdateCapability({
-14
View File
@@ -159,17 +159,3 @@ export function dismissVersionMismatch(dismissalKey: string | null | undefined):
keys: [...document.keys, dismissalKey],
});
}
export function appendVersionMismatchHint(
message: string | null | undefined,
mismatch: VersionMismatch | null | undefined,
): string | null {
const normalizedMessage = normalizeVersion(message);
if (!normalizedMessage) {
return mismatch?.hint ?? null;
}
if (!mismatch) {
return normalizedMessage;
}
return `${normalizedMessage} Hint: ${mismatch.hint}`;
}