Skip to content

Commit 958d073

Browse files
Hotragnclaude
andcommitted
Photo-fit gate: axe on each photo screen and the viewer; credits for the two test photos
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M4PSB5324DNP414ZWJKHW2MK
1 parent 9dd37f9 commit 958d073

6 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎apps/web/test/e2e/photo-fit.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
// the friend decrypts is byte-for-byte the photo the host saw on Send (the filter never touches
1515
// bytes); the main button is on screen without scrolling; the privacy tip is one line at
1616
// 375 px and stays closed after a reload; tapping the photo opens a full-screen dialog with a
17-
// 44 px close button, Escape closes it and focus goes back to the photo.
17+
// 44 px close button, Escape closes it and focus goes back to the photo. axe (WCAG 2 A and AA,
18+
// best practice) on each photo screen at 390 x 664, and on the open viewer.
1819
// Real built app, in-memory fake API (serve.ts), Chrome. No network beyond localhost.
1920
// Usage: npm run build && node apps/web/test/e2e/photo-fit.ts [before]
2021
// `before` only names the screenshots *-before.png and skips the checks main can't pass.
@@ -46,6 +47,7 @@ const VIEWPORTS = [
4647
{ width: 390, height: 844 },
4748
];
4849

50+
const AXE = fs.readFileSync(path.join(ROOT, "node_modules/axe-core/axe.min.js"), "utf8");
4951
const fails: string[] = [];
5052
const rows: string[] = [];
5153
const check = (name: string, ok: boolean, detail = "") => {
@@ -159,10 +161,24 @@ async function measure(
159161
if (photo.dark) check(`${tag}: the dark photo is brightened for display`, /brightness/.test(m.filter), m.filter);
160162
else check(`${tag}: a bright photo has no filter`, !m.filter || m.filter === "none", m.filter);
161163
}
164+
if (!BEFORE && vp.height === 664) await audit(page, tag);
162165
if (vp.width === 390 && vp.height === 664 && photo.dark)
163166
await page.screenshot({ path: path.join(OUT, `${screen}-${BEFORE ? "before" : "after"}.png`) });
164167
}
165168

169+
type Axe = {
170+
run: (c: Document, o: object) => Promise<{ violations: { id: string; nodes: { target: string[] }[] }[] }>;
171+
};
172+
async function audit(page: Page, tag: string) {
173+
await page.evaluate(AXE); // evaluate, not a script tag: the app's CSP blocks inline scripts
174+
const found = await page.evaluate(async () => {
175+
const a = (window as unknown as { axe: Axe }).axe;
176+
const r = await a.run(document, { runOnly: ["wcag2a", "wcag2aa", "best-practice"] });
177+
return r.violations.map((v) => `${v.id} (${v.nodes.length}): ${v.nodes[0]?.target.join(" ")}`);
178+
});
179+
check(`${tag}: axe 0 violations`, found.length === 0, found.join("; "));
180+
}
181+
166182
async function viewer(page: Page, tag: string) {
167183
const trigger = page.locator(".pf, .print button.image").first();
168184
await trigger.click();
@@ -173,6 +189,7 @@ async function viewer(page: Page, tag: string) {
173189
);
174190
check(`${tag}: tapping the photo opens it full screen`, opened);
175191
if (!opened) return;
192+
await audit(page, `${tag} viewer`);
176193
const box = await dlg.getByRole("button", { name: "Close" }).boundingBox();
177194
check(
178195
`${tag}: the close button is 44 px`,

‎docs/credits/photos.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ Scenic photos used in the app and on the website (backlog #6). Only CC0 or publi
1010
| pictured-rocks-autumn | Autumn Views at Pictured Rocks National Lakeshore, Michigan (1b64dfd9-8bf2-463d-8458-3ab74d3a7d8c).jpg | NPS staff | Public domain | https://commons.wikimedia.org/wiki/File:Autumn_Views_at_Pictured_Rocks_National_Lakeshore,_Michigan_(1b64dfd9-8bf2-463d-8458-3ab74d3a7d8c).jpg |
1111
| sleeping-bear-dunes | Sleeping Bear Dunes National Lakeshore SLBE0162.jpg | National Park Service Digital Image Archives | Public domain | https://commons.wikimedia.org/wiki/File:Sleeping_Bear_Dunes_National_Lakeshore_SLBE0162.jpg |
1212
| autumn-trail | Autumn trail (Unsplash).jpg | Taylor Swayze taylorgswayze | CC0 | https://commons.wikimedia.org/wiki/File:Autumn_trail_(Unsplash).jpg |
13+
14+
## Test photos (photo-fit gate)
15+
16+
Two derivatives of the photos above, made with sharp from `scripts/scenic-src/` for `apps/web/test/e2e/photo-fit.ts`. Nothing was downloaded. The repo has no real indoor photo, so the dark one is labelled "darkened real photo" in the test.
17+
18+
| File | Made from | Change |
19+
| --- | --- | --- |
20+
| `apps/web/test/fixtures/photo-dark-autumn-trail.jpg` | autumn-trail (CC0) | 1024 px wide, light cut to 22% (mean luma about 0.10) |
21+
| `apps/web/test/fixtures/photo-tall-pictured-rocks.jpg` | pictured-rocks-cliffs (public domain) | 9:16 centre crop, 720 x 1280 |
3.22 KB
Loading
-5.23 KB
Loading
189 KB
Loading
3.8 KB
Loading

0 commit comments

Comments
 (0)