Files
ianitor/apps/web/e2e/specs/aula.spec.ts

29 lines
1.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
// The release's screenshots (docs/release.md): each shot of tests/demo.ts SHOTS, 1440 × 900 at
// scale 1, saved as target/e2e/aula/<name>.png. .fabrica/aula.yaml lists the same files, which
// `fabrica aula shots` checks and publishes as aula-<name>.png with aula.json.
import { mkdirSync } from "node:fs";
import { join } from "node:path";
import { SHOTS } from "../../tests/demo";
import { TARGET, expect, test } from "../fixtures";
const dir = join(TARGET, "aula");
for (const shot of SHOTS) {
test(`aula: ${shot.name}`, async ({ page, open }) => {
await open(shot.path);
for (const sel of shot.click ?? []) await page.locator(sel).first().click();
await expect(page.locator(shot.wait).first()).toBeAttached();
// Nothing still loading, the fonts in, two frames drawn and transitions over.
await expect(page.locator("[aria-busy=true]")).toHaveCount(0);
await page.evaluate(() => document.fonts.ready.then(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)))));
await page.waitForTimeout(400);
mkdirSync(dir, { recursive: true });
await page.screenshot({ path: join(dir, `${shot.name}.png`), animations: "disabled", caret: "hide" });
});
}