Polish toasts and add searchable select and copy input
This commit is contained in:
1 parent
36f526aa02
commit
8e4e8e6ef0
28 files changed
+671
-17
No files matched your search
@@ -0,0 +1,108 @@
|
||||
import { chromium } from "playwright";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
|
||||
const browser = await chromium.launch({
|
||||
executablePath:
|
||||
process.env.PLAYWRIGHT_EXECUTABLE_PATH ||
|
||||
"C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe",
|
||||
headless: true,
|
||||
});
|
||||
const page = await browser.newPage({
|
||||
permissions: ["clipboard-read", "clipboard-write"],
|
||||
});
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
const base = process.env.BASE_URL || "http://127.0.0.1:4173";
|
||||
await mkdir("references/search-select", { recursive: true });
|
||||
let passed = 0;
|
||||
try {
|
||||
for (const theme of ["dark", "light"])
|
||||
for (const width of [1440, 768, 390]) {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await page.goto(`${base}/?page=components&theme=${theme}&locale=ru`);
|
||||
const root = page.locator("#environment-search");
|
||||
const trigger = root.locator(".search-select-trigger");
|
||||
const popup = root.locator("[data-search-popup]");
|
||||
const search = popup.locator("input");
|
||||
await trigger.click();
|
||||
await search.fill("staging");
|
||||
assert.equal(await popup.locator("[role=option]").count(), 3);
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await page.keyboard.press("Enter");
|
||||
assert.equal(
|
||||
await root.locator("input[type=hidden]").inputValue(),
|
||||
"staging-eu",
|
||||
);
|
||||
assert.equal(
|
||||
await trigger.evaluate((e) => e === document.activeElement),
|
||||
true,
|
||||
);
|
||||
await trigger.click();
|
||||
await search.fill("unfindable");
|
||||
assert.equal(
|
||||
await popup.locator(".search-select-empty").isVisible(),
|
||||
true,
|
||||
);
|
||||
await page.keyboard.press("Enter");
|
||||
assert.equal(await popup.isVisible(), true);
|
||||
await page.keyboard.press("Escape");
|
||||
assert.equal(await trigger.getAttribute("aria-expanded"), "false");
|
||||
await trigger.press("End");
|
||||
const activeId = await search.getAttribute("aria-activedescendant");
|
||||
assert.equal(
|
||||
await page.locator(`#${activeId}`).innerText(),
|
||||
"Quality assurance",
|
||||
);
|
||||
await page.keyboard.press("Escape");
|
||||
await trigger.click();
|
||||
await page.waitForTimeout(180);
|
||||
const rect = await popup.boundingBox();
|
||||
assert.ok(rect.x >= 0 && rect.x + rect.width <= width + 1);
|
||||
assert.ok(rect.y >= 0 && rect.y + rect.height <= 901);
|
||||
await popup.screenshot({
|
||||
path: `references/search-select/${theme}-${width}.png`,
|
||||
});
|
||||
await trigger.click();
|
||||
assert.equal(await popup.isVisible(), false);
|
||||
await trigger.click();
|
||||
await page.keyboard.press("Tab");
|
||||
assert.equal(await popup.isVisible(), false);
|
||||
const copyInput = page.locator("#copy-input-example");
|
||||
await copyInput.fill("current-value-✓");
|
||||
const copyButton = page.locator("[data-copy-input]");
|
||||
await copyButton.click();
|
||||
assert.equal(
|
||||
await page.evaluate(() => navigator.clipboard.readText()),
|
||||
"current-value-✓",
|
||||
);
|
||||
assert.equal(
|
||||
await page.locator("#toast").getAttribute("data-type"),
|
||||
"success",
|
||||
);
|
||||
await page.locator("[data-toast-dismiss]").click();
|
||||
await page
|
||||
.locator(".copy-field-example")
|
||||
.screenshot({
|
||||
path: `references/search-select/copy-${theme}-${width}.png`,
|
||||
});
|
||||
await trigger.click();
|
||||
await page.keyboard.press("Control+k");
|
||||
await page.locator("dialog[open]").waitFor();
|
||||
assert.equal(await popup.isVisible(), false);
|
||||
await page.keyboard.press("Escape");
|
||||
assert.equal(
|
||||
await page.evaluate(
|
||||
() => document.documentElement.scrollWidth <= innerWidth,
|
||||
),
|
||||
true,
|
||||
);
|
||||
passed++;
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log(
|
||||
`PASS: ${passed} searchable-select/copy variants; filtering, empty state, keyboard selection, disabled skip, dismissal, viewport bounds, clipboard, modal integration.`,
|
||||
);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
Reference in new issue
Block a user