Weekly puzzle: tests, CHANGELOG, architecture and deploy notes

This commit is contained in:
Frederic Jung 2026-10-28 20:50:17 +01:00
parent 2ac9143db9
commit 587d50decf
No known key found for this signature in database
5 changed files with 284 additions and 1 deletions

View file

@ -40,6 +40,14 @@ publishes the GitHub release and starts `release.yml`: test, `REQUIRE_NOTES=1 np
`pages: write`. Pushes to `main` and pull requests build but never deploy. The `release` skill has the
steps.
**The one exception: the weekly puzzle.** Every Sunday at 03:37 UTC `weekly-puzzle.yml` commits the new
`site/puzzles/weekly/<key>.json` to `main` (data only, no version bump) and starts `release.yml` for the **live
release tag** with `weekly=true`. That run rebuilds exactly the live release, with every weekly file from `main`
added, checks them with `scripts/weekly-puzzle.js --check`, and deploys it in the same `pages` concurrency group.
Players get no update banner (the version does not change). Every release build also copies all weekly files from
`main`, so a release never drops a published week. Weekly files are plain JSON the game fetches only when the
Puzzles list opens and never trusts; the service worker serves them network-first. See `docs/ARCHITECTURE.md`.
## Before you hand back a change that touches the build, deploy or loading
```bash

View file

