// Project Management label colors: each color choice of Manage labels shows its color, and the card title keeps its own field style, in both themes. import assert from "node:assert/strict"; import path from "node:path"; import { outputDir, runSmoke } from "../_harness/index.mjs"; import { loadWorkspace, openBoard, pane, setTheme } from "../_harness/pmFixture.mjs"; const rgb = hex => `rgb(${hex.slice(1).match(/../g).map(value => parseInt(value, 16)).join(", ")})`; await runSmoke("features/pmLabelColors", async ({ page }) => { const output = await outputDir("features/pmLabelColors"); await loadWorkspace(page); await openBoard(page, "Roadmap"); await pane(page).locator(".pm-card-title", { hasText: /^Card A$/ }).click(); const editor = page.locator("dialog.pm-card-editor[open]"); await editor.waitFor(); // The card title is a transparent field. The default field rule of Project Management does not replace its background. const title = editor.getByRole("textbox", { name: "Title", exact: true }); assert.equal(await title.evaluate(input => getComputedStyle(input).backgroundColor), "rgba(0, 0, 0, 0)"); await editor.getByRole("group", { name: "Card details", exact: true }).getByRole("button", { name: "Labels", exact: true }).click(); await page.getByRole("dialog", { name: "Choose labels", exact: true }).getByRole("button", { name: "Manage labels", exact: true }).click(); const manager = page.getByRole("dialog", { name: "Manage labels", exact: true }); await manager.waitFor(); const bug = manager.getByRole("group", { name: "Label Bug", exact: true }); const swatches = await bug.locator("input.pm-color-swatch").evaluateAll(inputs => inputs.map(input => ({ name: input.getAttribute("aria-label"), color: input.style.getPropertyValue("--pm-swatch-color"), shown: getComputedStyle(input).backgroundColor }))); assert.equal(swatches.length, 16); for (const swatch of swatches) assert.equal(swatch.shown, rgb(swatch.color), `${swatch.name} shows its color`); await bug.getByRole("radio", { name: "Blue", exact: true }).check(); await manager.locator(".pm-label-badge", { hasText: /^Bug$/ }).waitFor(); for (const theme of ["dark", "light"]) { await setTheme(page, theme); await bug.screenshot({ path: path.join(output, `label-colors-${theme}.png`) }); } console.log("PASS: label color choices and the card title field"); });