diff --git a/CHANGELOG.md b/CHANGELOG.md index 4caa1ff..2e84c98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ All notable changes to this project are documented here. The project follows Vultures, the Loan Shark and more) make offers with odd conditions. Offers come faster when you are in the red, so a bad hour no longer has to end in bankruptcy. Credit ratings, penalties for broken conditions, early repayment. +- Your game now saves every few seconds and whenever you leave the page, and a + reload drops you straight back into your network. +- Release announcements: a "What's new" card after an update, and a banner with + a one-click reload when a new version comes out while you are playing. +- Start a new network any time from the help screen. ## [1.1.0] — 2026-10-23 diff --git a/README.md b/README.md index f29d683..8dcada4 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ Only published releases reach [seriesoftub.es](https://seriesoftub.es). Pushes t `main` run CI and nothing else. 1. Bump `version` in `package.json` (semver) and add a `CHANGELOG.md` entry. + Write the bullets for players: the build turns that section into the in-game + "What's new" card and into `/version.json`, which open games poll to offer a reload. 2. Merge to `main`. 3. Publish a GitHub release tagged `v`, e.g. `gh release create v1.1.0 --generate-notes`. diff --git a/package.json b/package.json index afd85a1..1a9940f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "homepage": "https://seriesoftub.es/", "repository": { "type": "git", "url": "git+https://github.com/fjaeckel/seriesoftubes.git" }, "scripts": { - "test": "node --test tests/game.test.js tests/build.test.js", + "test": "node --test --test-concurrency=1 tests/game.test.js tests/build.test.js tests/persist.test.js", "build": "bash scripts/build.sh", "serve": "npm run build && npx --yes serve@14.2.4 _site" }, diff --git a/scripts/build.sh b/scripts/build.sh index aec1eab..15acf88 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -14,6 +14,16 @@ for f in _site/index.html _site/sitemap.xml _site/llms.txt; do rm -f "$f.bak" done +# Release notes for this version, baked into the page ("What's new") and +# published as version.json so open games can spot a newer release. +NOTES="$(node scripts/release-notes.js "$VERSION")" +node -e ' + const fs=require("fs"),[,v,d,notes]=process.argv; + const f="_site/index.html"; + fs.writeFileSync(f,fs.readFileSync(f,"utf8").replace("/*__RELEASE_NOTES__*/[]",notes)); + fs.writeFileSync("_site/version.json",JSON.stringify({version:v,date:d,notes:JSON.parse(notes)},null,2)+"\n"); +' "$VERSION" "$BUILD_DATE" "$NOTES" + if grep -rl "__VERSION__\|__BUILD_DATE__" _site >/dev/null; then echo "error: unreplaced placeholders left in _site" >&2 exit 1 diff --git a/scripts/release-notes.js b/scripts/release-notes.js new file mode 100644 index 0000000..caab9dd --- /dev/null +++ b/scripts/release-notes.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node +// Prints the CHANGELOG.md bullets for one version as a JSON array of strings. +// Usage: node scripts/release-notes.js 1.2.0 +const fs = require('node:fs'); +const path = require('node:path'); + +const version = process.argv[2]; +const text = fs.readFileSync(path.join(__dirname, '..', 'CHANGELOG.md'), 'utf8'); +const lines = text.split('\n'); +const start = lines.findIndex((l) => l.startsWith(`## [${version}]`)); +const notes = []; +if (start >= 0) { + for (let i = start + 1; i < lines.length && !lines[i].startsWith('## ['); i++) { + const l = lines[i]; + if (/^\s*-\s+/.test(l)) notes.push(l.replace(/^\s*-\s+/, '').trim()); + else if (/^\s{2,}\S/.test(l) && notes.length) notes[notes.length - 1] += ' ' + l.trim(); + } +} +process.stdout.write(JSON.stringify(notes)); diff --git a/site/index.html b/site/index.html index f55392c..e52185d 100644 --- a/site/index.html +++ b/site/index.html @@ -222,6 +222,10 @@ section h3{font-size:17px;margin-bottom:6px;display:flex;align-items:center;gap: #hint{position:fixed;left:50%;transform:translateX(-50%);top:calc(env(safe-area-inset-top,0px) + 76px);background:var(--ink);color:#fff;border-radius:12px;padding:6px 12px;font-weight:800;font-size:12.5px;z-index:3;pointer-events:none;max-width:min(440px,calc(100% - 32px));text-align:center;box-shadow:3px 3px 0 rgba(30,38,64,.25)} /* modal */ +#update{position:fixed;left:50%;transform:translateX(-50%);top:calc(env(safe-area-inset-top,0px) + 70px);z-index:18;width:min(520px,calc(100% - 24px));pointer-events:auto} +#update .b{pointer-events:auto} +.notes{margin:10px 0 0;padding-left:20px;line-height:1.5} +.notes li{margin:4px 0} #bankBox{position:fixed;inset:0;background:rgba(30,38,64,.35);z-index:16;overflow:auto;padding:calc(env(safe-area-inset-top,0px) + 12px) max(12px,env(safe-area-inset-right,0px)) 16px max(12px,env(safe-area-inset-left,0px))} #bankCard{max-width:760px;margin:0 auto;padding:16px 18px 18px;background:var(--paper)} .cashbtn{cursor:pointer;text-align:left;font:inherit;color:inherit;position:relative} @@ -355,6 +359,7 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
+ @@ -365,6 +370,9 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi Off unless ANALYTICS.host is set. Fill in your collector when you self-host the game. Inside the claude.ai viewer outside requests are blocked, so it only reports from your own domain. */ const APP_VERSION='__VERSION__'; +// Filled in by scripts/build.sh from CHANGELOG.md for this version. +const RELEASE_NOTES=/*__RELEASE_NOTES__*/[]; +const IS_DEV=APP_VERSION.startsWith('__'); // Only report from the real site; previews, localhost and the Claude viewer stay silent. const ANALYTICS={host:/(^|\.)seriesoftub\.es$/.test(location.hostname)?'https://stats.seriesoftub.es':'',site:'seriesoftub.es'}; (function(){ @@ -1298,6 +1306,10 @@ const ACT={ cont:()=>{migrate(S);track('game_continue',true);UI.started=true;closeModal();renderAll();}, newgame:()=>{try{localStorage.removeItem('sot-save-v1');}catch(e){}S=null;UI.started=false;UI.sel=null;$('dash').hidden=true;$('bankBox').hidden=true;renderAll();showTitle();}, keepPlaying:()=>{closeModal();}, + resetAsk:()=>openModal(`

