Files
pedwfrontend/tests/phase22/i18n-route-parity.test.cjs
T

66 lines
1.8 KiB
JavaScript

const assert = require("assert");
const path = require("path");
const tests = [];
const test = (name, fn) => tests.push({ name, fn });
const loadRewrites = async () => {
const configPath = path.join(__dirname, "..", "..", "next.config.js");
// eslint-disable-next-line global-require, import/no-dynamic-require
const nextConfig = require(configPath);
return nextConfig.rewrites();
};
test("i18n/rewrites include required CY aliases for auth and policy routes", async () => {
const rewrites = await loadRewrites();
const requiredPairs = [
{ source: "/awd/mewngofnodi", destination: "/auth/signin" },
{ source: "/awd/mewngofnodi/ebost", destination: "/auth/signin/email" },
{ source: "/awd/gwall", destination: "/auth/error" },
{ source: "/awd/gwirio-cais", destination: "/auth/verify-request" },
{ source: "/preifatrwydd", destination: "/privacy" },
{ source: "/hygyrchedd", destination: "/accessibility" },
{
source: "/telerau-ac-amodau",
destination: "/terms-and-conditions"
}
];
for (const pair of requiredPairs) {
const found = rewrites.some(
(entry) =>
entry.source === pair.source &&
entry.destination === pair.destination
);
assert.strictEqual(
found,
true,
`Missing required CY rewrite ${pair.source} -> ${pair.destination}`
);
}
});
const run = async () => {
let passed = 0;
for (const currentTest of tests) {
await currentTest.fn();
passed += 1;
}
console.log(
`Phase 22 i18n-route tests passed (${passed}/${tests.length}).`
);
};
module.exports = run;
if (require.main === module) {
run().catch((error) => {
console.error(error);
process.exit(1);
});
}