// tests/e2e/test_registration.js // Tests magic link registration error states: invalid token, used token. const { TARGET_URL, run } = require('./helpers'); run(async (page, assert) => { const fixtures = JSON.parse(process.env.E2E_FIXTURES || '{}'); // ---- Invalid token ---- console.log('\n--- Invalid registration token ---'); const resp1 = await page.goto(`${TARGET_URL}/register/invalid-token-12345`); assert(resp1.status() === 400, `Invalid token returns 400 (got: ${resp1.status()})`); const body1 = await page.locator('body').textContent(); assert( body1.includes('Invalid or expired'), `Shows invalid/expired message (got: "${body1.trim()}")` ); // ---- Used token ---- console.log('\n--- Used registration token ---'); assert(fixtures.used_token, 'Used token fixture exists'); const resp2 = await page.goto(`${TARGET_URL}/register/${fixtures.used_token}`); assert(resp2.status() === 400, `Used token returns 400 (got: ${resp2.status()})`); const body2 = await page.locator('body').textContent(); assert( body2.includes('Invalid or expired'), `Shows invalid/expired for used token (got: "${body2.trim()}")` ); });