Files
Convivo/e2e/src/helpers/reset-cli.js
T
d5ec009cb5 Add Playwright E2E suite (46 tests) + app testids + test_cases.md
- e2e/: full Playwright suite covering every spec case (staff auth/UI,
  welcome + session check-in, attendee access/gating, connections,
  profile visibility, speaker material, sponsor, feedback, E2E journeys,
  role security matrix). 46/46 passing.
- apps/convivo: add data-testid attributes (gate, tabs, scanner, toggles)
  to support the E2E suite.
- test_cases.md: spec-case-to-test coverage map (all cases fully covered).
- .gitignore: ignore e2e node_modules/reports/test-results.

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
2026-09-09 10:13:26 +02:00

71 lines
3.7 KiB
JavaScript

#!/usr/bin/env node
// Convivo e2e — standalone state reset.
//
// node src/helpers/reset-cli.js
//
// Resets the demo rows the acceptance suite touches and (re)creates the
// temporary identities (speaker QR token, sponsor). Safe to run any time.
const { execFileSync } = require('node:child_process');
const DB_CONTAINER = process.env.SUPABASE_DB_CONTAINER || 'supabase_db_Convivo';
const EVENT_ID = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee';
function psql(sql) {
execFileSync('docker', ['exec', '-i', DB_CONTAINER, 'psql', '-U', 'postgres', '-t', '-A'], {
input: sql,
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'pipe'],
});
}
const q = (s) => `'${s.replace(/'/g, "''")}'`;
const CONTACTS = [
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
];
// Welcome check-in baseline: everyone checked in EXCEPT ATTENDEE_NEW (lena).
const CHECKED_IN = CONTACTS.filter((c) => c !== '[email protected]');
psql(`update public.registrations set checked_in = true where contact_email in (${CHECKED_IN.map(q).join(',')}) and event_id = ${q(EVENT_ID)}`);
psql(`update public.registrations set checked_in = false where contact_email = ${q('[email protected]')} and event_id = ${q(EVENT_ID)}`);
// Clear per-contact state.
for (const c of CONTACTS) {
psql(`delete from public.checkins where contact_email = ${q(c)}`);
psql(`delete from public.connections where from_email = ${q(c)} or to_email = ${q(c)}`);
psql(`delete from public.feedback where contact_email = ${q(c)}`);
psql(`update public.registrations set points = 0 where contact_email = ${q(c)}`);
psql(`delete from public.points_log where contact_email = ${q(c)}`);
psql(`delete from public.leaderboard where contact_email = ${q(c)}`);
psql(`update public.contacts set show_email = false, show_linkedin = false, linkedin_url = null where email = ${q(c)}`);
}
// Clear material on the speaker's session (SESSION_A).
psql(`update public.sessions set material_path = null where id = ${q('37ab7060-3d81-4221-9322-6971e97d1175')}`);
// Speaker QR token (seed leaves it NULL).
psql(`update public.registrations set qr_token = ${q('CVV-SPK-9001')} where contact_email = ${q('[email protected]')} and event_id = ${q(EVENT_ID)}`);
psql(`update auth.users set encrypted_password = extensions.crypt(${q('CVV-SPK-9001')}, extensions.gen_salt('bf')) where email = ${q('[email protected]')}`);
// Sponsor (created; no sponsor exists in the seed).
psql(`insert into auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, raw_app_meta_data, raw_user_meta_data, created_at, updated_at)
values ('00000000-0000-0000-0000-000000000000', gen_random_uuid(), 'authenticated', 'authenticated', ${q('[email protected]')},
extensions.crypt(${q('CVV-SPO-9001')}, extensions.gen_salt('bf')), now(),
'{"provider":"email","providers":["email"]}', '{"full_name":"Demo Sponsor"}', now(), now())
on conflict (id) do nothing`);
psql(`insert into public.contacts (email, full_name, linkedin_url, show_email, show_linkedin, is_admin, password)
values (${q('[email protected]')}, 'Demo Sponsor', null, false, false, false, null)
on conflict (email) do nothing`);
psql(`insert into public.registrations (event_id, contact_email, type, checked_in, points, qr_token)
values (${q(EVENT_ID)}, ${q('[email protected]')}, 'sponsor', true, 0, ${q('CVV-SPO-9001')})
on conflict (event_id, contact_email) do update set type = 'sponsor', qr_token = ${q('CVV-SPO-9001')}, checked_in = true`);
console.log('Convivo e2e state reset complete.');