fix: release QA hardening across processing, media, security, and CI gates (#649)

A release-readiness QA pass over the whole product. The commits split into
defects a user would hit and gates that were reporting green while measuring
nothing.

## Fixes that change behaviour

Rate limiting was bypassable on every install: TRUST_PROXY defaulted to true, so
request.ip came from a client-set header and a forged X-Forwarded-For got past
the login limiter. The default is now a private-network trust list.

A transient Postgres outage stranded in-flight jobs, leaving finished output on
disk with no row pointing at it. A reconciler now resolves those rows and adopts
the bytes rather than dropping the work.

A Redis connection that moved to a new address wedged every read-blocked
consumer, so completions stopped signalling while health still answered 200.
Socket timeouts plus subscriber pings recover it.

Installing more than one AI bundle left the shared venv multi-versioned and
silently broke three tools. The installer now reconciles distributions to one
version each.

Converting an image to JXL at quality 1 through 4 returned a 500, because
libjxl 0.7 rejects the distance those values compute. The quality is floored at
what the encoder honours. A missing ffmpeg was also reported to the user as a
corrupt upload; it now says the engine is unavailable.

RAW uploads reached an unpatched LibRaw on arm64, so it is built from source at
0.22.2, and the release scan was split so it can fail on an unfixed critical
instead of hiding it behind ignore-unfixed.

## Gates that could not fail

Two mutation lanes ran zero mutants because Stryker crawled the gitignored docs
build; coverage discarded its whole report on any failing test; the lint gate
skipped root tests, scripts, and two workspaces; and several generated matrices
counted a host missing ffmpeg as a passing tool. Each now measures what it
claims.

Full evidence and the outstanding release items are tracked locally and are not
part of this branch.
This commit is contained in:
SnapOtter
2026-07-27 15:37:30 +08:00
committed by GitHub
parent bc32f86a07
commit d10d0f544f
855 changed files with 54564 additions and 13092 deletions
+21 -130
View File
@@ -4,34 +4,11 @@
* Mirrors the desktop a11y spec's scoped set on a real device emulation
* (Pixel 7 via mobile-chromium). All tests tagged @mobile for project routing.
*
* Shares the same a11y-baseline.json as the desktop spec, with mobile-prefixed
* page keys so desktop and mobile violations are tracked independently.
* The release gate requires zero axe violations in the scoped pages.
*/
import fs from "node:fs";
import path from "node:path";
import AxeBuilder from "@axe-core/playwright";
import { expect, test } from "./helpers";
// ---- Baseline machinery (shared with a11y.spec.ts) ----
interface BaselineFile {
_comment: string;
violations: Record<string, { impact: string; description: string; count: number }>;
}
const BASELINE_PATH = path.join(__dirname, "a11y-baseline.json");
function loadBaseline(): BaselineFile {
try {
return JSON.parse(fs.readFileSync(BASELINE_PATH, "utf-8"));
} catch {
return { _comment: "", violations: {} };
}
}
function saveBaseline(baseline: BaselineFile): void {
fs.writeFileSync(BASELINE_PATH, `${JSON.stringify(baseline, null, 2)}\n`);
}
import { MOBILE_A11Y_PAGES } from "./a11y-routes.js";
import { expect, openSettings, test } from "./helpers";
interface ViolationEntry {
id: string;
@@ -47,14 +24,6 @@ function buildKey(pageKey: string, ruleId: string): string {
async function auditPage(
page: import("@playwright/test").Page,
pageKey: string,
baseline: BaselineFile,
newViolations: {
key: string;
impact: string;
description: string;
count: number;
targets: string[];
}[],
allViolations: {
key: string;
impact: string;
@@ -77,48 +46,17 @@ async function auditPage(
targets: v.nodes.map((n) => (n.target ?? []).join(" ")),
};
allViolations.push(entry);
if (!baseline.violations[key]) {
newViolations.push(entry);
}
}
}
// ---- Scoped page set (mobile, EN + AR) ----
const PAGES_MOBILE_EN = [
{ key: "mobile-home-en", path: "/", needsAuth: true },
{ key: "mobile-image-resize-en", path: "/image/resize", needsAuth: true },
{ key: "mobile-video-convert-en", path: "/video/convert-video", needsAuth: true },
{ key: "mobile-audio-convert-en", path: "/audio/convert-audio", needsAuth: true },
{ key: "mobile-pdf-pdf-to-image-en", path: "/pdf/pdf-to-image", needsAuth: true },
{ key: "mobile-files-csv-excel-en", path: "/files/csv-excel", needsAuth: true },
{ key: "mobile-editor-en", path: "/editor", needsAuth: true },
{ key: "mobile-login-en", path: "/login", needsAuth: false },
];
const PAGES_MOBILE_AR = [
{ key: "mobile-home-ar", path: "/", needsAuth: true, locale: "ar" },
{ key: "mobile-image-resize-ar", path: "/image/resize", needsAuth: true, locale: "ar" },
{ key: "mobile-login-ar", path: "/login", needsAuth: false, locale: "ar" },
];
// ---- Tests ----
test.describe("@mobile Axe a11y audit -- mobile EN", () => {
test.setTimeout(90_000);
test("no new critical/serious violations on scoped pages", async ({
test("has no accessibility violations on scoped pages", async ({
loggedInPage: page,
browser,
}) => {
const baseline = loadBaseline();
const newViolations: {
key: string;
impact: string;
description: string;
count: number;
targets: string[];
}[] = [];
const allViolations: {
key: string;
impact: string;
@@ -127,19 +65,21 @@ test.describe("@mobile Axe a11y audit -- mobile EN", () => {
targets: string[];
}[] = [];
for (const p of PAGES_MOBILE_EN) {
for (const p of MOBILE_A11Y_PAGES.en) {
if (p.needsAuth) {
await page.goto(p.path);
await page.waitForLoadState("networkidle");
await page.waitForTimeout(500);
await auditPage(page, p.key, baseline, newViolations, allViolations);
if (p.openSettings) await openSettings(page);
await auditPage(page, p.key, allViolations);
if (p.openSettings) await page.keyboard.press("Escape");
} else {
const ctx = await browser.newContext({ storageState: { cookies: [], origins: [] } });
const anonPage = await ctx.newPage();
await anonPage.goto(p.path);
await anonPage.waitForLoadState("networkidle");
await anonPage.waitForTimeout(500);
await auditPage(anonPage, p.key, baseline, newViolations, allViolations);
await auditPage(anonPage, p.key, allViolations);
await ctx.close();
}
}
@@ -150,35 +90,10 @@ test.describe("@mobile Axe a11y audit -- mobile EN", () => {
}
console.log("a11y violation counts by severity (mobile EN):", JSON.stringify(bySeverity));
console.log(`total unique rules violated: ${allViolations.length}`);
console.log(`NEW (not in baseline): ${newViolations.length}`);
if (newViolations.length > 0) {
console.log("NEW violations:");
for (const v of newViolations) {
console.log(` ${v.key} [${v.impact}] (${v.count} nodes): ${v.description}`);
}
}
if (process.env.A11Y_UPDATE_BASELINE === "1") {
for (const v of allViolations) {
baseline.violations[v.key] = {
impact: v.impact,
description: v.description,
count: v.count,
};
}
saveBaseline(baseline);
console.log("Baseline updated -- skipping assertion.");
return;
}
const newCriticalSerious = newViolations.filter(
(v) => v.impact === "critical" || v.impact === "serious",
);
expect(
newCriticalSerious,
`${newCriticalSerious.length} NEW critical/serious a11y violation(s) on mobile.\n` +
newCriticalSerious
allViolations,
`${allViolations.length} accessibility violation(s) on mobile.\n` +
allViolations
.map(
(v) =>
` ${v.key} [${v.impact}]: ${v.description}\n${v.targets.map((t) => ` - ${t}`).join("\n")}`,
@@ -190,18 +105,10 @@ test.describe("@mobile Axe a11y audit -- mobile EN", () => {
test.describe("@mobile Axe a11y audit -- mobile AR (RTL)", () => {
test.setTimeout(60_000);
test("no new critical/serious violations on RTL mobile pages", async ({
test("has no accessibility violations on RTL mobile pages", async ({
loggedInPage: page,
browser,
}) => {
const baseline = loadBaseline();
const newViolations: {
key: string;
impact: string;
description: string;
count: number;
targets: string[];
}[] = [];
const allViolations: {
key: string;
impact: string;
@@ -210,7 +117,7 @@ test.describe("@mobile Axe a11y audit -- mobile AR (RTL)", () => {
targets: string[];
}[] = [];
for (const p of PAGES_MOBILE_AR) {
for (const p of MOBILE_A11Y_PAGES.ar) {
if (p.needsAuth) {
await page.evaluate(() => {
localStorage.setItem("snapotter-locale", "ar");
@@ -218,7 +125,9 @@ test.describe("@mobile Axe a11y audit -- mobile AR (RTL)", () => {
await page.goto(p.path);
await page.waitForLoadState("networkidle");
await page.waitForTimeout(500);
await auditPage(page, p.key, baseline, newViolations, allViolations);
if (p.openSettings) await openSettings(page);
await auditPage(page, p.key, allViolations);
if (p.openSettings) await page.keyboard.press("Escape");
} else {
const ctx = await browser.newContext({ storageState: { cookies: [], origins: [] } });
const anonPage = await ctx.newPage();
@@ -229,7 +138,7 @@ test.describe("@mobile Axe a11y audit -- mobile AR (RTL)", () => {
await anonPage.goto(p.path);
await anonPage.waitForLoadState("networkidle");
await anonPage.waitForTimeout(500);
await auditPage(anonPage, p.key, baseline, newViolations, allViolations);
await auditPage(anonPage, p.key, allViolations);
await ctx.close();
}
}
@@ -244,28 +153,10 @@ test.describe("@mobile Axe a11y audit -- mobile AR (RTL)", () => {
bySeverity[v.impact] = (bySeverity[v.impact] || 0) + v.count;
}
console.log("a11y violation counts by severity (mobile AR):", JSON.stringify(bySeverity));
console.log(`NEW (not in baseline): ${newViolations.length}`);
if (process.env.A11Y_UPDATE_BASELINE === "1") {
for (const v of allViolations) {
baseline.violations[v.key] = {
impact: v.impact,
description: v.description,
count: v.count,
};
}
saveBaseline(baseline);
console.log("Baseline updated -- skipping assertion.");
return;
}
const newCriticalSerious = newViolations.filter(
(v) => v.impact === "critical" || v.impact === "serious",
);
expect(
newCriticalSerious,
`${newCriticalSerious.length} NEW critical/serious a11y violation(s) on mobile AR.\n` +
newCriticalSerious
allViolations,
`${allViolations.length} accessibility violation(s) on mobile AR.\n` +
allViolations
.map(
(v) =>
` ${v.key} [${v.impact}]: ${v.description}\n${v.targets.map((t) => ` - ${t}`).join("\n")}`,