okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
52ba0b781
main
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 () => { 10const cors = expertParams (). find ( p => p . id === 'server.cors' ); 11assert . match ( cors . effect , / does nothing in the app / ); 12assert . match ( cors . effect , / "cors_origins" / ); 13const english = JSON . parse ( await readFile ( new URL ( '../src/locales/en.json' , import . meta. url ), 'utf8' )); 14const id = Object . keys ( english ). find ( key => english [ key ] === cors . effect ); 15assert . ok ( id , 'the English text is in the catalog' ); 16for ( const language of languages ) { 17const catalog = JSON . parse ( await readFile ( new URL ( `../src/locales/ ${ language } .json` , import . meta. url ), 'utf8' )); 18assert . ok ( catalog [ id ]?. trim (), ` ${ language } has ${ id } ` ); 19assert . ok ( catalog [ id ]. includes ( 'cors_origins' ), ` ${ language } keeps the config key` ); 20assert . ok ( catalog [ id ]. includes ( '8080' ), ` ${ language } keeps the port` ); 21if ( language !== 'en' ) assert . notEqual ( catalog [ id ], english [ id ], ` ${ language } is translated` ); 22} 23});