refactor(webui): centralize notification selection
This commit is contained in:
18
webui/scripts/test-notification-page-structure.mjs
Normal file
18
webui/scripts/test-notification-page-structure.mjs
Normal file
@@ -0,0 +1,18 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const pagePath = fileURLToPath(new URL("../src/features/notifications/NotificationCenterPage.tsx", import.meta.url));
|
||||
const stylesPath = fileURLToPath(new URL("../src/styles/notifications.css", import.meta.url));
|
||||
const page = readFileSync(pagePath, "utf8");
|
||||
const styles = readFileSync(stylesPath, "utf8");
|
||||
|
||||
assert.match(page, /SelectionList,[\s\S]*SelectionListItem,[\s\S]*from "@govoplan\/core-webui"/);
|
||||
assert.match(page, /<SelectionList label="Notifications" className="notifications-selection-list">/);
|
||||
assert.match(page, /<SelectionListItem[\s\S]*selected=\{selected\?\.id === notification\.id\}/);
|
||||
assert.match(page, /className=\{`notifications-list-item \$\{notification\.read_at \? "is-read" : ""\}`\}/);
|
||||
assert.doesNotMatch(page, /<button[\s\S]{0,160}notifications-list-item/);
|
||||
assert.doesNotMatch(styles, /\.notifications-list-item:(?:hover|focus-visible)/);
|
||||
assert.doesNotMatch(styles, /\.notifications-list-item\.is-selected/);
|
||||
|
||||
console.log("Notification rows use the central selection-list contract.");
|
||||
Reference in New Issue
Block a user