Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/screenshot-data-platform-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-data-platform-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-service-review-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-service-review-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-ticket-report-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-ticket-report-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions docs/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions docs/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <site url>` on the built and served site, light and dark, into `docs/assets/`. |
| The Pivot showcase screenshots (`pivot-showcase-*`) | `PSU_PIVOT_DEMO_URL=<app 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=<app url> node docs/site/screenshots.mjs` against `New-UDEChartShowcase` on a PSU instance, light and dark, into `assets/`. |

## Browser tests on PSU

Expand Down
58 changes: 56 additions & 2 deletions docs/site/screenshots.mjs
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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";
Expand Down Expand Up @@ -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();
}
18 changes: 18 additions & 0 deletions tests/browser/echarts-page.mjs
Original file line number Diff line number Diff line change
@@ -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);
}
11 changes: 2 additions & 9 deletions tests/browser/psu.spec.mjs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions tests/js/screenshots.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Loading