fix(web-app-kix): brand the sign-in title and dock the sidebar

KIX titles its sign-in page with a translated Welcome to KIX, so the design script appended the brand instead of replacing the title, and the palette spec hovered a table cell that the floating sidebar covers between 1141 and 1600 px. design.js.j2 now treats the /auth route as stock and sets the configured title there, and the palette spec runs at a 1680 by 1050 viewport where the sidebar docks. test_design_title.py runs the rendered script in node over sign-in, stock, empty and branded titles.

🎯 Fix: 85 %
💥 Break: 5 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 81
🚦 Gate: ⛔ fix 85 % < 90

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-11-20 23:59:58 +00:00
1 parent 274daa2d23
commit 2a298af605
3 files changed
+81 -2

No files matched your search

@@ -60,6 +60,7 @@ const MENU_ENTRY = `${MENU} ul.main-menu li`;
const MENU_SELECTED = `${MENU} li.active`;
const MOBILE_MENU = ".mobile-main-menu-container";
const LISTED = "/admin?moduleId=ticket-states";
const DOCKED = { width: 1680, height: 1050 };
test.use({ ignoreHTTPSErrors: true });
@@ -244,6 +245,8 @@ exports.register = function (shared) {
test("design: the signed-in interface takes frame, surfaces, dividers and text from the palette", async ({ page }) => {
shared.skipUnlessServiceEnabled("design");
// KIX floats a shown sidebar over the content between 1141 and 1600 px, where it covers the table cell the hover needs.
await page.setViewportSize(DOCKED);
await signIn(page);
for (const mode of MODES) {
await page.emulateMedia({ colorScheme: mode });
+4 -2
View File
@@ -4,12 +4,14 @@
var title = {{ design.title | to_json }};
var tail = " · " + title;
var stock = /^KIX \d+$/;
// KIX titles its sign-in page with a translated "Welcome to KIX", so the route, not the text, marks it as stock.
var signIn = /(^|\/)auth\/?$/.test(location.pathname);
function brand() {
var current = document.title;
if (current === title || current.slice(-tail.length) === tail) {
if (current === title || (!signIn && current.slice(-tail.length) === tail)) {
return;
}
document.title = current === "" || stock.test(current) ? title : current + tail;
document.title = signIn || current === "" || stock.test(current) ? title : current + tail;
}
new MutationObserver(brand).observe(document.head, { childList: true, subtree: true, characterData: true });
brand();
@@ -0,0 +1,74 @@
from __future__ import annotations
import json
import shutil
import subprocess
import unittest
from jinja2 import Environment, select_autoescape
from utils.cache.files import read_text
from . import PROJECT_ROOT
TEMPLATE = PROJECT_ROOT / "roles" / "web-app-kix" / "templates" / "design.js.j2"
TITLE = "Acme Desk"
HARNESS = """
const vm = require("node:vm");
const script = process.argv[1];
const cases = JSON.parse(process.argv[2]);
const titles = cases.map(([pathname, title]) => {
const document = { title, head: {}, addEventListener() {} };
const sandbox = { document, location: { pathname }, MutationObserver: class { observe() {} } };
vm.runInNewContext(script, sandbox);
return document.title;
});
process.stdout.write(JSON.stringify(titles));
"""
CASES = (
("/auth", "Welcome to KIX", TITLE),
("/auth", "Willkommen bei KIX", TITLE),
("/kix/auth", "Welcome to KIX", TITLE),
("/auth", TITLE, TITLE),
("/home", "KIX 18", TITLE),
("/home", "", TITLE),
("/home", "Home", f"Home · {TITLE}"),
("/home", f"Home · {TITLE}", f"Home · {TITLE}"),
("/authors", "Authors", f"Authors · {TITLE}"),
)
def _render() -> str:
environment = Environment(autoescape=select_autoescape(default_for_string=False))
environment.globals["lookup"] = lambda *_: {"title": TITLE}
environment.filters["to_json"] = json.dumps
return environment.from_string(read_text(str(TEMPLATE))).render(
application_id="web-app-kix"
)
@unittest.skipUnless(shutil.which("node"), "node is not available in PATH")
class TestDesignTitle(unittest.TestCase):
def test_every_page_carries_the_configured_title(self) -> None:
proc = subprocess.run(
[
"node",
"-e",
HARNESS,
_render(),
json.dumps([[path, title] for path, title, _ in CASES]),
],
capture_output=True,
text=True,
check=False,
)
self.assertEqual(proc.returncode, 0, proc.stderr)
for (path, title, expected), actual in zip(
CASES, json.loads(proc.stdout), strict=True
):
with self.subTest(path=path, title=title):
self.assertEqual(actual, expected)
if __name__ == "__main__":
unittest.main()