Versione del gioco (src/version.js, 0.1.0): immagini, musiche e voci con ?v=<versione> e cache lunga in nginx; scripts/bump.sh e make bump per le versioni nuove
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ks2K99uqCZjAxvy7Rdj1R
This commit is contained in:
+2
-2
@@ -51,7 +51,7 @@ try {
|
||||
// Il cartello d'apertura, poi da solo il titolo.
|
||||
assert.match(await page.textContent('#splash'), /Manzolo\s*\(Poca\)\s*Art\s*Presents/);
|
||||
assert.ok(await page.isHidden('#title'), 'il titolo aspetta la fine del cartello');
|
||||
assert.match(await page.evaluate(() => jingle.src), /assets\/audio\/cartello\.mp3$/, 'la musichetta del cartello');
|
||||
assert.match(await page.evaluate(() => jingle.src), /assets\/audio\/cartello\.mp3\?v=\d+\.\d+\.\d+$/, 'la musichetta del cartello');
|
||||
assert.equal(await page.evaluate(() => music.want), null, 'la musica del titolo aspetta il titolo');
|
||||
await page.waitForTimeout(2800);
|
||||
await page.screenshot({ path: `${OUT}/00-cartello.png` });
|
||||
@@ -100,7 +100,7 @@ try {
|
||||
await page.waitForFunction(() => game.speech);
|
||||
// La prima battuta ha la sua voce, e sotto la voce la musica si abbassa.
|
||||
await page.waitForFunction(() => voices.playing, null, { timeout: 5000 });
|
||||
assert.match(await page.evaluate(() => voices.audio.src), /assets\/voices\/andrea-[0-9a-f]+\.mp3$/);
|
||||
assert.match(await page.evaluate(() => voices.audio.src), /assets\/voices\/andrea-[0-9a-f]+\.mp3\?v=\d+\.\d+\.\d+$/);
|
||||
await page.waitForFunction(() => music.duck === 0.45, null, { timeout: 2000 });
|
||||
await page.screenshot({ path: `${OUT}/02-inizio.png` });
|
||||
assert.ok(await page.evaluate(() => game.state.flags['rione:campomigliaio']), 'il rione resta nella partita');
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { loadBackground, hasBackground, RETRIES, RETRY_WAIT, flameFrame } from '../src/engine/render.js';
|
||||
import { versioned } from '../src/version.js';
|
||||
|
||||
// Un Image finto: fallisce le prime `fails` volte per ogni indirizzo, e conta le richieste.
|
||||
function fakeImage(fails) {
|
||||
@@ -20,11 +21,11 @@ test('uno sfondo che non arriva si riprova dopo un po\', non a ogni fotogramma,
|
||||
try {
|
||||
assert.equal(await loadBackground(src), false);
|
||||
assert.equal(await loadBackground(src), false, 'subito dopo non si riprova');
|
||||
assert.equal(asked.get(src), 1);
|
||||
assert.equal(asked.get(versioned(src)), 1);
|
||||
assert.equal(await loadBackground(src, Date.now() + RETRY_WAIT + 1), false, 'dopo l\'attesa si riprova');
|
||||
assert.equal(asked.get(src), 2);
|
||||
assert.equal(asked.get(versioned(src)), 2);
|
||||
assert.equal(await loadBackground(src, Date.now() + RETRY_WAIT + 1), false, 'la seconda attesa è più lunga');
|
||||
assert.equal(asked.get(src), 2);
|
||||
assert.equal(asked.get(versioned(src)), 2);
|
||||
assert.equal(await loadBackground(src, Date.now() + 2 * RETRY_WAIT + 1), true);
|
||||
assert.ok(hasBackground(src));
|
||||
} finally {
|
||||
@@ -36,7 +37,7 @@ test('uno sfondo che non c\'è proprio si lascia stare dopo pochi tentativi', as
|
||||
const asked = fakeImage(Infinity), src = 'x/non-esiste.png', later = () => Date.now() + 3600e3;
|
||||
try {
|
||||
for (let i = 0; i < 10; i++) await loadBackground(src, later());
|
||||
assert.equal(asked.get(src), RETRIES + 1);
|
||||
assert.equal(asked.get(versioned(src)), RETRIES + 1);
|
||||
} finally {
|
||||
delete globalThis.Image;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { VERSION, versioned } from '../src/version.js';
|
||||
|
||||
test('la versione del gioco è quella di package.json', () => {
|
||||
assert.match(VERSION, /^\d+\.\d+\.\d+$/);
|
||||
assert.equal(JSON.parse(readFileSync(new URL('../package.json', import.meta.url))).version, VERSION);
|
||||
});
|
||||
|
||||
test('immagini e suoni prendono ?v=<versione>, senza rompere gli indirizzi già con parametri', () => {
|
||||
assert.equal(versioned('assets/scenes/pieve.png'), `assets/scenes/pieve.png?v=${VERSION}`);
|
||||
assert.equal(versioned('a.png?x=1'), `a.png?x=1&v=${VERSION}`);
|
||||
assert.equal(versioned('data:image/png;base64,AAAA'), 'data:image/png;base64,AAAA');
|
||||
});
|
||||
Reference in New Issue
Block a user