Files
co-lite/solvway-admin-portal/app/components/ui/table.scrollcue.test.tsx
T

33 lines
1.5 KiB
TypeScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
// refine-visitor-pages-and-shell: wide tables show a visible fade on an edge that can still scroll.
// The old 10px shadow at 12% was too faint to notice at 360px.
describe("table scroll cue", () => {
const css = readFileSync(join(__dirname, "../../globals.css"), "utf8");
const rule = css.match(/\[data-slot="table-container"\]\s*\{([\s\S]*?)\n\}/)?.[1] ?? "";
it("uses local covers over scroll shadows", () => {
expect(rule.match(/ local/g)).toHaveLength(2);
expect(rule.match(/ scroll/g)).toHaveLength(2);
});
it("draws a shadow wide and strong enough to see, from theme tokens only", () => {
const shadow = [...rule.matchAll(/var\(--foreground\) (\d+)%[^/]*\/ (\d+)px/g)];
expect(shadow).toHaveLength(2);
for (const [, pct, px] of shadow) {
expect(Number(pct)).toBeGreaterThanOrEqual(18);
expect(Number(px)).toBeGreaterThanOrEqual(16);
}
expect(rule).not.toMatch(/#[0-9a-f]{3,8}\b|rgb\(|hsl\(/i);
});
it("makes each cover wider than its shadow, so the fade is gone at that end", () => {
const covers = [...rule.matchAll(/var\(--card\)[^/]*\/ (\d+)px/g)].map((m) => Number(m[1]));
const shadows = [...rule.matchAll(/var\(--foreground\)[^/]*\/ (\d+)px/g)].map((m) => Number(m[1]));
expect(covers).toHaveLength(2);
expect(Math.min(...covers)).toBeGreaterThan(Math.max(...shadows));
});
});