Serve Dock directly and add explicit navigation feedback
This commit is contained in:
1 parent
645afe3ebf
commit
84c4b3030a
77 files changed
+477
-920
No files matched your search
+4
-10
@@ -17,7 +17,7 @@ const frame = (p, theme) =>
|
||||
`${base}/playground/frame.html?concept=dock&page=${p}&theme=${theme}&density=compact`;
|
||||
try {
|
||||
await page.goto(base + "/playground/");
|
||||
await page.frameLocator("#preview-a").locator("h1").waitFor();
|
||||
await page.locator("h1").waitFor();
|
||||
assert.equal(
|
||||
await page
|
||||
.locator("#concepts,#compare,#second,#preview-b,.version")
|
||||
@@ -46,14 +46,8 @@ try {
|
||||
),
|
||||
);
|
||||
await page.reload();
|
||||
await page.frameLocator("#preview-a").locator("#user-search").waitFor();
|
||||
assert.equal(
|
||||
await page
|
||||
.frameLocator("#preview-a")
|
||||
.locator("body")
|
||||
.getAttribute("data-concept"),
|
||||
"dock",
|
||||
);
|
||||
await page.locator("h1").waitFor();
|
||||
assert.equal(await page.locator("body").getAttribute("data-concept"), "dock");
|
||||
passed++;
|
||||
for (const theme of ["light", "dark"]) {
|
||||
for (const [p, selector] of [
|
||||
@@ -151,7 +145,7 @@ try {
|
||||
passed++;
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.goto(base + "/playground/");
|
||||
await page.frameLocator("#preview-a").locator("h1").waitFor();
|
||||
await page.locator("h1").waitFor();
|
||||
assert.ok(
|
||||
await page.evaluate(
|
||||
() => document.documentElement.scrollWidth <= innerWidth,
|
||||
|
||||
+16
-24
@@ -29,7 +29,7 @@ async function check(name, fn) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
await check("HTTP root and gallery", async () => {
|
||||
await check("HTTP root standalone app", async () => {
|
||||
const r = await page.goto(base);
|
||||
assert.equal(r.status(), 200);
|
||||
assert.equal(await page.locator("#concepts, #compare, #second").count(), 0);
|
||||
@@ -39,7 +39,7 @@ try {
|
||||
),
|
||||
false,
|
||||
);
|
||||
await page.frameLocator("#preview-a").locator("h1").waitFor();
|
||||
await page.locator("h1").waitFor();
|
||||
await page.screenshot({ path: "references/gallery.png", fullPage: true });
|
||||
});
|
||||
for (const c of concepts)
|
||||
@@ -240,26 +240,17 @@ try {
|
||||
);
|
||||
}
|
||||
});
|
||||
await check("Approved Dock controls and actual mobile viewport", async () => {
|
||||
await page.goto(base);
|
||||
await page.locator("#theme").selectOption("dark");
|
||||
await page.locator("#density").selectOption("compact");
|
||||
await page.locator("#page").selectOption("users");
|
||||
await page.locator("[data-size=mobile]").click();
|
||||
await page.frameLocator("#preview-a").locator("#user-search").waitFor();
|
||||
assert.equal(
|
||||
await page
|
||||
.frameLocator("#preview-a")
|
||||
.locator("body")
|
||||
.getAttribute("data-concept"),
|
||||
"dock",
|
||||
);
|
||||
await check("Standalone mobile viewport and theme", async () => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.goto(base + "/?page=users&theme=dark");
|
||||
await page.locator("#user-search").waitFor();
|
||||
assert.equal(await page.locator("iframe,#workspace,#page").count(), 0);
|
||||
assert.equal(await page.locator("body").getAttribute("data-theme"), "dark");
|
||||
assert.ok(
|
||||
await page.locator("#preview-a").evaluate((e) => e.clientWidth <= 390),
|
||||
await page.evaluate(
|
||||
() => document.documentElement.scrollWidth <= innerWidth,
|
||||
),
|
||||
);
|
||||
await page.locator("#accent").fill("#ffcc00");
|
||||
await page.locator("#accent").dispatchEvent("change");
|
||||
await page.frameLocator("#preview-a").locator("h1").waitFor();
|
||||
});
|
||||
await check("Mobile navigation and density variants", async () => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
@@ -286,19 +277,20 @@ try {
|
||||
}
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await page.goto(base);
|
||||
await page.frameLocator("#preview-a").locator("h1").waitFor();
|
||||
await page.locator("h1").waitFor();
|
||||
});
|
||||
await check("Export archive download", async () => {
|
||||
await page.goto(base + "/?page=tokens");
|
||||
const download = page.waitForEvent("download");
|
||||
await page.locator("#export").click();
|
||||
await page.locator("[data-action=download-system]").click();
|
||||
const d = await download;
|
||||
await d.saveAs("test-results/anidev-export.zip");
|
||||
assert.match(d.suggestedFilename(), /anidev-dock.zip/);
|
||||
});
|
||||
await check("Gallery mobile overflow", async () => {
|
||||
await check("Standalone mobile overflow", async () => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.goto(base);
|
||||
await page.frameLocator("#preview-a").locator("h1").waitFor();
|
||||
await page.locator("h1").waitFor();
|
||||
assert.ok(
|
||||
await page.evaluate(
|
||||
() => document.documentElement.scrollWidth <= innerWidth + 1,
|
||||
|
||||
+6
-18
@@ -291,40 +291,28 @@ try {
|
||||
await reset();
|
||||
},
|
||||
);
|
||||
await check("Appearance theme and gallery synchronization", async () => {
|
||||
await p.goto(path("appearance"));
|
||||
await check("Standalone appearance persists and exports", async () => {
|
||||
await p.goto(base + "/?page=appearance&theme=light");
|
||||
await p.locator("[data-identity=theme][data-theme=dark]").click();
|
||||
await p.reload();
|
||||
assert.equal(await p.locator("body").getAttribute("data-theme"), "dark");
|
||||
await p.goto(base + "/playground/?concept=dock");
|
||||
await p.locator("#page").selectOption("appearance");
|
||||
await p
|
||||
.frameLocator("#preview-a")
|
||||
.locator("[data-identity=theme][data-theme=dark]")
|
||||
.click();
|
||||
await p.waitForFunction(
|
||||
() => document.querySelector("#theme").value === "dark",
|
||||
);
|
||||
await p
|
||||
.frameLocator("#preview-a")
|
||||
.locator("body[data-theme=dark]")
|
||||
.waitFor();
|
||||
assert.equal(
|
||||
(
|
||||
await p
|
||||
.frameLocator("#preview-a")
|
||||
.locator("html")
|
||||
.evaluate((el) => el.style.getPropertyValue("--color-accent"))
|
||||
).trim(),
|
||||
tokensFor("dock", "dark")["color.accent"],
|
||||
);
|
||||
await p.goto(base + "/?page=tokens&theme=dark");
|
||||
const download = p.waitForEvent("download");
|
||||
await p.locator("#export").click();
|
||||
await p.locator("[data-action=download-system]").click();
|
||||
await (await download).saveAs("test-results/identity-export.zip");
|
||||
});
|
||||
await check(
|
||||
"Identity change across frames clears an open private dialog",
|
||||
async () => {
|
||||
await p.goto(base + "/playground/?concept=dock&page=security");
|
||||
await p.goto(base + "/patterns/IDENTITY.md");
|
||||
await p.setContent(
|
||||
`<iframe id="preview-a" style="width:48%;height:760px" src="${base}/playground/frame.html?concept=dock&page=security"></iframe><iframe id="preview-b" style="width:48%;height:760px" src="${base}/playground/frame.html?concept=dock&page=security"></iframe>`,
|
||||
);
|
||||
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
import { chromium } from "playwright";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
const base = process.env.BASE_URL || "http://127.0.0.1:4173";
|
||||
const b = await chromium.launch({
|
||||
executablePath:
|
||||
process.env.PLAYWRIGHT_EXECUTABLE_PATH ||
|
||||
"C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe",
|
||||
headless: true,
|
||||
});
|
||||
const p = await b.newPage({
|
||||
viewport: { width: 1440, height: 900 },
|
||||
acceptDownloads: true,
|
||||
});
|
||||
const errors = [];
|
||||
p.on("pageerror", (e) => errors.push(e.message));
|
||||
let passed = 0;
|
||||
await mkdir("references/site", { recursive: true });
|
||||
try {
|
||||
for (const theme of ["light", "dark"])
|
||||
for (const [device, width, height] of [
|
||||
["desktop", 1440, 900],
|
||||
["mobile", 390, 844],
|
||||
]) {
|
||||
await p.setViewportSize({ width, height });
|
||||
await p.goto(`${base}/?page=dashboard&theme=${theme}`);
|
||||
await p.locator(".health-line").waitFor();
|
||||
assert.equal(
|
||||
await p
|
||||
.locator(
|
||||
"iframe,.mast,.intro,.toolbar select#page,#preview-a,#workspace",
|
||||
)
|
||||
.count(),
|
||||
0,
|
||||
);
|
||||
assert.equal(
|
||||
await p.locator("body").getAttribute("data-concept"),
|
||||
"dock",
|
||||
);
|
||||
assert.ok(
|
||||
await p.evaluate(
|
||||
() => document.documentElement.scrollWidth <= innerWidth,
|
||||
),
|
||||
);
|
||||
await p.waitForTimeout(400);
|
||||
await p.screenshot({
|
||||
path: `references/site/${theme}-${device}.png`,
|
||||
fullPage: true,
|
||||
});
|
||||
passed++;
|
||||
await p.locator(".dock-brand").click();
|
||||
await p.waitForTimeout(320);
|
||||
for (const target of ["users", "settings", "components", "tokens"]) {
|
||||
const item = p.locator(`.nav-links [data-page=${target}]`);
|
||||
await p.mouse.move(width - 12, height - 12);
|
||||
await item.blur();
|
||||
await p.waitForTimeout(150);
|
||||
const rest = await item.evaluate(
|
||||
(e) => getComputedStyle(e).backgroundColor,
|
||||
);
|
||||
await item.hover();
|
||||
await p.waitForTimeout(160);
|
||||
const hover = await item.evaluate(
|
||||
(e) => getComputedStyle(e).backgroundColor,
|
||||
);
|
||||
assert.notEqual(hover, rest, `${theme}/${device}/${target}`);
|
||||
await item.focus();
|
||||
assert.equal(
|
||||
await item.evaluate((e) => getComputedStyle(e).backgroundColor),
|
||||
hover,
|
||||
);
|
||||
passed++;
|
||||
}
|
||||
await p.screenshot({
|
||||
path: `references/site/navigation-${theme}-${device}.png`,
|
||||
});
|
||||
await p.locator(".nav-links [data-page=users]").click();
|
||||
await p.locator("#user-search").waitFor();
|
||||
assert.equal(new URL(p.url()).searchParams.get("page"), "users");
|
||||
assert.equal(
|
||||
await p
|
||||
.locator(".nav-links [data-page=users]")
|
||||
.getAttribute("aria-current"),
|
||||
"page",
|
||||
);
|
||||
await p.reload();
|
||||
await p.locator("#user-search").waitFor();
|
||||
await p.goBack();
|
||||
await p.locator(".health-line").waitFor();
|
||||
passed++;
|
||||
const before = await p.locator(".main-column").boundingBox();
|
||||
await p.locator(".dock-brand").click();
|
||||
await p.waitForTimeout(280);
|
||||
const after = await p.locator(".main-column").boundingBox();
|
||||
assert.equal(before.x, after.x);
|
||||
assert.equal(before.width, after.width);
|
||||
await p.keyboard.press("Escape");
|
||||
passed++;
|
||||
}
|
||||
await p.goto(base + "/playground/?page=users&theme=dark");
|
||||
await p.locator("#user-search").waitFor();
|
||||
assert.equal(new URL(p.url()).pathname, "/");
|
||||
assert.equal(await p.locator("iframe").count(), 0);
|
||||
passed++;
|
||||
await p.goto(base + "/?page=appearance&theme=light");
|
||||
await p.locator("[data-identity=theme][data-theme=dark]").click();
|
||||
await p.reload();
|
||||
assert.equal(await p.locator("body").getAttribute("data-theme"), "dark");
|
||||
passed++;
|
||||
await p.goto(base + "/?page=tokens");
|
||||
const download = p.waitForEvent("download");
|
||||
await p.locator("[data-action=download-system]").click();
|
||||
await (await download).saveAs("test-results/site-export.zip");
|
||||
passed++;
|
||||
assert.deepEqual(errors, []);
|
||||
await writeFile(
|
||||
"references/site/qa.json",
|
||||
JSON.stringify(
|
||||
{
|
||||
passed,
|
||||
errors,
|
||||
checks:
|
||||
"Root app without wrapper; all navigation hover/focus; routes/reload/back; legacy redirects; theme persistence; no layout jump; export",
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
console.log("Standalone Dock:", passed, "passed");
|
||||
} finally {
|
||||
await b.close();
|
||||
}
|
||||
Reference in new issue
Block a user