Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
test(website): cover English-only route matching and release asset patterns
EtienneLescot677fd8b1987a
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.ymlindex ac2f95609..69e59d253 100644--- a/.github/workflows/docs.yml+++ b/.github/workflows/docs.yml@@ -57,6 +57,9 @@ jobs:- name: Type-checkworking-directory: websiterun: npm run typecheck+ - name: Unit tests+ working-directory: website+ run: npm test# The walkthrough's clips and stills are committed to this repo, which has# no LFS filter — their size is permanent, so a budget that lives only in a# design note drifts on the first re-cut. This also fails any clip encodeddiff --git a/website/package.json b/website/package.jsonindex 454aca615..13a5e6ae2 100644--- a/website/package.json+++ b/website/package.json@@ -10,7 +10,8 @@"clear": "docusaurus clear","typecheck": "tsc --noEmit","check:media": "node scripts/check-media-budget.mjs",- "check:recreation": "node scripts/gen-recreation.mjs --check"+ "check:recreation": "node scripts/gen-recreation.mjs --check",+ "test": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON --test \"src/**/*.test.ts\""},"dependencies": {"@docusaurus/core": "~3.10.1",diff --git a/website/src/lib/locale-routes.test.ts b/website/src/lib/locale-routes.test.tsnew file mode 100644index 000000000..64a3d30c0--- /dev/null+++ b/website/src/lib/locale-routes.test.ts@@ -0,0 +1,37 @@+import assert from "node:assert/strict";+import { test } from "node:test";++import { BLOG_PATH, ENGLISH_ONLY_PAGES, isEnglishOnlyPath } from "./locale-routes.ts";++test("every English-only family matches, with and without the trailing slash", () => {+ for (const prefix of [BLOG_PATH, ...ENGLISH_ONLY_PAGES.map((page) => page.path)]) {+ const page = prefix.endsWith("/") ? `${prefix}some-page/` : `${prefix}linux/`;+ assert.equal(isEnglishOnlyPath(page), true, page);+ assert.equal(isEnglishOnlyPath(page.slice(0, -1)), true, page.slice(0, -1));+ }+ // The family roots themselves, as the navbar and footer write them.+ assert.equal(isEnglishOnlyPath("/blog"), true);+ assert.equal(isEnglishOnlyPath("/blog/"), true);+});++test("query strings and hashes do not change the answer", () => {+ assert.equal(isEnglishOnlyPath("/features/captions/#offline"), true);+ assert.equal(isEnglishOnlyPath("/compare/openscreen-vs-cap?ref=docs"), true);+ assert.equal(isEnglishOnlyPath("/docs/faq/#does-openscreen-work-offline"), false);+});++test("translated routes and look-alikes are not English-only", () => {+ for (const path of [+ "/",+ "/download/",+ "/docs/intro/",+ "/docs/captions/",+ "/blogroll/",+ "/featured/",+ "/screen-recorder",+ "/fr/blog/",+ "/fr/features/captions/",+ ]) {+ assert.equal(isEnglishOnlyPath(path), false, path);+ }+});diff --git a/website/src/lib/release.test.ts b/website/src/lib/release.test.tsnew file mode 100644index 000000000..8d436b8a1--- /dev/null+++ b/website/src/lib/release.test.ts@@ -0,0 +1,52 @@+import assert from "node:assert/strict";+import { test } from "node:test";++import { ASSET_PATTERNS, type AssetKind, findAsset, type LatestRelease } from "./release.ts";++const release = (...names: string[]): LatestRelease => ({+ tag: "v0.0.0",+ published: "",+ publishedIso: "",+ assets: names.map((name) => ({ name, url: `https://example.test/${name}`, size: 1 })),+});++// The asset list of v1.11.0, the release whose .dmg names the old patterns missed.+const V1_11_0 = release(+ "Openscreen-macOS-Apple-Silicon-1.11.0.dmg",+ "Openscreen-macOS-Intel-1.11.0.dmg",+ "Openscreen.Setup.1.11.0.exe",+ "Openscreen-Linux-1.11.0.deb",+ "Openscreen-Linux-1.11.0.rpm",+ "Openscreen-Linux-1.11.0.pacman",+ "Openscreen-Linux-1.11.0.AppImage",+ "latest.yml",+ "latest-mac.yml",+);++test("each kind resolves to exactly one v1.11.0 asset", () => {+ const expected: Record<AssetKind, string> = {+ macArm: "Openscreen-macOS-Apple-Silicon-1.11.0.dmg",+ macIntel: "Openscreen-macOS-Intel-1.11.0.dmg",+ windows: "Openscreen.Setup.1.11.0.exe",+ deb: "Openscreen-Linux-1.11.0.deb",+ rpm: "Openscreen-Linux-1.11.0.rpm",+ pacman: "Openscreen-Linux-1.11.0.pacman",+ appImage: "Openscreen-Linux-1.11.0.AppImage",+ };+ for (const kind of Object.keys(ASSET_PATTERNS) as AssetKind[]) {+ assert.equal(findAsset(V1_11_0, kind)?.name, expected[kind], kind);+ const matches = V1_11_0?.assets.filter((a) => ASSET_PATTERNS[kind].test(a.name)) ?? [];+ assert.equal(matches.length, 1, `${kind} is ambiguous`);+ }+});++test("the 1.7.0 .dmg names still resolve", () => {+ const old = release("Openscreen-Mac-arm64-1.7.0.dmg", "Openscreen-Mac-x64-1.7.0.dmg");+ assert.equal(findAsset(old, "macArm")?.name, "Openscreen-Mac-arm64-1.7.0.dmg");+ assert.equal(findAsset(old, "macIntel")?.name, "Openscreen-Mac-x64-1.7.0.dmg");+});++test("a missing asset or a failed lookup gives null, which the page turns into /releases/latest", () => {+ assert.equal(findAsset(release("Openscreen.Setup.1.11.0.exe"), "macArm"), null);+ assert.equal(findAsset(null, "windows"), null);+});diff --git a/website/tsconfig.json b/website/tsconfig.jsonindex b4345b727..74e88ee19 100644--- a/website/tsconfig.json+++ b/website/tsconfig.json@@ -1,6 +1,9 @@{"extends": "@docusaurus/tsconfig","compilerOptions": {- "baseUrl": "."+ "baseUrl": ".",+ // The node:test files import their subject with its .ts extension, which+ // Node's type stripping needs; noEmit (from the base config) allows it.+ "allowImportingTsExtensions": true}}