-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefresh-snapshots.js
More file actions
27 lines (25 loc) · 1.42 KB
/
Copy pathrefresh-snapshots.js
File metadata and controls
27 lines (25 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Regenerates the UI snapshots (dev/requirements/<kind>/cases/<name>.png) from the cases in
// dev/requirements/<kind>/cases/*.case.js, using the same rendering as the snapshot test (each case
// through render-snapshot.js, which dispatches to the popup renderer or the
// toolbar-icon renderer by leaf kind), plus the requirement-first INLINE gallery:
// each per-leaf PNG embedded directly under its requirement in
// dev/requirements/requirements.md (build-requirements-gallery.js). Run after an intentional
// change to the popup, its views, events-popup/popup.css, or the toolbar icon, and commit the
// PNGs + the gallery so reviewers see the before/after in the diff.
"use strict";
const fs = require("node:fs");
const path = require("node:path");
const { loadCases, snapshotPath } = require("../cases");
const { renderSnapshot, rendersImage } = require("./render-snapshot");
const { buildGallery, DOC_PATH } = require("../build-requirements-gallery");
(async () => {
// Skip non-image cases (e.g. `kind: "behavior"`): they have no snapshot to write.
for (const testCase of loadCases().filter(rendersImage)) {
const outPath = snapshotPath(testCase);
fs.writeFileSync(outPath, await renderSnapshot(testCase));
console.log(`Wrote ${outPath}`);
}
// The inline gallery embeds those PNGs — refresh it after they exist.
fs.writeFileSync(DOC_PATH, buildGallery());
console.log(`Wrote inline gallery into ${DOC_PATH}`);
})();