Start a new network?

${esc(S?S.name:'Your network')} and everything it owns will be deleted. This cannot be undone.

${btn('Delete and start over','newgame',{},'red big')}${btn('Keep playing','closeModal',{},'ghost big')}
`), + whatsNewShow:()=>whatsNew(true,true), + updateNow:()=>{save();location.reload();}, + updateLater:()=>{$('update').hidden=true;UI.updLater=Date.now();}, helpClose:()=>{if(UI.started)closeModal();else showTitle();}, }; function pairLinks(a,b){return S.links.filter(l=>(l.a===a&&l.b===b)||(l.a===b&&l.b===a));} @@ -1311,7 +1323,10 @@ function after(){if(S)purgeInc();compute();checkGoals();renderAll();save();} function selectCity(c){UI.sel={type:'city',id:c};UI.confirm=null;if(!S.pops[c])UI.tab='cust';renderPanel();} /* ================= SAVE ================= */ -function save(){if(!S||S.lost)return;try{localStorage.setItem('sot-save-v1',JSON.stringify(S));}catch(e){}} +function save(){if(!S||S.lost)return;S.uiSpeed=UI.speed;S.cam={x:cam.x,y:cam.y,z:cam.z};try{localStorage.setItem('sot-save-v1',JSON.stringify(S));}catch(e){}UI.lastSave=performance.now();} +// Save whenever the player might be leaving: tab hidden, page closing or reloading. +addEventListener('pagehide',()=>save()); +document.addEventListener('visibilitychange',()=>{if(document.visibilityState==='hidden')save();else checkUpdate();}); function loadSave(){try{const t=localStorage.getItem('sot-save-v1');if(t){const s=JSON.parse(t);if(s&&s.v===1&&!s.lost)return s;}}catch(e){}return null;} /* ================= AUDIO ================= */ @@ -1661,6 +1676,25 @@ function showTitle(){
${btn(sv?'Start a new network':'Start building','start',{},'big')}${btn('How to play','help',{},'ghost')}

v${APP_VERSION} · Source on GitHub · Cookieless stats, no tracking

`); if(sv){S=migrate(sv);compute();} } +// "What's new": shown once to returning players after an update, or on demand. +function whatsNew(returning,force){ + if(IS_DEV||!RELEASE_NOTES.length)return false;let seen=null; + try{seen=localStorage.getItem('sot-seen-version');localStorage.setItem('sot-seen-version',APP_VERSION);}catch(e){} + if(!force&&(!returning||seen===APP_VERSION))return false; + openModal(`
Release notes

