mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 21:46:49 +00:00
dc7d1f5e10
Vector basemaps rendered Arabic, Hebrew, Persian and Urdu place names as isolated letters in logical order — "القاهرة" drawn as "ة ر ه ا ق ل ا" — because neither GL engine loads its optional RTL text plugin by default and TREK never registered one. Raster basemaps hid the problem, since their labels are drawn server-side, so it only became visible for everyone when the default basemap became a vector style. Both engine entry points now register the plugin lazily, so the payload is only fetched once a map actually paints RTL text and Latin-only users download nothing. The call is left with each engine because the two signatures genuinely differ: MapLibre takes (url, lazy) and returns a promise, Mapbox takes (url, callback, deferred). The plugin is bundled rather than loaded from a CDN: TREK is offline-first and the production CSP is script-src 'self', so a remote plugin URL would be refused by the worker that imports it. Bundling also puts it in the Workbox precache, so shaping keeps working offline. It needs a resolve alias because the package publishes only its ESM/WASM entry point through "exports" while setRTLTextPlugin requires the classic script in dist/ — the alias is shared by the build and test configs so the two cannot drift.
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
import react from '@vitejs/plugin-react';
|
|
import { rtlTextAlias } from './rtlTextAlias.js';
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
test: {
|
|
alias: [rtlTextAlias],
|
|
root: '.',
|
|
globals: true,
|
|
environment: './tests/environment/jsdom-native-abort.ts',
|
|
include: [
|
|
'tests/**/*.test.{ts,tsx}',
|
|
'src/**/*.test.{ts,tsx}',
|
|
],
|
|
setupFiles: ['tests/setup.ts'],
|
|
testTimeout: 15000,
|
|
hookTimeout: 15000,
|
|
pool: 'forks',
|
|
silent: false,
|
|
reporters: ['verbose'],
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['lcov', 'text'],
|
|
reportsDirectory: './coverage',
|
|
include: ['src/**/*.{ts,tsx}'],
|
|
// All .d.ts, not just vite-env: declaration files carry no executable
|
|
// code, and their lcov entries can't resolve on the Sonar side (its
|
|
// **/*.d.ts exclusion removes them from analysis), which surfaced as
|
|
// "Could not resolve 2 file paths" warnings in every scan.
|
|
exclude: ['src/main.tsx', 'src/**/*.d.ts'],
|
|
// Without these the Client Tests job produced a report, uploaded it and
|
|
// passed no matter what the number was — which is how coverage drifted
|
|
// down to ~48% unnoticed. 85 across the board is the floor we do not want
|
|
// to fall through, not a target: the suite currently sits well above it.
|
|
thresholds: {
|
|
statements: 85,
|
|
branches: 85,
|
|
functions: 85,
|
|
lines: 85,
|
|
},
|
|
},
|
|
css: false,
|
|
},
|
|
});
|