fix(shipwrecks): small row and query fixes: era counts in one pass, pickers list only years with a wreck, no Portuguese default

- The legend counted each era twice, scanning every record eight times per
  row refresh; it now counts once.
- Each year picker listed every year from the oldest dated wreck (well over
  a thousand entries); it lists the years that have a wreck, plus the chosen
  ends.
- Labels fell back to Portuguese and links to Portuguese Wikipedia while the
  app ships 11 locales: labels now fall back through the app's languages
  after English, and a wreck with no English article links its Wikidata
  item, which lists the article in every language.
This commit is contained in:
Sameh Khamis committed 2026-11-10 13:29:25 -08:00
1 parent 38cf1e2be5
commit 0c159186f9
5 files changed
+71 -17

No files matched your search

+36
View File
@@ -208,3 +208,39 @@ test('a click opens the card; a period that excludes the wreck closes it', async
);
assert.equal(h.layer.getStats().count, 1);
});
test('the year pickers list only years with a wreck, and each era is counted', async () => {
const h = harness({
snapshots: [
snapshot([
wreck('a', { year: 300 }),
wreck('b', { year: 1912 }),
wreck('c', { year: 1912 }),
wreck('d', { year: 1990 }),
wreck('e', { year: null }),
]),
],
});
h.layer.enable();
await h.layer.update();
let controls = h.layer.getRowControls();
assert.deepEqual(
controls.range.options.map((option) => option.value),
[1990, 1912, 300],
);
assert.deepEqual(
controls.legend.map((era) => era.count),
[1, 2, 1, 1],
);
h.layer.setParams({ from: 1900, to: 1950 });
controls = h.layer.getRowControls();
assert.deepEqual(
controls.range.options.map((option) => option.value),
[1990, 1950, 1912, 1900, 300],
'the chosen ends are listed too',
);
assert.deepEqual(
controls.legend.map((era) => era.count),
[0, 2, 0, 0],
);
});