import { test, after } from 'node:test' import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import { useTestEnv } from './support/testEnv.js' // Task H2: oeffentliche Shop-Seiten /shop/:siteKey und /shop/:siteKey/widerruf useTestEnv({ appwriteUrl: 'http://127.0.0.1:1', stripeUrl: 'http://127.0.0.1:1' }) const { startTestApp } = await import('./support/testApp.js') const { shopSeiteRouter, resetShopSeiteForTests } = await import('../server/routes/shopSeite.js') resetShopSeiteForTests() const app = await startTestApp({ '/': shopSeiteRouter() }) after(() => app.close()) const KEY = 'abcdefghijklmnop'.replace(/[ilo]/g, 'a') // nur a-z und 2-7 wie siteKeys const get = async (path) => { const r = await fetch(app.url + path) return { status: r.status, headers: r.headers, text: await r.text() } } const lies = (pfad) => readFileSync(new URL(`../${pfad}`, import.meta.url), 'utf8') test('gueltiger Schluessel: 200 HTML mit Schluessel im Container und den Schutz-Headern', async () => { const r = await get(`/shop/${KEY}`) assert.equal(r.status, 200) assert.match(r.headers.get('content-type'), /^text\/html; charset=utf-8/) assert.match(r.text, new RegExp(`