diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..d5d27fc56 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,21 @@ +name: Tests + +on: + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + seo: + name: SEO publishing contract + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "22" + - name: Run SEO contract tests + run: npm test diff --git a/.mintignore b/.mintignore new file mode 100644 index 000000000..3ea7609ab --- /dev/null +++ b/.mintignore @@ -0,0 +1,2 @@ +# Repository documentation; not part of the published Mintlify site. +README_EN.md diff --git a/package.json b/package.json index 570a876b0..96928f6d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "scripts": { - "dev": "npx mintlify dev" + "dev": "npx mintlify dev", + "test": "node --test tests/*.test.mjs" }, "dependencies": { "mintlify": "^4.2.375" diff --git a/tests/seo.test.mjs b/tests/seo.test.mjs new file mode 100644 index 000000000..a9ebcedae --- /dev/null +++ b/tests/seo.test.mjs @@ -0,0 +1,32 @@ +import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import test from "node:test"; + +const repoRoot = new URL("../", import.meta.url); + +test("repository-only English README is excluded from Mintlify publishing", async () => { + const mintignore = await readFile(new URL(".mintignore", repoRoot), "utf8"); + const patterns = mintignore + .split(/\r?\n/) + .map((line) => line.trim()) + .filter((line) => line && !line.startsWith("#")); + + let ignored = false; + for (const pattern of patterns) { + if (pattern === "README_EN.md") ignored = true; + if (pattern === "!README_EN.md") ignored = false; + } + + assert.equal(ignored, true); +}); + +test("the historical README_EN URL keeps its permanent canonical redirect", async () => { + const docs = JSON.parse(await readFile(new URL("docs.json", repoRoot), "utf8")); + const redirects = docs.redirects.filter( + (item) => item.source === "/README_EN", + ); + + assert.equal(redirects.length, 1); + assert.equal(redirects[0].destination, "/en/insight/guide"); + assert.notEqual(redirects[0].permanent, false); +});