import fs from 'node:fs/promises'; import crypto from 'node:crypto'; import assert from 'node:assert/strict'; const release = JSON.parse(await fs.readFile('compras-release.json', 'utf8')); const base = 'https://compras.tempo.co.mz'; const entry = await fetch(base + '/', { redirect: 'manual', signal: AbortSignal.timeout(15000), }); assert.equal(entry.status, 302); assert.equal(new URL(entry.headers.get('location'), base).pathname, '/login'); const queue = Object.entries(release.frontend.files); let checked = 0; await Promise.all( Array.from({ length: 4 }, async () => { for (;;) { const entry = queue.shift(); if (!entry) return; const [name, expected] = entry; const response = await fetch(base + '/build/' + name, { signal: AbortSignal.timeout(20000), }); assert.equal(response.status, 200, name); assert.equal( crypto .createHash('sha256') .update(new Uint8Array(await response.arrayBuffer())) .digest('hex'), expected, name, ); checked++; } }), ); for (const [path, component] of [ ['/', 'auth/login'], ['/login', 'auth/login'], ['/apresentacao', 'home'], ]) { const response = await fetch(base + path, { signal: AbortSignal.timeout(15000), }); assert.equal(response.status, 200); const html = await response.text(); assert.ok(html.includes(release.frontend.entry)); const bootstrap = html.match( /