Part of the unification order in the UI sweep issue (step c). The four header menus each kept their own open state, dismiss hook and a copy of the popover CSS, and the copies had drifted (offset, padding, fade-in). A shared HeaderMenu now owns the state, the dismiss rules and the popover look; each menu supplies its button and its rows. The settings popover moves 0.15em lower and the settings and alerts popovers gain the fade-in.
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
// The header menus share one popover. Run by `npm test`. Each menu's
|
|
// stylesheet must pull in `HeaderMenu.css` and keep no popover of its own, so
|
|
// a fifth menu can't quietly bring back a copy with its own offset or shadow.
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { test } from "node:test";
|
|
|
|
const read = (rel) => readFileSync(new URL(rel, import.meta.url), "utf8");
|
|
|
|
const MENUS = [
|
|
["links", "../../shared/src/links-menu/LinksMenu.css"],
|
|
["user", "../../shared/src/user-menu/UserMenu.css"],
|
|
["settings", "../../shared/src/settings/SettingsMenu.css"],
|
|
["alerts", "../src/shell/AlertsMenu.css"],
|
|
];
|
|
|
|
for (const [name, file] of MENUS) {
|
|
test(`the ${name} menu uses the shared popover`, () => {
|
|
const css = read(file);
|
|
assert.match(css, /@import "[^"]*header-menu(\/HeaderMenu)?\.css";/);
|
|
assert.ok(!/-popover\s*\{/.test(css), `${name}: has its own popover rule`);
|
|
assert.ok(
|
|
!/position:\s*absolute;[\s\S]*?z-index/.test(
|
|
css.replace(/\.alerts-menu-count \{[\s\S]*?\}/, ""),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
test("the shared popover is the one that floats", () => {
|
|
const css = read("../../shared/src/header-menu/HeaderMenu.css");
|
|
assert.match(css, /\.header-menu-popover \{[^}]*z-index: var\(--z-popover\)/);
|
|
assert.match(css, /box-shadow: var\(--shadow-pop\)/);
|
|
});
|