mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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.
103 lines
3.5 KiB
TypeScript
103 lines
3.5 KiB
TypeScript
// @vitest-environment node
|
|
import { globSync, readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { TOOLS } from "@snapotter/shared";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
/**
|
|
* PR #520 renamed 18 tools across the app and the tool pages, but the VitePress
|
|
* sidebar kept its old labels for another two releases: 19 entries in the nav
|
|
* under names the product no longer used. One page H1 was missed too.
|
|
*
|
|
* Tool leaves in the sidebar are deliberately never translated (see
|
|
* localizeSidebar in apps/docs/.vitepress/config.mts), so checking the English
|
|
* config covers all 21 locales.
|
|
*/
|
|
|
|
const ROOT = path.resolve(__dirname, "../../..");
|
|
const NAME_BY_ID = new Map(TOOLS.map((t) => [t.id, t.name]));
|
|
|
|
/**
|
|
* Shipped tools with no docs page. Adding a page means deleting the id here.
|
|
* Adding a tool without a page means this list grows, which is the point.
|
|
*/
|
|
const UNDOCUMENTED = new Set(["remove-gif-background", "rounded-crop"]);
|
|
|
|
interface Leaf {
|
|
label: string;
|
|
id: string;
|
|
line: number;
|
|
}
|
|
|
|
function sidebarToolLeaves(): Leaf[] {
|
|
const src = readFileSync(path.join(ROOT, "apps/docs/.vitepress/config.mts"), "utf8");
|
|
const leaves: Leaf[] = [];
|
|
src.split("\n").forEach((line, i) => {
|
|
// The single top-nav entry sits at six spaces; sidebar leaves are deeper.
|
|
if (!/^\s{10,}\{ text: "/.test(line)) return;
|
|
const m = line.match(
|
|
/\{ text: "([^"]+)", link: "\/tools\/(?:image|video|audio|pdf|files)\/([a-z0-9-]+)" \}/,
|
|
);
|
|
if (m) leaves.push({ label: m[1], id: m[2], line: i + 1 });
|
|
});
|
|
return leaves;
|
|
}
|
|
|
|
const LEAVES = sidebarToolLeaves();
|
|
const PAGES = globSync("apps/docs/tools/*/*.md", { cwd: ROOT })
|
|
.filter((f) => !f.endsWith("conversion-presets.md"))
|
|
.sort();
|
|
|
|
describe("docs sidebar", () => {
|
|
it("found the tool leaves", () => {
|
|
expect(LEAVES.length).toBeGreaterThan(100);
|
|
});
|
|
|
|
it("links only to tools the catalog ships", () => {
|
|
expect(LEAVES.filter((l) => !NAME_BY_ID.has(l.id)).map((l) => l.id)).toEqual([]);
|
|
});
|
|
|
|
it("labels every leaf with the tool's catalog name", () => {
|
|
const wrong = LEAVES.filter((l) => NAME_BY_ID.get(l.id) !== l.label).map(
|
|
(l) => `config.mts:${l.line} "${l.label}" should be "${NAME_BY_ID.get(l.id)}"`,
|
|
);
|
|
expect(wrong).toEqual([]);
|
|
});
|
|
});
|
|
|
|
describe("tool pages", () => {
|
|
it("found the pages", () => {
|
|
expect(PAGES.length).toBeGreaterThan(100);
|
|
});
|
|
|
|
it("titles every page with the tool's catalog name", () => {
|
|
const wrong: string[] = [];
|
|
for (const file of PAGES) {
|
|
const id = path.basename(file, ".md");
|
|
const name = NAME_BY_ID.get(id);
|
|
if (!name) {
|
|
wrong.push(`${file} has no tool with id ${id}`);
|
|
continue;
|
|
}
|
|
const h1 = readFileSync(path.join(ROOT, file), "utf8")
|
|
.split("\n")
|
|
.find((l) => l.startsWith("# "))
|
|
?.replace(/^#\s+/, "")
|
|
.replace(/\s*\{#.*\}$/, "")
|
|
.trim();
|
|
if (h1 !== name) wrong.push(`${file} H1 "${h1}" should be "${name}"`);
|
|
}
|
|
expect(wrong).toEqual([]);
|
|
});
|
|
|
|
it("tracks exactly the tools that still have no page", () => {
|
|
const documented = new Set(PAGES.map((f) => path.basename(f, ".md")));
|
|
const missing = TOOLS.filter((t) => !documented.has(t.id))
|
|
.map((t) => t.id)
|
|
// The 83 conversion presets are covered collectively by
|
|
// apps/docs/tools/conversion-presets.md rather than one page each.
|
|
.filter((id) => !id.includes("-to-"));
|
|
expect(missing.sort()).toEqual([...UNDOCUMENTED].sort());
|
|
});
|
|
});
|