Files
Netcatty/components/ui/toast.test.ts
T
3c67392455 fix(ui): keep New Host menu icons from shrinking and fix toast contrast when app/system themes differ (#3795)
* fix(vault): keep the New Host local shell icon at 14px

The dropdown was a fixed w-44 flex row. "Local Shell (CMD)" is wider than
the sibling labels, so the icon SVG flex-shrunk below size 14 (and longer
shell names collapsed it entirely). Pin every menu icon with shrink-0 and
let the menu grow with the label.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>

* fix(ui): keep toast text on the app theme surface

Palette fills used a prefers-color-scheme dark variant, so an app-dark session with a light OS left light text on a pale background.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
2026-10-20 18:14:11 +08:00

25 lines
1.1 KiB
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
const toastSource = readFileSync(new URL("./toast.tsx", import.meta.url), "utf8");
test("toast surfaces follow app theme tokens instead of OS palette fills", () => {
const styles = toastSource.slice(
toastSource.indexOf("const TOAST_STYLES"),
toastSource.indexOf("export const ToastProvider"),
);
assert.match(styles, /success: 'border-emerald-600'/);
assert.match(styles, /error: 'border-red-600'/);
assert.match(styles, /warning: 'border-yellow-600'/);
assert.match(styles, /info: 'border-blue-600'/);
// `dark:` is prefers-color-scheme, so these fills stay pale while
// text-foreground / text-muted-foreground follow the `.dark` class.
assert.doesNotMatch(styles, /bg-(?:emerald|red|yellow|blue)-50/);
assert.doesNotMatch(styles, /dark:bg-(?:emerald|red|yellow|blue)-950/);
assert.match(toastSource, /"bg-card animate-in/);
assert.match(toastSource, /text-sm font-medium text-foreground/);
assert.match(toastSource, /text-sm text-muted-foreground break-words/);
});