import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs/promises'; test('Caddy caches only content-hashed Vite frontend assets as immutable', async () => { const caddyfile = await fs.readFile(new URL('../caddy/Caddyfile', import.meta.url), 'utf8'); const matcher = caddyfile.match( /@immutableFrontendAssets path_regexp immutableFrontendAssets (\S+)/, ); assert.ok(matcher, 'immutable frontend asset matcher must exist'); const assetPath = new RegExp(matcher[1]); for (const profile of ['gateway', 'che', 'kwe', 'pwe', 'twe', 'nya', 'pya', 'hwe']) { assert.equal(assetPath.test(`/${profile}/assets/index-CcXtLSVk.js`), true); assert.equal(assetPath.test(`/${profile}/assets/index-CcXtLSVk.js.map`), true); } assert.equal(assetPath.test('/gateway/'), false); assert.equal(assetPath.test('/gateway/terms.1.html'), false); assert.equal(assetPath.test('/gateway/assets/index.js'), false); assert.equal(assetPath.test('/image/game/figure.png'), false); assert.match( caddyfile, /header @immutableFrontendAssets >Cache-Control "public, max-age=31536000, immutable"/, ); });