@ -12,6 +12,15 @@ that version's CHANGELOG section as notes, and dispatches `release.yml`, which b
to GitHub Pages (https://seriesoftub.es). GitHub Pages is the only host, ever: see the
`github-pages` skill.
## Weekly puzzles are not releases
`weekly-puzzle.yml` publishes a new puzzle every Sunday morning without a release: it commits the JSON under
`site/puzzles/weekly/` to `main` and redeploys the live tag through `release.yml` (`weekly=true`). Never bump the
version for a weekly puzzle. To publish or fix one by hand: `node scripts/weekly-puzzle.js --key 2026-W45 --force`,
`node scripts/weekly-puzzle.js --check`, commit to `main`, then run the "Weekly puzzle" workflow (or
`gh workflow run release.yml --ref <live tag> -f tag=<live tag> -f weekly=true`). A release includes every weekly
file on `main` when it builds.
## Only release when Frederic says so
Never bump the version on your own. Finished work is committed and pushed with its

View file

@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
- A new weekly puzzle every Sunday morning, the same for everyone: a themed puzzle such as an ocean crossing, a ring, a latency sprint, island hopping or a detour around a busy hub, with its own name and a budget tuned so three stars take a smart design. The Puzzles door says "New this Sunday!" until you have played it, the list counts down to the next one, and your streak and share line use the week's name. A new puzzle week starts on Sunday at 06:00 Berlin time; offline, the game still has a weekly puzzle of its own.
- A new start screen with four doors: Puzzles, Sandbox, Normal, and Scenarios & weekly. Every network now picks its rules when it starts, and they stay locked for that network; your saved games carry on exactly as before.
- Normal comes in three flavours. Change Freeze has a third of the outages and no DDoS floods, delivers PNIs, cross-connects and builds in days instead of months (#151), and skips the peering inbox, hardware shortages and sold-out routes. On-call is the classic game. BGP at 3 a.m. brings almost twice the outages, lasting half as long again, and twice the DDoS. The HUD and the share card show which one you picked.
- Sandbox is a real sandbox now (#188): everything is unlocked from day one, your own subsea cable included, money never runs out, deliveries are quick, and you pick how much chaos you want, from none to spicy.

View file

@ -29,7 +29,7 @@ hoisted across files, and top-level statements run in path order. Find code by n
| `30-networks/` | Other ASes (`NETS`), rival exchanges (`XIX`), the long tail, traffic shares (`NSH`) |
| `40-progress/` | Customer types (`BIZ_T`), `LEVELS` and their requirements, `GOALS`; the per-save ruleset (`S.rules`, `rule()`, `PRESETS`, `chaosMul()`, `leadDays()`) |
| `50-state.js` | The globals `S`, `R`, `UI`; `emptyR()` |
| `60-features/` | Banks and loans, scenarios and the weekly challenge, conferences, the tutorial, traceroute, the share card, `newGame()`, the offer trial (`autoOffer()`), standing orders (`S.ops`, `opsDay()`, run from `dayTick()`) |
| `60-features/` | Banks and loans, scenarios and the weekly challenge, puzzles and the published weekly puzzle, conferences, the tutorial, traceroute, the share card, `newGame()`, the offer trial (`autoOffer()`), standing orders (`S.ops`, `opsDay()`, run from `dayTick()`) |
| `70-rules/` | Formatting helpers and market rules: exchanges, PNIs, the peering inbox, peering policy and snubs, DE-KICKS, sold-out routes, hot ports and the Tier 1/2/3 rank |
| `80-simulation/` | Dijkstra, RouteScript, `compute()`, monthly prices, `sanitize()`/`migrate()`, customer requirements, events, geography pricing and latency, second sites and service |
| `85-incidents/` | `addInc()`, DDoS and scrubbing, `fireFailure()`, `clearInc()`, `fireEvent()` |
@ -72,6 +72,8 @@ Development runs on `npm run dev` (assembles on every request, reloads on save);
| `.github/workflows/ci.yml` | Tests and build on every push and PR |
| `.github/workflows/auto-release.yml` | On a `package.json` version bump on `main`: test, tag, GitHub release from the CHANGELOG, start the deploy |
| `.github/workflows/release.yml` | Builds and deploys to GitHub Pages, the only workflow that can |
| `.github/workflows/weekly-puzzle.yml` | Sunday 03:37 UTC: makes the week's puzzle, commits it to `main` (data only, no release) and starts `release.yml` for the live release tag with `weekly=true` |
| `scripts/weekly-puzzle.js`, `site/puzzles/weekly/` | The weekly puzzle generator and its output, one `<key>.json` per week plus `index.json` (see below) |
| `docs/adr/` | Decisions: GitHub Pages only (0001), one page assembled at build (0002), translations by label (0003) |
## Globals
@ -146,6 +148,32 @@ Served share per city (`sfOf`) drives eyeball revenue and customer mood.
- The map is a canvas drawn every frame by `draw()`. Zoomed out (`lodFar()`) it uses
a simplified style; parallel waves are grouped by `linkGroups()`.
## The weekly puzzle
A puzzle week runs from Sunday 06:00 Berlin time to the next Sunday 06:00, and is named after the ISO week of
its Monday (the week starting Sunday 1 November 2026 is `2026-W45`); `pzWeekKey()` and `pzWeekStart()` in
`src/game/60-features/93-puzzles-weekly.js` handle summer time and the year boundary.
Every Sunday `weekly-puzzle.yml` runs `scripts/weekly-puzzle.js`, which loads the real game headless, picks a
theme the last three weeks did not have (region tour, ring, detour around a hub, ocean crossing, island hopping,
latency sprint) and cities the last four weeks did not use, and searches for the cheapest build that connects
them and the cheapest one that survives any single cut (a whole cable, or a trench). The budget sits just above
that N-1 build and, where there is room, below the obvious "second path along every hop", so three stars take
some thought. Both reference builds are then played through the game's own actions and must earn one and three
stars, or the puzzle is thrown away. The file holds only ids, numbers and translation labels with their fill-ins
(`{"v":1,"key","theme","cities","via","avoid","budget","twist","name":{"l","p"},"joke":{"l","p"},"ref"}`).
`--check` re-validates every file the way the game does.
The game fetches `puzzles/weekly/<key>.json` (relative, same origin) only when the Puzzles list opens, and checks
it field by field (`pzWkValid()`): known fields, playable cities, labels from the theme's own list, sane numbers.
When it is missing, offline or wrong, the seeded weekly (`pzWeekly()`) stands in, so the weekly puzzle always
works. The service worker fetches these files network-first and keeps a copy for offline play.
The weekly ships without a release: the workflow commits only `site/puzzles/weekly/` to `main` (no version bump,
so `auto-release.yml` stays quiet) and starts `release.yml` from the live release's tag with `weekly=true`, which
rebuilds that exact release with every weekly file from `main` and deploys it. Every release build takes the
weekly files from `main` too, so no deploy ever drops a published week.
## Saves, imports and migration
- `save()` writes `S` to localStorage every few seconds and after actions.

237
tests/weekly-puzzle.test.js Normal file
View file

@ -0,0 +1,237 @@
// The published weekly puzzle: Sunday 06:00 Berlin weeks, the generator (scripts/weekly-puzzle.js), its --check,
// and the game's fetch: only when Puzzles opens, validated strictly, with the seeded weekly as the fallback.
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const { load } = require('./harness');
const G = require('../scripts/weekly-puzzle');
const DIR = path.join(__dirname, '..', 'site', 'puzzles', 'weekly');
const tmp = () => fs.mkdtempSync(path.join(os.tmpdir(), 'tubes-weekly-'));
const committed = () => G.list(DIR).map((k) => JSON.parse(fs.readFileSync(path.join(DIR, k + '.json'), 'utf8')));
const tick = () => new Promise((r) => setTimeout(r, 30));
test('weeks start Sunday 06:00 Berlin, in winter and in summer, and keys run across New Year', () => {
const { ev, errors } = load();
const key = (iso) => ev(`pzWeekKey(new Date('${iso}'))`), start = (k) => ev(`new Date(pzWeekStart('${k}')).toISOString()`);
// Winter (CET, UTC+1): 06:00 Berlin is 05:00 UTC.
assert.equal(key('2026-11-01T04:59:59Z'), '2026-W44');
assert.equal(key('2026-11-01T05:00:00Z'), '2026-W45', 'the week starting Sunday 1 Nov is named after its Monday');
assert.equal(key('2026-11-07T23:00:00Z'), '2026-W45', 'Saturday night is still the same week');
assert.equal(start('2026-W45'), '2026-11-01T05:00:00.000Z');
// Summer (CEST, UTC+2): 06:00 Berlin is 04:00 UTC.
assert.equal(key('2026-07-05T03:59:00Z'), '2026-W27');
assert.equal(key('2026-07-05T04:00:00Z'), '2026-W28');
// The weekends the clocks change: the change is at 01:00 UTC that same Sunday, before the week starts.
assert.equal(start('2026-W14'), '2026-03-29T04:00:00.000Z', 'spring forward: first CEST Sunday');
assert.equal(start('2026-W13'), '2026-03-22T05:00:00.000Z');
assert.equal(start('2026-W44'), '2026-10-25T05:00:00.000Z', 'fall back: first CET Sunday');
assert.equal(start('2026-W43'), '2026-10-18T04:00:00.000Z');
assert.equal(key('2026-03-29T03:59:00Z'), '2026-W13');
assert.equal(key('2026-03-29T04:00:00Z'), '2026-W14');
assert.equal(key('2026-10-25T04:59:00Z'), '2026-W43');
assert.equal(key('2026-10-25T05:00:00Z'), '2026-W44');
// New Year: 2026 has 53 ISO weeks, 2027 has 52.
assert.equal(key('2026-12-27T05:00:00Z'), '2026-W53');
assert.equal(key('2027-01-03T04:59:00Z'), '2026-W53');
assert.equal(key('2027-01-03T05:00:00Z'), '2027-W01');
assert.equal(key('2027-12-26T05:00:00Z'), '2027-W52');
assert.equal(key('2028-01-02T05:00:00Z'), '2028-W01');
assert.equal(ev("pzKeyAdd('2026-W53',1)"), '2027-W01');
assert.equal(ev("pzPrevKey('2027-W01')"), '2026-W53');
assert.equal(ev("pzPrevKey('2028-W01')"), '2027-W52');
assert.equal(ev("pzWeekStart('2027-W53')"), null, '2027 has no week 53');
assert.equal(ev("pzWeekStart('2026-W00')"), null);
assert.equal(ev("pzWeekStart('nope')"), null);
// Every week of ten years: 7 days apart (give or take the DST hour), keys round-trip, never two Sundays the same key.
let k = '2026-W01', seen = new Set();
for (let i = 0; i < 522; i++) {
const t = ev(`pzWeekStart('${k}')`), n = ev(`pzKeyAdd('${k}',1)`), tn = ev(`pzWeekStart('${n}')`);
assert.equal(new Date(t).getUTCDay(), 0, `${k} starts on a Sunday`);
assert.ok([7 * 864e5, 7 * 864e5 - 3600e3, 7 * 864e5 + 3600e3].includes(tn - t), `${k} → ${n}`);
assert.equal(ev(`pzWeekKey(${t})`), k);
assert.equal(ev(`pzWeekKey(${t - 1})`), ev(`pzPrevKey('${k}')`));
assert.ok(!seen.has(k)); seen.add(k); k = n;
}
// The countdown.
assert.equal(ev("pzWkNext(Date.parse('2026-10-29T14:00:00Z'))"), 'Next weekly puzzle in 2 d 15 h');
assert.equal(ev("pzWkNext(Date.parse('2026-11-01T03:20:00Z'))"), 'Next weekly puzzle in 1 h 40 min');
assert.deepEqual(errors, []);
});
test('generator: deterministic for a week, and the committed weeks are what it makes', () => {
const g = G.game(), a = tmp(), b = tmp();
const first = G.list(DIR)[0];
const keys = G.list(DIR).length;
for (const d of [a, b]) for (let i = 0; i < keys; i++) G.writeWeek(d, G.generate(g, g.ev(`pzKeyAdd('${first}',${i})`), d));
for (const k of G.list(a)) {
assert.equal(fs.readFileSync(path.join(a, k + '.json'), 'utf8'), fs.readFileSync(path.join(b, k + '.json'), 'utf8'), `${k} twice the same`);
assert.equal(fs.readFileSync(path.join(a, k + '.json'), 'utf8'), fs.readFileSync(path.join(DIR, k + '.json'), 'utf8'), `${k} as committed`);
}
assert.ok(keys >= 3, 'the release ships with weeklies in place');
});
test('generator: a quarter of weeks, all verified, varied, small and in the schema', () => {
const g = G.game(), d = tmp();
let k = '2027-W10';
const out = [];
for (let i = 0; i < 12; i++, k = g.ev(`pzKeyAdd('${k}',1)`)) { const j = G.generate(g, k, d); G.writeWeek(d, j); out.push(j); }
assert.deepEqual(G.check(g, d, 0), [], 'every week verifies: both references earn their stars in the game');
for (let i = 1; i < out.length; i++) {
assert.notEqual(out[i].theme, out[i - 1].theme, `${out[i].key}: not last week's theme`);
for (const c of out[i].cities) assert.ok(!out[i - 1].cities.includes(c), `${out[i].key}: ${c} was a city last week too`);
}
assert.ok(new Set(out.map((j) => j.theme)).size >= 5, 'most themes come round in a quarter');
for (const j of out) {
assert.ok(j.cities.length >= 3 && j.cities.length <= 6);
assert.ok(j.ref.one <= j.ref.three && j.ref.three <= j.budget && j.budget <= j.ref.three * 1.06 + 10000, `${j.key}: budget ${j.budget} just above the N-1 build ${j.ref.three}`);
assert.ok(JSON.stringify(j).length < 600, 'small file');
assert.deepEqual(Object.keys(j), ['v', 'key', 'theme', 'cities', 'via', 'avoid', 'budget', 'twist', 'name', 'joke', 'ref']);
}
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(d, 'index.json'), 'utf8')).weeks, out.map((j) => j.key));
});
test('--check passes on the committed files and rejects tampered ones', () => {
const g = G.game();
assert.deepEqual(G.check(g, DIR, 0), [], 'committed weeklies verify');
const bad = (edit, why) => {
const d = tmp();
for (const f of fs.readdirSync(DIR)) fs.copyFileSync(path.join(DIR, f), path.join(d, f));
const k = G.list(d)[0], f = path.join(d, k + '.json'), j = JSON.parse(fs.readFileSync(f, 'utf8'));
const r = edit(j, d, k); fs.writeFileSync(f, typeof r === 'string' ? r : JSON.stringify(j));
assert.notDeepEqual(G.check(g, d, 0), [], why);
};
bad((j) => { j.budget = Math.floor(j.ref.three * 0.8 / 10000) * 10000; j.ref.three = j.budget - 1; }, 'a budget nobody can earn three stars under');
bad((j) => { j.cities[0] = 'xxx'; }, 'an unknown city');
bad((j) => { j.name.l = 'puzzles.hello_world'; }, 'a label that is not a weekly name');
bad((j) => { j.joke.p = { hub: 'fra' }; }, 'parameters the label does not take');
bad((j) => { j.extra = '<img src=x onerror=alert(1)>'; }, 'an unknown field');
bad((j) => { j.key = '2030-W01'; }, 'a file under another week\'s name');
bad((j) => { j.twist = { lat: [j.cities[0], j.cities[1], 0.5] }; }, 'an impossible latency target');
bad(() => '{nope', 'not JSON');
bad((j, d) => { fs.writeFileSync(path.join(d, 'index.json'), '{"v":1,"weeks":[]}'); }, 'an index that misses weeks');
});
test('the page never asks for a weekly puzzle on load, only when Puzzles opens', async () => {
const { ev, errors } = load();
ev("window.__f=[];window.fetch=(u,o)=>{__f.push(String(u));return Promise.resolve({ok:false,json:()=>Promise.reject()})}");
ev("showTitle();for(let i=0;i<5;i++)frame(performance.now()+i*1000);renderAll()");
assert.equal(ev("__f.filter(u=>/puzzles/.test(u)).length"), 0, 'nothing on the title screen');
assert.equal(ev("UI.pzWk===undefined"), true);
ev("ACT.start({});for(let i=0;i<3;i++)dayTick();renderAll()");
assert.equal(ev("__f.filter(u=>/puzzles/.test(u)).length"), 0, 'nothing while playing');
ev('ACT.puzzleMenu({})');
const key = ev('pzWeekKey(new Date())');
assert.deepEqual(ev("JSON.stringify(__f.filter(u=>/puzzles/.test(u)))"), JSON.stringify([`puzzles/weekly/${key}.json`]), 'one relative, same-origin request');
ev('closeModal();ACT.puzzleMenu({})');
assert.equal(ev("__f.filter(u=>/puzzles/.test(u)).length"), 1, 'once is enough while it is loading');
await tick();
assert.deepEqual(errors, []);
});
test('the published puzzle is played when it is good, the seeded one when it is missing, offline or bad', async () => {
const src = committed()[1], { ev, dom, errors } = load();
const key = ev('pzWeekKey(new Date())'), good = { ...src, key };
const serve = (how) => { ev(`UI.pzWk=null;window.fetch=()=>${how}`); ev('ACT.puzzleMenu({})'); };
const seeded = JSON.parse(ev('JSON.stringify(pzWeekly())'));
for (const [how, why] of [
["Promise.resolve({ok:false,status:404,json:()=>Promise.reject()})", 'missing'],
["Promise.reject(new TypeError('offline'))", 'offline'],
["Promise.resolve({ok:true,json:()=>Promise.reject(new SyntaxError('x'))})", 'not JSON'],
[`Promise.resolve({ok:true,json:()=>Promise.resolve(${JSON.stringify({ ...good, cities: ['fra', 'nope', 'ams'] })})})`, 'an unknown city'],
[`Promise.resolve({ok:true,json:()=>Promise.resolve(${JSON.stringify({ ...good, key: '2020-W01' })})})`, 'another week'],
]) {
serve(how);
await tick();
assert.equal(ev('UI.pzWk.st'), 'fb', why);
assert.deepEqual(JSON.parse(ev('JSON.stringify(pzWkDef().cities)')), seeded.cities, `${why}: the seeded weekly stands in`);
assert.match(ev("document.getElementById('pzWk').textContent"), new RegExp(`Weekly puzzle ${key}`));
assert.equal(ev("document.querySelector('#pzWk [data-act=pzWeekly]').disabled"), false);
}
// While it loads, the button waits a moment.
ev("UI.pzWk=null;window.fetch=()=>new Promise(()=>{})");
ev('ACT.puzzleMenu({})');
assert.match(ev("document.getElementById('pzWk').textContent"), /Loading this week/);
assert.equal(ev("document.querySelector('#pzWk [data-act=pzWeekly]').disabled"), true);
// The good one.
serve(`Promise.resolve({ok:true,json:()=>Promise.resolve(${JSON.stringify(good)})})`);
await tick();
assert.equal(ev('UI.pzWk.st'), 'ok');
const row = ev("document.getElementById('pzWk').textContent");
assert.ok(row.includes(ev('pzName(pzWkDef())')), 'its pun name');
assert.ok(row.includes(ev('pzTxt(pzWkDef().wj)')), 'its joke');
assert.match(row, /New this Sunday!/);
assert.match(row, /Next weekly puzzle in \d+ (d \d+ h|h \d+ min)/);
ev("document.querySelector('#pzWk [data-act=pzWeekly]').click()");
assert.equal(ev('S.pz.key'), key);
assert.deepEqual(JSON.parse(ev('JSON.stringify(S.pz.cities)')), good.cities);
assert.equal(ev('S.pz.budget'), good.budget);
assert.match(ev("document.getElementById('pzBox').textContent"), new RegExp(ev('pzTxt(S.pz.wj)').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
// Solve it with three stars: the share line and the streak use the published key.
const sol = G.solve(G.world(ev), { cities: good.cities, via: good.via, avoid: good.avoid, ring: !!good.twist.ring, noSub: false, lat: good.twist.lat || null }).three;
for (const l of sol.links) {
if (!ev(`!!S.pops['${l.a}']`)) ev(`ACT.pzPop({city:'${l.a}'})`);
ev(`ACT.pzLinkTo({a:'${l.a}',b:'${l.b}'});ACT.pzVia({v:'${l.via}'});ACT.pzDiv({v:1});ACT.pzLink({tier:0})`);
}
assert.equal(ev('pzEval().stars'), 3);
assert.match(ev('pzShareText(pzEval())'), new RegExp(`^Series of Tubes puzzle ${key} ⭐⭐⭐ \\$[\\d.]+[kM] · seriesoftub\\.es$`));
const p = JSON.parse(ev("localStorage.getItem('sot-puzzles')"));
assert.equal(p.wk[key].st, 3);
assert.equal(p.streak.last, key);
ev('ACT.pzLeave({})');
assert.doesNotMatch(ev("document.querySelector('.door[data-door=puzzle]').textContent"), /New this Sunday/, 'played: no badge');
void dom;
assert.deepEqual(errors, []);
});
test('the file is checked field by field', () => {
const { ev, errors } = load();
const j = committed()[0], k = j.key, ok = (o) => ev(`!!pzWkValid(${JSON.stringify(o)},'${k}')`);
assert.ok(ok(j));
const no = (edit, why) => { const o = JSON.parse(JSON.stringify(j)); edit(o); assert.equal(ok(o), false, why); };
no((o) => { o.v = 2; }, 'a newer schema');
no((o) => { o.theme = 'constructor'; }, 'an unknown theme');
no((o) => { o.cities = ['fra']; }, 'too few cities');
no((o) => { o.cities = [...o.cities, o.cities[0]]; }, 'a city twice');
no((o) => { o.via = [o.cities[0]]; }, 'a goal city as a stepping stone');
no((o) => { o.cities[0] = 'pek'; }, 'a city that needs a licence');
no((o) => { o.budget = '240000'; }, 'a budget as text');
no((o) => { o.budget = 1e9; }, 'a silly budget');
no((o) => { o.twist = { ring: 'yes' }; }, 'a twist that is not true');
no((o) => { o.twist = { avoidAll: true }; }, 'an unknown twist');
no((o) => { o.name = { l: 'puzzles_weekly.name_tour_de_reg', p: { reg: 'XX' } }; }, 'an unknown region');
no((o) => { o.name = { l: 'puzzles_weekly.name_race_to_b', p: { b: '<b>' } }; }, 'markup as a city');
no((o) => { o.joke = 'Ha ha'; }, 'raw English');
no((o) => { o.__proto__ = { budget: 1 }; o.extra = 1; }, 'extra fields');
assert.equal(ev(`pzWkValid(null,'${k}')`), null);
assert.equal(ev(`pzWkValid([],'${k}')`), null);
// Every label a theme may use exists in English, and every file names its text in the player's language.
assert.ok(ev("Object.values(PZ_WK_THEMES).every(T=>[T.t,...T.names,...T.jokes].every(l=>typeof EN[l]==='string'))"));
for (const f of committed()) {
const d = ev(`JSON.stringify(pzWkValid(${JSON.stringify(f)},'${f.key}'))`);
assert.ok(d, f.key);
assert.doesNotMatch(ev(`(d=>pzTxt(d.wn)+' '+pzTxt(d.wj))(${d})`), /\{|puzzles_weekly\./, `${f.key}: filled in`);
}
assert.deepEqual(errors, []);
});
test('weekly puzzle in every language and on a 360 px phone', async () => {
const f = committed()[0];
for (const lang of ['de', 'es', 'fr', 'it', 'pt']) {
const { ev, errors } = load({ lang });
const key = ev('pzWeekKey(new Date())');
ev(`window.fetch=()=>Promise.resolve({ok:true,json:()=>Promise.resolve(${JSON.stringify({ ...f, key })})})`);
ev("innerWidth=360;innerHeight=740;dispatchEvent(new Event('resize'));showTitle()");
ev('ACT.puzzleMenu({})');
await tick();
const row = ev("document.getElementById('pzWk').textContent");
assert.doesNotMatch(row, /puzzles(_weekly)?\.|\{/, `${lang}: no raw labels or placeholders`);
assert.notEqual(ev('pzName(pzWkDef())'), ev("EN[pzWkDef().wn.l]"), `${lang}: translated name`);
ev("document.querySelector('#pzWk [data-act=pzWeekly]').click()");
assert.equal(ev("document.getElementById('pzBox').hidden"), false);
assert.doesNotMatch(ev("document.getElementById('pzBox').textContent"), /puzzles(_weekly)?\./);
assert.deepEqual(errors, [], lang);
}
});