diff --git a/assets/screenshot-data-platform-dark.png b/assets/screenshot-data-platform-dark.png index 96d8b20..3cde87e 100644 Binary files a/assets/screenshot-data-platform-dark.png and b/assets/screenshot-data-platform-dark.png differ diff --git a/assets/screenshot-data-platform-light.png b/assets/screenshot-data-platform-light.png new file mode 100644 index 0000000..30d192e Binary files /dev/null and b/assets/screenshot-data-platform-light.png differ diff --git a/assets/screenshot-service-review-dark.png b/assets/screenshot-service-review-dark.png new file mode 100644 index 0000000..57a53bf Binary files /dev/null and b/assets/screenshot-service-review-dark.png differ diff --git a/assets/screenshot-service-review-light.png b/assets/screenshot-service-review-light.png index 274d855..5f91fca 100644 Binary files a/assets/screenshot-service-review-light.png and b/assets/screenshot-service-review-light.png differ diff --git a/assets/screenshot-ticket-report-dark.png b/assets/screenshot-ticket-report-dark.png index 7d960d0..976a1e4 100644 Binary files a/assets/screenshot-ticket-report-dark.png and b/assets/screenshot-ticket-report-dark.png differ diff --git a/assets/screenshot-ticket-report-light.png b/assets/screenshot-ticket-report-light.png new file mode 100644 index 0000000..bce0f5c Binary files /dev/null and b/assets/screenshot-ticket-report-light.png differ diff --git a/docs/demo.md b/docs/demo.md index b494a75..f34daec 100644 --- a/docs/demo.md +++ b/docs/demo.md @@ -30,11 +30,14 @@ asset 360), calendars, intraday charts with axis breaks, public data, layouts, t live data and a benchmark. All data is generated with a fixed seed; "Public data" calls public web APIs from the PSU server. -![Data platform page of the showcase app: coverage heatmap of source systems and assets per number of sources](assets/images/screenshot-data-platform-dark.png) +![Data platform page of the showcase app in the light theme: coverage heatmap of source systems per asset class, and assets per number of sources](assets/images/screenshot-data-platform-light.png#only-light) +![Data platform page of the showcase app in the dark theme: coverage heatmap of source systems per asset class, and assets per number of sources](assets/images/screenshot-data-platform-dark.png#only-dark) -![Ticket report page: SLA gauge, opened per day against the previous period, lead time histogram, boxplot per team](assets/images/screenshot-ticket-report-dark.png) +![Ticket report page in the light theme: SLA gauge, opened per day against the previous period, lead time histogram, boxplot per team](assets/images/screenshot-ticket-report-light.png#only-light) +![Ticket report page in the dark theme: SLA gauge, opened per day against the previous period, lead time histogram, boxplot per team](assets/images/screenshot-ticket-report-dark.png#only-dark) -![Service review page: KPI matrix of sparklines per customer](assets/images/screenshot-service-review-light.png) +![Managed services page in the light theme: service review, a KPI matrix of sparklines per customer](assets/images/screenshot-service-review-light.png#only-light) +![Managed services page in the dark theme: service review, a KPI matrix of sparklines per customer](assets/images/screenshot-service-review-dark.png#only-dark) ## Before you share the app diff --git a/docs/development/index.md b/docs/development/index.md index 1ae7a73..4e097b4 100644 --- a/docs/development/index.md +++ b/docs/development/index.md @@ -65,6 +65,7 @@ of these sections; `tests/js/llms-sections.test.js` fails otherwise. | The pivot report on a page | Drawn into a shadow root of its placeholder, with the module's stylesheets inside it, so the page's typography stays outside. | | The screenshots of the README and the start page (`echarts-weather-*`, `perspective-weather-*`, `pivot-weather-*`) | `node docs/site/screenshots.mjs ` on the built and served site, light and dark, into `docs/assets/`. | | The Pivot showcase screenshots (`pivot-showcase-*`) | `PSU_PIVOT_DEMO_URL= node docs/site/screenshots.mjs` against `New-UDPivotShowcase` on a PSU instance, light and dark, into `docs/assets/`. | +| The ECharts showcase screenshots (`screenshot-ticket-report-*`, `screenshot-data-platform-*`, `screenshot-service-review-*`) | `PSU_ECHARTS_DEMO_URL= node docs/site/screenshots.mjs` against `New-UDEChartShowcase` on a PSU instance, light and dark, into `assets/`. | ## Browser tests on PSU diff --git a/docs/site/screenshots.mjs b/docs/site/screenshots.mjs index 5a77b00..fe14702 100644 --- a/docs/site/screenshots.mjs +++ b/docs/site/screenshots.mjs @@ -1,5 +1,5 @@ // Screenshots for the documentation, in the light and the dark theme. The files land in docs/assets/ -// and are committed; look at them before committing. +// (the ECharts showcase app's in assets/) and are committed; look at them before committing. // // The live examples of the README and the start page: each one is the example's element on the built site, drawn by // the module's own component. Build and serve the site first (docs/development/), then: @@ -11,12 +11,22 @@ // those are taken then: // // PSU_PIVOT_DEMO_URL=https://psu.example.com/pivot-showcase node docs/site/screenshots.mjs +// +// The ECharts showcase app's pages for docs/demo.md (screenshot-ticket-report-*, screenshot-data-platform-*, +// screenshot-service-review-*): set PSU_ECHARTS_DEMO_URL to the app on a PSU instance (New-UDEChartShowcase), +// as PSU_URL for tests/browser/psu.spec.mjs. Only those are taken then; with both variables set, both sets: +// +// PSU_ECHARTS_DEMO_URL=https://psu.example.com/echarts node docs/site/screenshots.mjs import { chromium, expect } from "@playwright/test"; import { fileURLToPath } from "node:url"; import { CSV, fileOf, pickFile } from "../../tests/browser/pivot-import.mjs"; +import { waitForCharts } from "../../tests/browser/echarts-page.mjs"; const out = fileURLToPath(new URL("../assets/", import.meta.url)); +// the root's assets/: the showcase app's screenshots, which Build-Site.ps1 copies into the site +const rootAssets = fileURLToPath(new URL("../../assets/", import.meta.url)); const demo = (process.env.PSU_PIVOT_DEMO_URL || "").replace(/\/$/, ""); +const echartsDemo = (process.env.PSU_ECHARTS_DEMO_URL || "").replace(/\/$/, ""); // ---- the site's live examples ---------------------------------------------------------------------- const base = process.argv[2] || "http://127.0.0.1:8765"; @@ -145,10 +155,54 @@ async function demoShots(browser) { } } +// ---- the ECharts showcase app on PSU --------------------------------------------------------------- +// page, file name (without -light/-dark) and the card whose bottom ends the shot, with 8 pixels of the +// page below it (half the gap between two rows of cards), so no chart is cut +const ECHARTS_SHOTS = [ + ["tickets", "screenshot-ticket-report", "Lead time by team"], + ["dataplatform", "screenshot-data-platform", "In how many sources"], + ["msp", "screenshot-service-review", "Service review"], +]; +const ECHARTS_WIDTH = 1440; + +async function echartsDemoShots(browser) { + const page = await browser.newPage({ viewport: { width: ECHARTS_WIDTH, height: 900 } }); + try { + for (const mode of ["light", "dark"]) { + for (const [path, name, lastCard] of ECHARTS_SHOTS) { + await page.goto(`${echartsDemo}/${path}`); + await waitForCharts(page); + await setTheme(page, mode); + // the pointer off the switch and the charts: no hover state, no tooltip + await page.mouse.move(4, 80); + await expect(page.locator("[role=alert], .MuiSnackbar-root")).toHaveCount(0); + const card = page.locator(".MuiCard-root", { hasText: lastCard }).first(); + // the card's bottom on the page, not in the window + const bottom = await card.evaluate((el) => el.getBoundingClientRect().bottom + window.scrollY); + const clip = { x: 0, y: 0, width: ECHARTS_WIDTH, height: Math.round(bottom + 8) }; + // the charts redraw in the new theme with their entry animation, which + // animations: "disabled" does not stop on a canvas: wait until two shots in a row match + let previous; + await expect.poll(async () => { + const shot = await page.screenshot({ fullPage: true, clip }); + const still = previous !== undefined && shot.equals(previous); + previous = shot; + return still; + }, { timeout: 30000, intervals: [700] }).toBe(true); + await page.screenshot({ path: `${rootAssets}${name}-${mode}.png`, fullPage: true, clip }); + console.log(`${name}-${mode}.png`); + } + } + } finally { + await page.close(); + } +} + const browser = await chromium.launch(); try { if (demo) await demoShots(browser); - else await siteShots(browser); + if (echartsDemo) await echartsDemoShots(browser); + if (!demo && !echartsDemo) await siteShots(browser); } finally { await browser.close(); } diff --git a/tests/browser/echarts-page.mjs b/tests/browser/echarts-page.mjs new file mode 100644 index 0000000..c01a62a --- /dev/null +++ b/tests/browser/echarts-page.mjs @@ -0,0 +1,18 @@ +// Waiting for the charts of a PSU app page, shared by the showcase spec (psu.spec.mjs) and the +// showcase screenshots (docs/site/screenshots.mjs). Each drawn chart is a div with its ECharts instance. +import { expect } from "@playwright/test"; + +/** The number of charts on the page. */ +export const chartCount = (page) => page.evaluate(() => [...document.querySelectorAll("div")].filter((d) => d.echarts).length); + +/** Waits until the page has charts and stops adding them (dynamic regions render after the first ones). */ +export async function waitForCharts(page) { + await expect.poll(() => chartCount(page), { timeout: 30000 }).toBeGreaterThan(0); + let last = -1; + await expect.poll(async () => { + const n = await chartCount(page); + const stable = n === last; + last = n; + return stable; + }, { timeout: 30000, intervals: [1000] }).toBe(true); +} diff --git a/tests/browser/psu.spec.mjs b/tests/browser/psu.spec.mjs index 55cfe45..9945e94 100644 --- a/tests/browser/psu.spec.mjs +++ b/tests/browser/psu.spec.mjs @@ -1,6 +1,7 @@ // Optional: the showcase app on a PSU instance in all three browsers. Runs only when PSU_URL points // at the app (e.g. PSU_URL=https://psu.example.com/echarts npx playwright test psu); skipped in CI. import { test, expect } from "@playwright/test"; +import { waitForCharts } from "./echarts-page.mjs"; const base = process.env.PSU_URL; // every page of the app. "public" calls public web APIs (slow, outside our control), and "live" and @@ -14,15 +15,7 @@ test.describe("showcase on PSU", () => { const errors = []; page.on("pageerror", (e) => errors.push(e.message)); await page.goto(`${base.replace(/\/$/, "")}/${name}`); - await expect.poll(() => page.evaluate(() => [...document.querySelectorAll("div")].filter((d) => d.echarts).length), { timeout: 30000 }).toBeGreaterThan(0); - // wait until the page stops adding charts (dynamic regions render after the first ones) - let last = -1; - await expect.poll(async () => { - const n = await page.evaluate(() => [...document.querySelectorAll("div")].filter((d) => d.echarts).length); - const stable = n === last; - last = n; - return stable; - }, { timeout: 30000, intervals: [1000] }).toBe(true); + await waitForCharts(page); await expect(page.locator("[role=alert]")).toHaveCount(0); const charts = await page.evaluate(() => [...document.querySelectorAll("div")].filter((d) => d.echarts && d.offsetParent !== null).map((d) => ({ w: d.clientWidth, cw: d.echarts.getWidth() }))); for (const c of charts) expect(Math.abs(c.w - c.cw)).toBeLessThanOrEqual(2); diff --git a/tests/js/screenshots.test.js b/tests/js/screenshots.test.js index 9166f25..36e2b56 100644 --- a/tests/js/screenshots.test.js +++ b/tests/js/screenshots.test.js @@ -23,10 +23,9 @@ const files = [ ...readdirSync(join(root, "assets")).filter((name) => name.startsWith("screenshot-")).map((name) => `assets/${name}`), ]; -// Single screenshots of the ECharts showcase app (docs/demo.md). Their partners need new screenshots -// from the app on a PowerShell Universal instance: #213. The site shows them without a theme fragment, -// so they stay visible in both themes. Remove an entry when its partner is there; the test fails until then. -const SINGLES = new Set(["assets/screenshot-data-platform-dark.png", "assets/screenshot-ticket-report-dark.png", "assets/screenshot-service-review-light.png"]); +// Single screenshots, shown in both themes without a theme fragment. None at present; an entry needs a +// reason and an issue for its partner. The test fails once an entry has its partner or is gone. +const SINGLES = new Set([]); /** * The repository path an image address of `page` points to, or null for an image elsewhere (a badge).