Files
wekan/tests/addressReportColumns.test.cjs
T
Lauri Ojansivu 3d703965c4 Admin Panel / Problems: "IPv6 location" and "Instrumentation" are translated.
The Security report in Finnish read "Sijainti" beside the English "IPv6
location", and the menu row and title bar of the Instrumentation report were
English in every language.

- The IPv6 location column is the translated 'location' with the fixed
  technical suffix " (IPv6)" - "Sijainti (IPv6)" - through a new optional
  labelSuffix on table headers, so no new key is needed.
- instrumentationReportTitle names the report in the menu row and in its
  title bar, which tests/adminUrls.test.cjs requires to say the same words.
  It is translated into all 246 locale files, after instrumentation-other
  in en.i18n.json's key order. French uses "Instrumentation logicielle",
  because the bare word is spelled exactly like the English one.

Low-confidence translations, written from the language's general
vocabulary for "measuring tools" where the technical term has no
established form: ak, ay, bm, bua, chr, cv, ee, ff, fj, gn, gv, ha, haw, ig,
iu, kl, kw, lg, mi, nah, nd, ny, om, qu, rn, rw, sah, se, sm, sn, ss, st,
tig, tlh, to, tpi, ts, ve, vo, wal, wo, zgh.

tests/addressReportColumns.test.cjs checks that every address column header
is translated. The admin-office-location UI spec expects "Location (IPv6)".

Thanks to xet7 !
2026-10-20 10:37:03 +03:00

55 lines
2.8 KiB
JavaScript

'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { addressReportColumns } = require('../models/lib/addressReportColumns');
const columns = addressReportColumns({ map: true });
// Every header translated: the IPv6 location was the English text "IPv6
// location" in every language. It is 'location' with the fixed suffix
// " (IPv6)" now, "Sijainti (IPv6)" in Finnish.
assert.deepEqual(columns.map(column => (column.labelKey || column.label) + (column.labelSuffix || '')),
['event-ipv4', 'location', 'event-ipv6', 'location (IPv6)']);
assert.ok(columns.every(column => column.labelKey), 'negative: no header is untranslated English');
const v4 = { ipv4: '203.0.113.4', location: { country: 'FI', city: 'Helsinki',
latitude: 60.17, longitude: 24.94 } };
assert.deepEqual(columns.map(column => column.value(v4)),
['203.0.113.4', 'Helsinki, FI', '', '']);
assert.equal(columns[1].flag(v4), '🇫🇮');
assert.equal(columns[3].flag(v4), '');
assert.deepEqual(columns[1].location(v4),
{ latitude: 60.17, longitude: 24.94, label: 'Helsinki, FI' });
assert.equal(columns[3].location(v4), null);
const v6 = { ipv6: '2001:db8::4', location: { country: 'SE', city: 'Stockholm' } };
assert.deepEqual(columns.map(column => column.value(v6)),
['', '', '2001:db8::4', 'Stockholm, SE']);
assert.equal(columns[1].flag(v6), '');
assert.equal(columns[3].flag(v6), '🇸🇪');
const dual = { ipv4: '203.0.113.5', ipv6: '2001:db8::5',
ipv4Location: { country: 'FI', city: 'Turku' },
ipv6Location: { country: 'SE', city: 'Uppsala' } };
assert.deepEqual(columns.map(column => column.value(dual)),
['203.0.113.5', 'Turku, FI', '2001:db8::5', 'Uppsala, SE']);
assert.equal(columns[1].flag(dual), '🇫🇮');
assert.equal(columns[3].flag(dual), '🇸🇪');
const old = { ip: '::ffff:203.0.113.9', location: { country: 'GB', city: 'London' } };
assert.deepEqual(columns.map(column => column.value(old)),
['203.0.113.9', 'London, GB', '', '']);
assert.deepEqual(columns.map(column => column.value({ ipv4: '203.0.113.4' })),
['203.0.113.4', '', '', '']);
const read = file => fs.readFileSync(path.join(__dirname, '..', file), 'utf8');
const admin = read('client/components/settings/adminProblems.js');
const people = read('client/components/settings/peopleBody.js');
assert.equal((admin.match(/\.\.\.addressReportColumns\(\)/g) || []).length, 3,
'API, event and Recovery tables use the same four columns');
assert.match(admin, /\.\.\.addressReportColumns\(\{ map: true \}\)/,
'Offices keeps map links for its location cells');
assert.match(people, /\.\.\.addressReportColumns\(\)/,
'People login locations use the same four columns');
console.log('Address report columns: four-column order, IPv4/IPv6 attribution, legacy IP, empty location and all report wiring pass.');