Files
NetMesh/components/TrayPanel.closeSession.test.ts

26 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
const source = readFileSync(new URL("./TrayPanel.tsx", import.meta.url), "utf8");
test("tray panel does not paint a CSS drop shadow on the host card", () => {
// BrowserWindow already has hasShadow. CSS shadow-lg on a transparent
// macOS overlay double-composites as an extra outline under the card.
const rootOpenTag = source.match(/<div id="tray-panel-root"[^>]*>/);
assert.ok(rootOpenTag, "expected tray-panel-root");
assert.doesNotMatch(rootOpenTag[0], /shadow-lg|shadow-md|shadow-xl/);
});
test("tray session close actions are discoverable without mouse hover", () => {
const keyboardVisible = source.match(/focus-visible:opacity-100/g) ?? [];
const touchVisible = source.match(/\[@media\(hover:none\)\]:opacity-100/g) ?? [];
const centeredActions = source.match(/inline-flex items-center justify-center opacity-0/g) ?? [];
const labelledActions = source.match(/aria-label=\{t\("tray\.closeSession"\)\}/g) ?? [];
assert.equal(keyboardVisible.length, 2);
assert.equal(touchVisible.length, 2);
assert.equal(centeredActions.length, 2);
assert.equal(labelledActions.length, 2);
});