New in Series of Tubes ${esc(APP_VERSION)}

+ + ${returning&&S?`

Your network ${esc(S.name)} was saved and is waiting for you.

`:''} +
${btn(UI.started?'Back to my network':'Got it',UI.started?'closeModal':'helpClose',{},'pink big')}Full changelog
`); + return true;} +function newerVer(a,b){const x=String(a).split('.').map(Number),y=String(b).split('.').map(Number);for(let i=0;i<3;i++){if((x[i]||0)>(y[i]||0))return true;if((x[i]||0)<(y[i]||0))return false;}return false;} +// While the game is open, look for a newer release now and then and offer a reload. +function checkUpdate(){ + if(IS_DEV||location.protocol==='file:'||!window.fetch)return;const now=Date.now();if(now-(UI.updChecked||0)<60000)return;UI.updChecked=now; + fetch('/version.json',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(j=>{ + if(!j||!j.version||!newerVer(j.version,APP_VERSION))return;if(UI.updLater&&now-UI.updLater<6*3600*1000)return; + const top=(j.notes||[])[0]||'';$('update').innerHTML=`
Series of Tubes ${esc(j.version)} is out!${top?`
${esc(top.length>120?top.slice(0,117)+'…':top)}`:''}
Your game is saved automatically.
${btn('Reload now','updateNow',{},'pink sm')}${btn('Later','updateLater',{},'ghost sm')}`;$('update').hidden=false; + }).catch(()=>{}); +} function showHelp(){ openModal(`

How the internet works here

Controls: drag the map to pan, scroll or pinch to zoom, tap a city to open it. Drag from your pink router to another city to lay fiber. Space pauses, 1 2 3 4 set speed. At 1× a day lasts 2.5 seconds.

