okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-027-i18n: French as the ninth app language and the Polish README52ba0b781

main
1.3 KiB23 linesraw
1// #3208: the "Allow browser origins" setting says in plain words that it does nothing in the app, where CORS really is, and how to limit it.
2import test from 'node:test';
3import assert from 'node:assert/strict';
4import { readFile } from 'node:fs/promises';
5import { expertParams } from '../server/catalog.mjs';
6
7const languages = ['en', 'de', 'es', 'fr', 'ja', 'ko', 'pt', 'ru', 'zh'];
8
9test('the CORS setting explains itself and the explanation exists in all 9 languages', async () => {
10  const cors = expertParams().find(p => p.id === 'server.cors');
11  assert.match(cors.effect, /does nothing in the app/);
12  assert.match(cors.effect, /"cors_origins"/);
13  const english = JSON.parse(await readFile(new URL('../src/locales/en.json', import.meta.url), 'utf8'));
14  const id = Object.keys(english).find(key => english[key] === cors.effect);
15  assert.ok(id, 'the English text is in the catalog');
16  for (const language of languages) {
17    const catalog = JSON.parse(await readFile(new URL(`../src/locales/${language}.json`, import.meta.url), 'utf8'));
18    assert.ok(catalog[id]?.trim(), `${language} has ${id}`);
19    assert.ok(catalog[id].includes('cors_origins'), `${language} keeps the config key`);
20    assert.ok(catalog[id].includes('8080'), `${language} keeps the port`);
21    if (language !== 'en') assert.notEqual(catalog[id], english[id], `${language} is translated`);
22  }
23});