mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
+23
-136
@@ -4,35 +4,11 @@
|
||||
* Scoped set: home, one tool per modality, editor, settings, login.
|
||||
* Runs in the default locale (en) and one RTL locale (ar).
|
||||
*
|
||||
* Uses a baseline file (a11y-baseline.json) to avoid failing on known
|
||||
* violations while catching any NEW regressions. To update the baseline
|
||||
* after fixing violations, run with A11Y_UPDATE_BASELINE=1.
|
||||
* 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 ----
|
||||
|
||||
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 { DESKTOP_A11Y_PAGES } from "./a11y-routes.js";
|
||||
import { expect, openSettings, test } from "./helpers";
|
||||
|
||||
interface ViolationEntry {
|
||||
id: string;
|
||||
@@ -46,20 +22,12 @@ function buildKey(pageKey: string, ruleId: string): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* Run axe on the current page and assert no NEW critical/serious violations
|
||||
* beyond the committed baseline.
|
||||
* Run axe on the current page and collect every violation. The caller gates
|
||||
* on the complete result so moderate debt cannot silently become permanent.
|
||||
*/
|
||||
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;
|
||||
@@ -82,53 +50,28 @@ async function auditPage(
|
||||
targets: v.nodes.map((n) => (n.target ?? []).join(" ")),
|
||||
};
|
||||
allViolations.push(entry);
|
||||
|
||||
// If this violation is NOT in the baseline, it is new
|
||||
if (!baseline.violations[key]) {
|
||||
newViolations.push(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Scoped page set ----
|
||||
|
||||
const PAGES_EN = [
|
||||
{ key: "home-en", path: "/", needsAuth: true },
|
||||
{ key: "image-resize-en", path: "/image/resize", needsAuth: true },
|
||||
{ key: "video-convert-en", path: "/video/convert-video", needsAuth: true },
|
||||
{ key: "audio-convert-en", path: "/audio/convert-audio", needsAuth: true },
|
||||
{ key: "pdf-pdf-to-image-en", path: "/pdf/pdf-to-image", needsAuth: true },
|
||||
{ key: "files-csv-excel-en", path: "/files/csv-excel", needsAuth: true },
|
||||
{ key: "editor-en", path: "/editor", needsAuth: true },
|
||||
{ key: "login-en", path: "/login", needsAuth: false },
|
||||
];
|
||||
|
||||
const PAGES_AR = [
|
||||
{ key: "home-ar", path: "/", needsAuth: true, locale: "ar" },
|
||||
{ key: "image-resize-ar", path: "/image/resize", needsAuth: true, locale: "ar" },
|
||||
{ key: "editor-ar", path: "/editor", needsAuth: true, locale: "ar" },
|
||||
{ key: "login-ar", path: "/login", needsAuth: false, locale: "ar" },
|
||||
];
|
||||
|
||||
// ---- Tests ----
|
||||
|
||||
// Each test scans 9+ pages with axe; the default 30s timeout is tight.
|
||||
test.describe("Axe a11y audit -- desktop 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 }[] = [];
|
||||
const allViolations: { key: string; impact: string; description: string; count: number }[] = [];
|
||||
|
||||
for (const p of PAGES_EN) {
|
||||
for (const p of DESKTOP_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 {
|
||||
// Login page: use a fresh context without auth
|
||||
const ctx = await browser.newContext({ storageState: { cookies: [], origins: [] } });
|
||||
@@ -136,7 +79,7 @@ test.describe("Axe a11y audit -- desktop EN", () => {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -148,39 +91,11 @@ test.describe("Axe a11y audit -- desktop EN", () => {
|
||||
}
|
||||
console.log("a11y violation counts by severity (desktop EN):", JSON.stringify(bySeverity));
|
||||
console.log(`total unique rules violated: ${allViolations.length}`);
|
||||
console.log(`baselined: ${allViolations.length - newViolations.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}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Update baseline if requested (skip assertion when generating baseline)
|
||||
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;
|
||||
}
|
||||
|
||||
// Gate: fail only on NEW critical or serious violations
|
||||
const newCriticalSerious = newViolations.filter(
|
||||
(v) => v.impact === "critical" || v.impact === "serious",
|
||||
);
|
||||
expect(
|
||||
newCriticalSerious,
|
||||
`${newCriticalSerious.length} NEW critical/serious a11y violation(s) found. ` +
|
||||
`Run with A11Y_UPDATE_BASELINE=1 to baseline after review.\n` +
|
||||
newCriticalSerious
|
||||
allViolations,
|
||||
`${allViolations.length} accessibility violation(s) found.\n` +
|
||||
allViolations
|
||||
.map(
|
||||
(v) =>
|
||||
` ${v.key} [${v.impact}]: ${v.description}\n${v.targets.map((t) => ` - ${t}`).join("\n")}`,
|
||||
@@ -192,15 +107,10 @@ test.describe("Axe a11y audit -- desktop EN", () => {
|
||||
|
||||
test.describe("Axe a11y audit -- desktop AR (RTL)", () => {
|
||||
test.setTimeout(60_000);
|
||||
test("no new critical/serious violations on RTL pages", async ({
|
||||
loggedInPage: page,
|
||||
browser,
|
||||
}) => {
|
||||
const baseline = loadBaseline();
|
||||
const newViolations: { key: string; impact: string; description: string; count: number }[] = [];
|
||||
test("has no accessibility violations on RTL pages", async ({ loggedInPage: page, browser }) => {
|
||||
const allViolations: { key: string; impact: string; description: string; count: number }[] = [];
|
||||
|
||||
for (const p of PAGES_AR) {
|
||||
for (const p of DESKTOP_A11Y_PAGES.ar) {
|
||||
if (p.needsAuth) {
|
||||
// Switch to Arabic locale
|
||||
await page.evaluate(() => {
|
||||
@@ -209,7 +119,9 @@ test.describe("Axe a11y audit -- desktop 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();
|
||||
@@ -221,7 +133,7 @@ test.describe("Axe a11y audit -- desktop 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();
|
||||
}
|
||||
}
|
||||
@@ -238,35 +150,10 @@ test.describe("Axe a11y audit -- desktop AR (RTL)", () => {
|
||||
}
|
||||
console.log("a11y violation counts by severity (desktop AR):", 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) in AR locale.\n` +
|
||||
newCriticalSerious
|
||||
allViolations,
|
||||
`${allViolations.length} accessibility violation(s) in AR locale.\n` +
|
||||
allViolations
|
||||
.map(
|
||||
(v) =>
|
||||
` ${v.key} [${v.impact}]: ${v.description}\n${v.targets.map((t) => ` - ${t}`).join("\n")}`,
|
||||
|
||||
Reference in New Issue
Block a user