feat(scan): confirm before welcome check-in, with print warning
The staff scanner checked attendees in silently, and the default session mode never prints — so a welcome-desk scan could check someone in with no badge and no confirmation. - new read-only RPC preview_welcome_checkin(qr): resolves the attendee and reports already + will_print (mirrors the exact welcome_checkin enqueue condition: first check-in AND a layout exists). Staff/admin only; checks nobody in, enqueues nothing. - attendee Scan screen previews first and shows a Yes/No sheet: "You are checking in [Name]. By confirming, you will print this person's label." Only Yes runs welcome_checkin. Session check-in unchanged (never prints). - badge_print_tests.sql +8 assertions (109 total); ScanPage + welcome specs drive the confirm step; new CONV-CHECKIN-003 (No cancels, Yes checks in). - docs: rpcs.md, printing.md, releases/2026-10-19.md. 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]>
This commit is contained in:
1 parent
00c89c1b48
commit
65dcf64c4e
11 files changed
+348
-7
No files matched your search
@@ -262,6 +262,76 @@ select pg_temp.assert_bp(
|
||||
(select not checked_in from public.registrations where contact_email = '[email protected]'),
|
||||
'rolled back check-in leaves the attendee unchecked');
|
||||
|
||||
-- -----------------------------------------------------------------------------
|
||||
-- 2b. WELCOME CHECK-IN PREVIEW (read-only: resolves the name + will_print)
|
||||
-- -----------------------------------------------------------------------------
|
||||
|
||||
-- bp-att5 is still unchecked (its scan was rolled back) and event A has a
|
||||
-- layout, so the preview must report will_print = true WITHOUT checking in or
|
||||
-- enqueueing anything.
|
||||
create temporary table bp_prev1 as
|
||||
select * from public.preview_welcome_checkin('BPQR-ATT-5');
|
||||
select pg_temp.assert_bp(
|
||||
(select attendee_email = '[email protected]' and attendee_name = 'Savepoint Sol' from bp_prev1),
|
||||
'preview resolves the attendee name from the QR token');
|
||||
select pg_temp.assert_bp(
|
||||
(select already = false and will_print = true from bp_prev1),
|
||||
'preview of an unchecked attendee reports will_print');
|
||||
select pg_temp.assert_bp(
|
||||
(select count(*) = 1 from pgmq.q_badge_print),
|
||||
'preview enqueues nothing');
|
||||
select pg_temp.assert_bp(
|
||||
(select not checked_in from public.registrations where contact_email = '[email protected]'),
|
||||
'preview does not check the attendee in');
|
||||
|
||||
-- An already-checked-in attendee: preview reports already and will_print = false.
|
||||
create temporary table bp_prev2 as
|
||||
select * from public.preview_welcome_checkin('BPQR-ATT-2');
|
||||
select pg_temp.assert_bp(
|
||||
(select already = true and will_print = false from bp_prev2),
|
||||
'preview of a checked-in attendee reports no print');
|
||||
|
||||
-- An event without a badge layout: check-in would work but nothing prints.
|
||||
-- (bp-attb was checked in by the section-2 scan; reset it so the preview
|
||||
-- isolates the "no layout" reason rather than "already checked in".)
|
||||
update public.registrations set checked_in = false where contact_email = '[email protected]';
|
||||
update public.events set is_active = true where id = 'b9d00002-0000-0000-0000-00000000000b';
|
||||
update public.events set is_active = false where id = 'b9d00001-0000-0000-0000-00000000000a';
|
||||
create temporary table bp_prev3 as
|
||||
select * from public.preview_welcome_checkin('BPQR-ATT-B');
|
||||
select pg_temp.assert_bp(
|
||||
(select already = false and will_print = false from bp_prev3),
|
||||
'preview without a layout reports no print');
|
||||
update public.events set is_active = true where id = 'b9d00001-0000-0000-0000-00000000000a';
|
||||
update public.events set is_active = false where id = 'b9d00002-0000-0000-0000-00000000000b';
|
||||
|
||||
-- A plain (non-staff) viewer cannot preview; the guard matches welcome_checkin
|
||||
-- (a plain RAISE EXCEPTION, i.e. sqlstate P0001 / raise_exception).
|
||||
select set_config('request.jwt.claims', '{"email":"[email protected]","role":"authenticated"}', true);
|
||||
do $$ begin
|
||||
begin
|
||||
perform * from public.preview_welcome_checkin('BPQR-ATT-5');
|
||||
raise exception 'non-staff preview allowed';
|
||||
exception when raise_exception then
|
||||
if sqlerrm <> 'staff or admin only' then raise; end if;
|
||||
end;
|
||||
perform pg_temp.assert_bp(true, 'preview is staff/admin only');
|
||||
end; $$;
|
||||
|
||||
-- The anonymous role cannot preview either.
|
||||
select set_config('request.jwt.claims', '{"role":"anon"}', true);
|
||||
set local role anon;
|
||||
do $$ begin
|
||||
begin
|
||||
perform * from public.preview_welcome_checkin('BPQR-ATT-5');
|
||||
raise exception 'anon preview allowed';
|
||||
exception when insufficient_privilege then
|
||||
null;
|
||||
end;
|
||||
perform pg_temp.assert_bp(true, 'anon cannot preview a check-in');
|
||||
end; $$;
|
||||
reset role;
|
||||
|
||||
-- -----------------------------------------------------------------------------
|
||||
-- 3. PRINT STATION PROVISIONING AND PERMISSIONS
|
||||
-- -----------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user