@@ -1676,7 +1710,7 @@ function showHelp(){
Peering policy
Open peers with anyone. Selective wants to see traffic first. Restrictive (Tier 1s) only peers with giants, over PNIs. Paid means exactly that.
Waves
Your fiber links are leased waves at a flat monthly rate. Longer and bigger costs more (10G → 6.4T), and subsea is 1.8× the price.
95th percentile
Transit bills sample your usage every day and charge the 95th percentile of the last 30 days, so short spikes are forgiven but long ones are not.
Routers
Each POP's router model caps its fastest port (100G, 400G, 800G, 1.6T) and how much it can forward. Bigger waves and ports need better routers at both ends. Better models unlock with your customer level. With one router, upgrades mean a day of downtime.
Dark fiber
Lease an IRU or build your own (slow, with delays), then buy a line system with amplifiers and light channels with 400ZR+, 800ZR+ or 1.6T transponders. Much cheaper than waves at scale, but the gear can fail. A spares kit speeds up repairs.
Subsea cables
Subsea waves can only follow real-ish cable systems, drawn faintly on the map (tap a city to highlight its cables). Teal ones are new and cheap, purple ones pricey, dashed ones old and cut-prone. All your waves on one cable die together when it is cut. Between continents on land, you can often choose overland (2.5×, many borders) or a cable.
Latency
Every link has latency. High-frequency traders pay a fortune for a circuit within their latency budget; route them “Lowest latency”. Bulk backup customers do not care, so route them “Scenic” over your quiet links to keep busy ones free.
NOC dashboard
The chart button at the top opens traffic graphs by exit (caches, PNIs, IX, transit), money over time, per-ASN traffic with how it reaches you and what its transit costs, plus your busiest links and routers.
Asia
A weird, underserved market. Transit costs 2.5× what it does in Europe (Africa 2×, Oceania 1.8×), local incumbents mostly peer only for pay, and IXs are fragmented. But demand is enormous and users sign up 60% faster than anywhere else. Peering and caches pay off most here.
Russia
Moscow needs a mandatory government box in every POP, Western CDNs are mostly gone, Goggle video is throttled to half speed, and the sovereign internet drills now and then cut Moscow off for a day.
Bank
Tap your cash to open the bank. Lenders make offers now and then, and much more often when you are in the red. Each loan has a monthly payment and some odd conditions; break one and you pay a penalty. Your credit rating decides which banks talk to you. The loan shark is always there. Do not be late.
LAGs
Out of port speed? Bundle up to 8 identical ports to the same transit provider, IX or PNI into a LAG. Each member costs a full port; flow hashing is never perfectly even, so a bundle carries about 95% of the sum.
Traffic engineering
Tap a link to see which networks, which entry points and which customer cities fill it. Raise a link's metric to steer traffic around it, or set an egress (transit, IX, PNI) to Prefer or Backup only.
China
Mainland China needs a license and a local joint venture. Many foreign services are blocked there, and traffic crossing the border loses packets unless you pay for premium routes.
Weird requirements
Some customers come with conditions: no Cogentle anywhere, no subsea cables because of sharks, two routers, a generator, NetChill on-net, low-loss China reach and more. Each pays a bonus. Unmet ones make them grumpy until you fix it or they leave.
Customer levels
As your peak traffic and footprint grow, bigger customers show up: streaming startups and universities, then AI GPU data centers and cloud on-ramps, then AI training interconnects and hyperscaler DCI deals measured in terabits. Pink $$ bubbles mark the big ones.
L2VPN & DDoS protection
Businesses may want a private circuit between two of your POPs (it rides your backbone), or DDoS protection (needs your own scrubbing center).
NNI fabrics
Megapork, PocketFabric and Consolation Connect sell a port plus virtual circuits between cities. Great for small links and remote peering at an IX where you have no POP.
Failures
Things break all the time: fiber cuts, router crashes, power cuts, IX loops, fabric outages, route leaks, DDoS, fat fingers, cooling failures, and geopolitics: sanctions, tariffs, BGP hijacks, landing permit disputes, exam-day shutdowns and Red Sea cable cuts. Traffic reroutes automatically over other paths and upstreams. Parallel links on diverse routes, a second router and a backup generator all help. Or pay to rush repairs.
-
${btn(UI.started?'Back to the map':'Got it','helpClose',{},'big')}
`); +
${btn(UI.started?'Back to the map':'Got it','helpClose',{},'big')}${RELEASE_NOTES.length?btn(`What’s new in ${esc(APP_VERSION)}`,'whatsNewShow',{},'ghost'):''}${UI.started&&S&&!S.lost?btn('Start a new network','resetAsk',{},'ghost sm'):''}
`); } function showWin(){openModal(`

You're a Tier 1!

${esc(S.name)} (AS${S.asn}) is transit-free. You peer with every giant on the planet and pay nobody to reach the internet. Took you ${S.day} days and ${S.stats.incidents} incidents.

${btn('Keep building','keepPlaying',{},'pink big')}`);sfx('coin');} function showLose(){openModal(`

Bankrupt

The bank repossessed your routers and sold them on eBuy. ${esc(S.name)} lasted ${S.day} days and peaked at ${fmtG(S.stats.peak)}.

${btn('Try again','newgame',{},'pink big')}`);try{localStorage.removeItem('sot-save-v1');}catch(e){}} @@ -1973,13 +2007,14 @@ addEventListener('keydown',e=>{if(e.target.tagName==='INPUT')return;if(e.code=== let pressing=false; document.addEventListener('pointerdown',e=>{if(e.target.closest('#panel,#left'))pressing=true;}); addEventListener('pointerup',()=>setTimeout(()=>pressing=false,0)); -document.addEventListener('click',e=>{const b=e.target.closest('[data-act]');if(!b||b.disabled)return;audioInit();const fn=ACT[b.dataset.act];if(!fn)return;if(!S&&!['start','pickStart','cont','help','helpClose','newgame','mute','closeModal','speed','bankClose'].includes(b.dataset.act))return;let a={};try{a=JSON.parse(b.dataset.args||'{}');}catch(_){}fn(a);}); +document.addEventListener('click',e=>{const b=e.target.closest('[data-act]');if(!b||b.disabled)return;audioInit();const fn=ACT[b.dataset.act];if(!fn)return;if(!S&&!['start','pickStart','cont','help','helpClose','newgame','mute','closeModal','speed','bankClose','whatsNewShow','updateNow','updateLater'].includes(b.dataset.act))return;let a={};try{a=JSON.parse(b.dataset.args||'{}');}catch(_){}fn(a);}); /* ================= LOOP ================= */ let last=performance.now(),acc=0,hudT=0; function frame(now){ const dt=Math.min(250,now-last);last=now; if(ANALYTICS.host&&S&&!S.lost&&UI.speed&&document.visibilityState==='visible'){UI.playMs=(UI.playMs||0)+dt;const m=UI.playMs/60000;for(const k of PLAY_MARKS)if(m>=k)track('play_'+k+'m',true);} + if(S&&UI.started&&!S.lost&&now-(UI.lastSave||0)>5000)save(); if(S&&!S.lost&&$('modal').hidden&&UI.speed){acc+=dt*UI.speed;let n=0;while(acc>=DAY_MS&&n<4){acc-=DAY_MS;dayTick();n++;} if(n){renderHUD();if(!pressing){renderPanel();renderLeft();if(!$('dash').hidden)renderDash();renderBank();}renderHint();}} draw(now); @@ -1988,10 +2023,14 @@ function frame(now){ function boot(data){ try{UI.muted=localStorage.getItem('sot-mute')==='1';}catch(e){} if(data&&data.S){S=migrate(data.S);UI.started=true;if(data.cam)Object.assign(cam,data.cam);compute();renderAll();} - else showTitle(); + else{const sv=loadSave(); + if(sv){S=migrate(sv);UI.started=true;UI.speed=S.uiSpeed===undefined?1:S.uiSpeed; + if(S.cam&&isFinite(S.cam.x))Object.assign(cam,S.cam);else{const h=CITY[S.home];if(h){cam.x=h.x;cam.y=h.y;cam.z=innerWidth<760?1.1:1.4;}} + compute();renderAll();if(!whatsNew(true))toast(`Welcome back, ${esc(S.name)}.
Your network is right where you left it: ${dateStr(S.day)}.`,'good');} + else{showTitle();whatsNew(false);}} renderHUD();renderLeft(); window.claude?.hot?.snapshot?.(()=>({S:S&&JSON.parse(JSON.stringify(S)),cam:{...cam}})); - if(!window.__TUBES_TEST__)requestAnimationFrame(frame); + if(!window.__TUBES_TEST__){requestAnimationFrame(frame);setTimeout(checkUpdate,4000);setInterval(checkUpdate,10*60*1000);} } window.claude?.hot?.ready ? window.claude.hot.ready(boot) : boot(window.claude?.hot?.data ?? {}); diff --git a/tests/build.test.js b/tests/build.test.js index 3ad58c6..252b97c 100644 --- a/tests/build.test.js +++ b/tests/build.test.js @@ -12,11 +12,19 @@ test('build stamps version and date into the site', () => { assert.match(html, /const APP_VERSION='9\.9\.9'/); assert.match(html, /"softwareVersion": "9\.9\.9"/); assert.match(fs.readFileSync(path.join(root, '_site', 'sitemap.xml'), 'utf8'), /2030-01-01<\/lastmod>/); - for (const f of ['favicon.svg', 'favicon.ico', 'apple-touch-icon.png', 'icon-192.png', 'icon-512.png', 'site.webmanifest', 'robots.txt', 'images/og-image.png', '404.html', 'CNAME']) { + for (const f of ['favicon.svg', 'favicon.ico', 'apple-touch-icon.png', 'icon-192.png', 'icon-512.png', 'site.webmanifest', 'robots.txt', 'images/og-image.png', '404.html', 'CNAME', 'version.json']) { assert.ok(fs.existsSync(path.join(root, '_site', f)), `${f} is shipped`); } }); +test('version.json carries the release notes from the changelog', () => { + execFileSync('bash', ['scripts/build.sh'], { cwd: root, env: { ...process.env, VERSION: '1.0.0', BUILD_DATE: '2026-10-23' } }); + const v = JSON.parse(fs.readFileSync(path.join(root, '_site', 'version.json'), 'utf8')); + assert.equal(v.version, '1.0.0'); + assert.ok(v.notes.length >= 5); + assert.ok(v.notes.every((n) => !n.startsWith('-'))); +}); + test('head carries the SEO and social metadata', () => { const html = fs.readFileSync(path.join(root, 'site', 'index.html'), 'utf8'); for (const needle of ['', 'property="og:image"', 'name="twitter:card"', 'application/ld+json', 'rel="manifest"', 'name="description"']) { diff --git a/tests/harness.js b/tests/harness.js index 2f484a8..69107ba 100644 --- a/tests/harness.js +++ b/tests/harness.js @@ -4,8 +4,9 @@ const fs = require('node:fs'); const path = require('node:path'); const { JSDOM, VirtualConsole } = require('jsdom'); -function load() { - const html = fs.readFileSync(path.join(__dirname, '..', 'site', 'index.html'), 'utf8'); +function load(opts = {}) { + const file = opts.file || path.join(__dirname, '..', 'site', 'index.html'); + const html = fs.readFileSync(file, 'utf8'); const errors = []; const vc = new VirtualConsole(); vc.on('jsdomError', (e) => { @@ -19,6 +20,7 @@ function load() { virtualConsole: vc, beforeParse(window) { window.__TUBES_TEST__ = true; + for (const [k, v] of Object.entries(opts.storage || {})) window.localStorage.setItem(k, v); window.Path2D = class { moveTo() {} quadraticCurveTo() {} closePath() {} }; }, }); diff --git a/tests/persist.test.js b/tests/persist.test.js new file mode 100644 index 0000000..b57b1b5 --- /dev/null +++ b/tests/persist.test.js @@ -0,0 +1,51 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const path = require('node:path'); +const { execFileSync } = require('node:child_process'); +const { load } = require('./harness'); + +const root = path.join(__dirname, '..'); + +function playedGame() { + const a = load(); + a.ev("ACT.start({});ACT.launchBB({city:'fra'});for(let i=0;i<25;i++)dayTick();UI.speed=2;save()"); + return { a, saved: a.ev("localStorage.getItem('sot-save-v1')"), day: a.ev('S.day') }; +} + +test('a reload drops you straight back into your saved network', () => { + const { saved, day } = playedGame(); + const b = load({ storage: { 'sot-save-v1': saved } }); + assert.equal(b.ev('UI.started'), true); + assert.equal(b.ev('S.day'), day); + assert.equal(b.ev('UI.speed'), 2, 'game speed is remembered'); + assert.equal(b.ev("document.getElementById('modal').hidden"), true, 'no title screen in the way'); + assert.deepEqual(b.errors, []); +}); + +test('leaving the page saves the game', () => { + const a = load(); + a.ev("ACT.start({});for(let i=0;i<7;i++)dayTick();localStorage.removeItem('sot-save-v1')"); + a.ev("dispatchEvent(new Event('pagehide'))"); + assert.equal(JSON.parse(a.ev("localStorage.getItem('sot-save-v1')")).day, a.ev('S.day')); +}); + +test('returning players see what is new after an update, once', () => { + const { saved } = playedGame(); + execFileSync('bash', ['scripts/build.sh'], { cwd: root, env: { ...process.env, VERSION: '1.1.0', BUILD_DATE: '2026-10-23' } }); + const file = path.join(root, '_site', 'index.html'); + const b = load({ file, storage: { 'sot-save-v1': saved, 'sot-seen-version': '1.0.0' } }); + const text = b.ev("document.getElementById('modalCard').textContent"); + assert.match(text, /New in Series of Tubes 1\.1\.0/); + assert.match(text, /Spätzle-IX/); + assert.equal(b.ev("localStorage.getItem('sot-seen-version')"), '1.1.0'); + const c = load({ file, storage: { 'sot-save-v1': saved, 'sot-seen-version': '1.1.0' } }); + assert.equal(c.ev("document.getElementById('modal').hidden"), true, 'not shown again'); +}); + +test('version comparison for the update banner', () => { + const { ev } = load(); + assert.equal(ev("newerVer('1.2.0','1.1.0')"), true); + assert.equal(ev("newerVer('1.10.0','1.9.3')"), true); + assert.equal(ev("newerVer('1.1.0','1.1.0')"), false); + assert.equal(ev("newerVer('1.0.9','1.1.0')"), false); +});