From ef0446dcdfb1a2ef81de57c1059b105453e90a9b Mon Sep 17 00:00:00 2001 From: Jose Lago Date: Fri, 16 Oct 2026 16:11:12 +0200 Subject: [PATCH] fix(convivo): consistent service cards, in-place pick details, no duplicated slot time - groupAgenda drops orphan service slots (no session row), so every Service Session card consistently shows header + session row; list, slot count and Home Now/Next agree - Extract the session detail bottom sheet into shared components/SessionDetail.tsx; Home's My-picks chips now open it in place instead of routing to the Agenda (App passes openFeedback so Give-feedback works there too) - Sheet subtitle shows the slot name only when it adds information: auto-named 'Slot 10:15-11:00' no longer repeats the time range, and service names equal to the session title are skipped - e2e: orphan-slot test + Home session picks test (exact subtitle assertion) in convivo-admin-entry.spec.ts, 41/41 green; speaker-portal 19/19; docs + release record 2026-10-16.md --- apps/convivo/src/App.tsx | 2 +- apps/convivo/src/components/SessionDetail.tsx | 198 ++++++++++++++++++ apps/convivo/src/lib/api.ts | 10 +- apps/convivo/src/screens/Agenda.tsx | 182 ++-------------- apps/convivo/src/screens/Home.tsx | 31 ++- docs/backend/tests.md | 20 ++ docs/frontend/app-structure.md | 18 +- docs/frontend/screens.md | 22 +- docs/releases/2026-10-16.md | 60 ++++++ e2e/tests/convivo-admin-entry.spec.ts | 76 ++++++- 10 files changed, 442 insertions(+), 177 deletions(-) create mode 100644 apps/convivo/src/components/SessionDetail.tsx create mode 100644 docs/releases/2026-10-16.md diff --git a/apps/convivo/src/App.tsx b/apps/convivo/src/App.tsx index 2de5c3c..49f06ec 100644 --- a/apps/convivo/src/App.tsx +++ b/apps/convivo/src/App.tsx @@ -156,7 +156,7 @@ function Shell() { return (
- {tab === 'home' && setEventFeedbackOpen(true)} />} + {tab === 'home' && setEventFeedbackOpen(true)} openFeedback={(id) => setFeedbackSession(id)} />} {tab === 'agenda' && setFeedbackSession(id)} />} {tab === 'scan' && } {tab === 'connections' && } diff --git a/apps/convivo/src/components/SessionDetail.tsx b/apps/convivo/src/components/SessionDetail.tsx new file mode 100644 index 0000000..e21357f --- /dev/null +++ b/apps/convivo/src/components/SessionDetail.tsx @@ -0,0 +1,198 @@ +import { useRef } from 'react'; +import { + clearPreference, + removeSessionMaterial, + sessionMaterialUrl, + setPreference, + uploadSessionMaterial, +} from '../lib/api'; +import { fmtRange, slotStatus } from '../lib/time'; +import type { Session, Slot } from '../lib/types'; +import { useToast } from '../context/ToastContext'; +import { Sheet } from './ui'; + +/** + * The session detail bottom sheet — the single source of truth for what a + * session looks like when opened. Used by the Agenda list and by Home's + * "My picks today" chips, so tapping a pick on Home shows exactly the same + * detail as tapping it in the Agenda. + */ +export function SessionDetail({ + session, + slot, + now, + checkedIn, + isSpeaker, + picked, + onClose, + onPickChanged, + onGiveFeedback, + onMaterialChanged, +}: { + session: Session | null; + slot: Slot | undefined; + now: Date; + checkedIn: boolean; + isSpeaker: boolean; + picked: boolean; + onClose: () => void; + /** Persist a pick/un-pick; the parent refreshes its own preference list. */ + onPickChanged: () => Promise | void; + onGiveFeedback?: (sessionId: string) => void; + /** Refresh the agenda after a material upload/remove. */ + onMaterialChanged?: () => void; +}) { + const { toast } = useToast(); + const fileRef = useRef(null); + if (!session || !slot) return null; + + const status = slotStatus(slot, now); + const isService = slot.type === 'service_session'; + // Service sessions have no material requirement (and no mic), so the + // pending-material notice never applies to them. + const needsMaterial = isSpeaker && !session.material_path && !isService; + + async function togglePick() { + try { + if (picked) { + await clearPreference(slot!.id); + toast('Pick removed'); + } else { + await setPreference(session!.id); + toast('Pick saved ✓', 'ok'); + } + await onPickChanged(); + } catch (e) { + toast(e instanceof Error ? e.message : 'Could not update pick', 'err'); + } + } + + async function handleUpload(e: React.ChangeEvent) { + const file = e.target.files?.[0]; + if (!file || !session) return; + try { + await uploadSessionMaterial(session.id, file); + toast('Material uploaded ✓', 'ok'); + onClose(); + onMaterialChanged?.(); + } catch (err) { + toast(err instanceof Error ? err.message : 'Upload failed', 'err'); + } finally { + if (fileRef.current) fileRef.current.value = ''; + } + } + + async function handleDeleteMaterial() { + if (!session) return; + if (!confirm('Remove this material? You can upload a new one.')) return; + try { + await removeSessionMaterial(session.id); + toast('Material removed', 'ok'); + onClose(); + onMaterialChanged?.(); + } catch (err) { + toast(err instanceof Error ? err.message : 'Could not remove material', 'err'); + } + } + + const range = fmtRange(slot); + // Talk slots are auto-named "Slot 10:15–11:00", which merely repeats the + // time range shown next to it, and service slots are often named exactly + // like their session (the title is already the heading). Show the slot name + // only when it actually adds information. + const showSlotName = slot.name !== `Slot ${range}` && slot.name !== session.title; + + return ( + +
+
+

{session.title}

+
+ {showSlotName && <>{slot.name} · }{range} · {session.room} +
+
+ +
+
+ {session.description} +
+
+ {isService ? '' : '🎤 '}{session.speakers} + {session.level && 📶 {session.level}} + {session.area && 🗂 {session.area}} + {session.capacity && 👥 {session.capacity}} + {checkedIn && ✓ Checked in} +
+ + {/* Speaker material: non-dismissible notification until uploaded. */} + {needsMaterial && ( +
+
📎 Upload your session material
+
+ Attendees can download your slides/notes from this session. +
+ +
+ )} + + {/* Speaker feedback: visible only after the session is over. */} + {isSpeaker && status === 'done' && ( +
+
⭐ Your session feedback
+ {session.average_feedback != null ? ( +
+ + {[1, 2, 3, 4, 5].map((n) => ( + ★ + ))} + + {session.average_feedback.toFixed(1)} +
+ ) : ( +
No feedback yet.
+ )} + {session.ai_generated_feedback && ( +
+
AI summary
+
{session.ai_generated_feedback}
+
+ )} +
+ )} + +
+ {status === 'done' && checkedIn && onGiveFeedback && ( + + )} + {status === 'done' && !checkedIn && ( +
+ You weren’t checked in to this session. +
+ )} + {isService ? ( +
+ No pick needed for this slot. +
+ ) : ( + + )} + {/* Material download (all attendees) — pinned to the bottom. */} + {session.material_path && ( + + 📎 Download material + + )} + {/* Speakers can remove their own material to re-upload. */} + {isSpeaker && session.material_path && ( + + )} +
+
+ ); +} diff --git a/apps/convivo/src/lib/api.ts b/apps/convivo/src/lib/api.ts index 0c5b854..c7b9497 100644 --- a/apps/convivo/src/lib/api.ts +++ b/apps/convivo/src/lib/api.ts @@ -83,7 +83,15 @@ export function groupAgenda(rows: AgendaRow[]): { slot: Slot; sessions: Session[ }); } } - return [...map.values()].sort((first, second) => + // A service slot is only meaningful with a session behind it (break / lunch / + // closing …). An orphan service slot — left over from an earlier feed or a + // manual edit with no session row — would render as a header-only card, + // inconsistent with every other service card. Drop those (mirroring how the + // agenda already hides empty talk slots) so the list, its slot count, and + // Home's Now/Next all agree. + return [...map.values()] + .filter(({ slot, sessions }) => slot.type !== 'service_session' || sessions.length > 0) + .sort((first, second) => first.slot.slot_date.localeCompare(second.slot.slot_date) || first.slot.start_time.localeCompare(second.slot.start_time) || first.slot.end_time.localeCompare(second.slot.end_time) diff --git a/apps/convivo/src/screens/Agenda.tsx b/apps/convivo/src/screens/Agenda.tsx index f30e0d1..adc75ba 100644 --- a/apps/convivo/src/screens/Agenda.tsx +++ b/apps/convivo/src/screens/Agenda.tsx @@ -1,21 +1,12 @@ -import { useEffect, useMemo, useRef, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { useAuth } from '../context/AuthContext'; import { useEvent } from '../lib/useEvent'; import { mergeAgendaPlaceholders } from '../lib/agendaBlocks'; -import { - clearPreference, - getMyCheckins, - getMyPreferences, - getMySpeakerSessions, - removeSessionMaterial, - sessionMaterialUrl, - setPreference, - uploadSessionMaterial, -} from '../lib/api'; +import { getMyCheckins, getMyPreferences, getMySpeakerSessions } from '../lib/api'; import { capWords, fmtRange, slotStatus } from '../lib/time'; import type { Preference, Session } from '../lib/types'; -import { Sheet, Spinner } from '../components/ui'; -import { useToast } from '../context/ToastContext'; +import { Spinner } from '../components/ui'; +import { SessionDetail } from '../components/SessionDetail'; export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) => void }) { const { contact } = useAuth(); @@ -24,8 +15,6 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) => const [checkins, setCheckins] = useState([]); const [mySpeakerSessions, setMySpeakerSessions] = useState([]); const [selected, setSelected] = useState(null); - const fileRef = useRef(null); - const { toast } = useToast(); // Agenda filters: level + area (free-text, dynamic — built from the distinct // values actually present in the agenda, so it works for numeric levels @@ -99,60 +88,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) => const pickFor = (slotId: number) => prefs.find((p) => p.slot_id === slotId)?.session_id; - async function togglePick(slotId: number, sessionId: string) { - const current = pickFor(slotId); - try { - if (current === sessionId) { - await clearPreference(slotId); - toast('Pick removed'); - } else { - await setPreference(sessionId); - toast('Pick saved ✓', 'ok'); - } - const p = await getMyPreferences(); - setPrefs(p); - } catch (e) { - toast(e instanceof Error ? e.message : 'Could not update pick', 'err'); - } - } - const selSlot = selected ? slots.find((s) => s.slot.id === selected.slot_id)?.slot : undefined; - const selStatus = selSlot ? slotStatus(selSlot, now) : 'next'; - const selCheckedIn = selected ? checkins.includes(selected.id) : false; - const selISpeaker = selected ? mySpeakerSessions.includes(selected.id) : false; - const selIsService = selSlot?.type === 'service_session'; - // Service sessions have no material requirement (and no mic), so the - // pending-material notice never applies to them. - const selNeedsMaterial = selISpeaker && !selected?.material_path && !selIsService; - - async function handleUpload(e: React.ChangeEvent) { - const file = e.target.files?.[0]; - if (!file || !selected) return; - try { - await uploadSessionMaterial(selected.id, file); - toast('Material uploaded ✓', 'ok'); - setSelected(null); - // Refresh agenda so material_path updates. - reload(); - } catch (err) { - toast(err instanceof Error ? err.message : 'Upload failed', 'err'); - } finally { - if (fileRef.current) fileRef.current.value = ''; - } - } - - async function handleDeleteMaterial() { - if (!selected) return; - if (!confirm('Remove this material? You can upload a new one.')) return; - try { - await removeSessionMaterial(selected.id); - toast('Material removed', 'ok'); - setSelected(null); - reload(); - } catch (err) { - toast(err instanceof Error ? err.message : 'Could not remove material', 'err'); - } - } return (
@@ -259,104 +195,18 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) => })}
- setSelected(null)}> - {selected && selSlot && ( - <> -
-
-

{selected.title}

-
- {selSlot.name} · {fmtRange(selSlot)} · {selected.room} -
-
- -
-
- {selected.description} -
-
- {selIsService ? '' : '🎤 '}{selected.speakers} - {selected.level && 📶 {selected.level}} - {selected.area && 🗂 {selected.area}} - {selected.capacity && 👥 {selected.capacity}} - {selCheckedIn && ✓ Checked in} -
- - {/* Speaker material: non-dismissible notification until uploaded. */} - {selNeedsMaterial && ( -
-
📎 Upload your session material
-
- Attendees can download your slides/notes from this session. -
- -
- )} - - {/* Speaker feedback: visible only after the session is over. */} - {selISpeaker && selStatus === 'done' && ( -
-
⭐ Your session feedback
- {selected.average_feedback != null ? ( -
- - {[1, 2, 3, 4, 5].map((n) => ( - ★ - ))} - - {selected.average_feedback.toFixed(1)} -
- ) : ( -
No feedback yet.
- )} - {selected.ai_generated_feedback && ( -
-
AI summary
-
{selected.ai_generated_feedback}
-
- )} -
- )} - -
- {selStatus === 'done' && selCheckedIn && ( - - )} - {selStatus === 'done' && !selCheckedIn && ( -
- You weren’t checked in to this session. -
- )} - {selSlot.type === 'service_session' ? ( -
- No pick needed for this slot. -
- ) : ( - - )} - {/* Material download (all attendees) — pinned to the bottom. */} - {selected.material_path && ( - - 📎 Download material - - )} - {/* Speakers can remove their own material to re-upload. */} - {selISpeaker && selected.material_path && ( - - )} -
- - )} -
+ setSelected(null)} + onPickChanged={async () => setPrefs(await getMyPreferences())} + onGiveFeedback={openFeedback} + onMaterialChanged={reload} + /> ); } diff --git a/apps/convivo/src/screens/Home.tsx b/apps/convivo/src/screens/Home.tsx index 0a53b9f..665094e 100644 --- a/apps/convivo/src/screens/Home.tsx +++ b/apps/convivo/src/screens/Home.tsx @@ -5,6 +5,7 @@ import { getMyCheckins, getMyFeedback, getMyPreferences, getMySpeakerSessions } import { fmtRange, greeting, slotStatus } from '../lib/time'; import type { Feedback, Preference, Session } from '../lib/types'; import { Sheet, Spinner } from '../components/ui'; +import { SessionDetail } from '../components/SessionDetail'; /** A single session block inside the Now/Next card (title + room + speaker). */ function SessionBlock({ session, checkedIn }: { session: Session; checkedIn?: boolean }) { @@ -42,14 +43,18 @@ function ConcurrentList({ sessions }: { sessions: Session[] }) { ); } -export function Home({ go, onEventFeedback }: { go: (tab: string) => void; onEventFeedback?: () => void }) { +export function Home({ go, onEventFeedback, openFeedback }: { go: (tab: string) => void; onEventFeedback?: () => void; openFeedback?: (sessionId: string) => void }) { const { contact, registration } = useAuth(); - const { event, slots, sessionById, slotById, now, clockMode, loading } = useEvent(); + const { event, slots, sessionById, slotById, now, clockMode, loading, reload } = useEvent(); const [prefs, setPrefs] = useState([]); const [checkins, setCheckins] = useState([]); const [mySpeakerSessions, setMySpeakerSessions] = useState([]); const [myFeedback, setMyFeedback] = useState([]); const [materialSheetOpen, setMaterialSheetOpen] = useState(false); + // The pick the user tapped in "My picks today" — opened in the same detail + // sheet the Agenda uses, so a pick shows the full session info in place + // instead of bouncing to the Agenda tab. + const [selected, setSelected] = useState(null); const email = contact?.email ?? ''; @@ -207,7 +212,12 @@ export function Home({ go, onEventFeedback }: { go: (tab: string) => void; onEve {picks.length > 0 ? (
{picks.map((r) => ( - + + {/* Tapping one of "My picks today" opens the same session detail sheet the + Agenda shows — no round trip to the Agenda tab. */} + setSelected(null)} + onPickChanged={async () => setPrefs(await getMyPreferences())} + onGiveFeedback={openFeedback} + onMaterialChanged={reload} + /> ); } diff --git a/docs/backend/tests.md b/docs/backend/tests.md index 8742c1b..7027ae2 100644 --- a/docs/backend/tests.md +++ b/docs/backend/tests.md @@ -175,6 +175,26 @@ retained no-pick/no-upload service behavior even for an assigned staff speaker. A separate case checks exact date/time matching and keeps unrelated services separate. See the [deployment record](../releases/2026-10-11.md). +# Agenda Consistency + Home Picks Regression + +Two further API-mocked checks run in the same spec: + +```sh +CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- convivo-admin-entry.spec.ts --project=chromium --grep 'Service agenda|Home session picks' +``` + +- **Orphan service slot** — a `get_agenda` row whose slot is a + `service_session` with a null session (the LEFT JOIN shape a slot with no + session row produces) must render **no card at all**, so every service card + consistently shows a header plus its session row. The rule lives in + `groupAgenda`, so the list, the displayed slot count and Home's Now/Next all + agree. +- **Home session picks** — tapping a "My picks today" chip opens the shared + `SessionDetail` sheet **over Home** (title, description, time/room/speaker, + level pill, and the "Remove my pick" control) and leaves the active tab on + Home; closing the sheet returns to the pick list. This replaces the old + behavior of routing to the Agenda tab. + # Session Persistence Regression Run the rollback-only fixture after applying diff --git a/docs/frontend/app-structure.md b/docs/frontend/app-structure.md index 8f892b9..8c730a3 100644 --- a/docs/frontend/app-structure.md +++ b/docs/frontend/app-structure.md @@ -186,8 +186,8 @@ The `Shell` is the navigation container. Render logic, in order: - **Leaderboard** is *not* a tab — it's reached from the Home points pill and the Home quick-actions. It renders as a tab in the shell but is opened via `go('leaderboard')`. -- **Feedback** is a full-screen takeover (no tab bar), opened from the Agenda - session sheet via `openFeedback(sessionId)`. +- **Feedback** is a full-screen takeover (no tab bar), opened from the session + detail sheet (Agenda list or Home picks) via `openFeedback(sessionId)`. ## Shared UI components (`components/ui.tsx`) @@ -199,3 +199,17 @@ The `Shell` is the navigation container. Render logic, in order: | `Sheet` | Bottom-sheet modal (backdrop + grab handle) | | `QrImage` | Renders a string (e.g. a QR token) as a scannable QR (`qrcode.react`) | | `Scanner` | Camera QR scanner (`html5-qrcode`) with a **manual-entry fallback** and a `hasCamera` guard (headless/no-camera environments fall back to typing the code) | + +## Session detail (`components/SessionDetail.tsx`) + +`SessionDetail` is the **single session detail bottom sheet** shared by the +Agenda list and Home's **My picks today** chips (so tapping a pick on Home +opens the session in place instead of routing to the Agenda). It receives the +`session` + its `slot` plus plain booleans (`checkedIn`, `isSpeaker`, +`picked`) and callbacks (`onPickChanged`, `onGiveFeedback`, +`onMaterialChanged`) — the owning screen keeps its own preference/check-in +state and refreshes it through the callbacks. Renders: title + time/room +subtitle (the slot name is prefixed only when it adds information, so an +auto-named "Slot 10:15–11:00" never repeats the time range), description, speaker/level/area/capacity/checked-in pills, the speaker +material upload notice, the speaker feedback review, the Give-feedback button, +the pick / "No pick needed" control, and the material download/remove buttons. diff --git a/docs/frontend/screens.md b/docs/frontend/screens.md index 70a9360..7ae9108 100644 --- a/docs/frontend/screens.md +++ b/docs/frontend/screens.md @@ -117,8 +117,14 @@ The landing screen. Shows: - **Next card** — **always shown** for the next slot (same pick / concurrent-list logic as the Now card, without the check-in pill). - **My picks today** — one row per pick the user has made **today** (in slot - order), each showing the slot time + session title + room. "tap to change" is a - **hyperlink** to the Agenda. With no picks, a "No picks yet" line. + order), each showing the slot time + session title + room. Tapping a row + opens the **same session detail sheet the Agenda shows** (description, + speaker/level/area pills, pick/un-pick, material download, feedback entry) + **in place over Home** — no round trip to the Agenda tab. "tap to change" is + a **hyperlink** to the Agenda. With no picks, a "No picks yet" line. +- The detail sheet is a shared component (`components/SessionDetail.tsx`) used + by both Home's picks and the Agenda list, so a session looks and behaves + identically wherever it is opened. - **Quick actions** — Scan & connect, Agenda, Connections, Leaderboard. - **No active event** — a graceful empty state ("No active event right now. Check back soon!"). @@ -164,8 +170,18 @@ differently: - they have **no material requirement** (the pending-material notice never applies to them). +A **service slot with no session behind it** (an orphan left over from an +earlier feed or a manual edit) is **hidden entirely** by `groupAgenda`, exactly +like an empty talk slot. Without this it would render as a header-only card +while every real service card shows a header **plus** its session row — the +inconsistency the attendee reported. The rule lives in the grouping layer, so +the agenda list, its slot count, and Home's Now/Next cards all agree. + - **Tap a session** → opens a bottom **sheet** with details (description, - speakers, room, capacity, checked-in state) and actions: + speakers, room, capacity, checked-in state) and actions. The subtitle shows + **time · room**, prefixed with the **slot name only when it adds + information** — auto-named talk slots ("Slot 10:15–11:00") and service slots + named like their session are not repeated: - **Give feedback ⭐** — only when the session is *done* **and** the user is checked in. Opens the Feedback takeover (`openFeedback(sessionId)`). - **Speaker feedback review** — when the user is a **speaker** of the session diff --git a/docs/releases/2026-10-16.md b/docs/releases/2026-10-16.md new file mode 100644 index 0000000..6a37852 --- /dev/null +++ b/docs/releases/2026-10-16.md @@ -0,0 +1,60 @@ +# Attendee Agenda Polish (2026-10-16) + +Three presentation-only fixes to the attendee app (Convivo), all local-first +and deployed together as an attendee-only rebuild (no migrations, no sidecar, +no admin changes). + +## 1. Service Session card consistency + +**Symptom:** some Service Session agenda cards rendered a header plus a detail +row, while one (11:15–12:00) rendered header-only. + +**Root cause:** an orphan service slot — a `slots` row typed +`service_session` with no `sessions` row behind it (a leftover from an earlier +feed state or manual edit). `get_agenda` LEFT JOINs sessions onto slots, so +the orphan arrives as a row with slot fields and a null session; the Agenda +rendered the header with zero session rows. Nothing referenced the slot +(0 preferences / check-ins / feedback). + +**Fix:** `groupAgenda` (`apps/convivo/src/lib/api.ts`) drops service slots +with no sessions, mirroring the existing rule that hides empty talk slots. +Placed in the grouping layer so the agenda list, its displayed slot count, and +Home's Now/Next cards all agree. Presentation-only — no data was deleted. + +## 2. Home picks open the session detail in place + +**Request:** tapping a pick under "My picks today" routed to the Agenda tab; +it should open the session's details directly. + +**Fix:** the Agenda's session bottom sheet was extracted verbatim into a +shared component `apps/convivo/src/components/SessionDetail.tsx` (title, +time/room subtitle, description, speaker/level/area/capacity/checked-in pills, +pick / "Remove my pick", speaker material upload/download/remove, speaker +feedback review, Give-feedback entry). Home's pick chips now open it over +Home; the Agenda renders the same component (~100 lines of duplicated markup +removed). `App.tsx` passes `openFeedback` into Home so feedback works from the +Home sheet too. The "tap to change" link to the Agenda remains. + +## 3. Session detail subtitle no longer repeats the time + +**Symptom:** the sheet subtitle showed the time twice, e.g. +"Slot 10:15–11:00 · 10:15–11:00 · Room A". + +**Root cause:** talk slots are auto-named `Slot –`, and the +subtitle rendered `{slot.name} · {range} · {room}`. + +**Fix:** the slot name is shown only when it adds information — skipped when +it equals the auto-generated `Slot ` or repeats the session title +(common for services like "Lunch"). + +## Verification + +- `convivo-admin-entry.spec.ts` (API-mocked): **41/41** green, including the + new orphan-service-slot test and the new "Home session picks" test (sheet + opens over Home, tab stays active, exact subtitle `10:15–11:00 · Room A`, + close returns to the pick list). +- `speaker-portal.spec.ts`: 19/19 green (regression). +- Attendee production build clean. +- Docs synced: `docs/frontend/screens.md`, `docs/frontend/app-structure.md` + (new "Session detail" section), `docs/backend/tests.md` ("Agenda + Consistency + Home Picks Regression"). diff --git a/e2e/tests/convivo-admin-entry.spec.ts b/e2e/tests/convivo-admin-entry.spec.ts index 0df9e8f..c303705 100644 --- a/e2e/tests/convivo-admin-entry.spec.ts +++ b/e2e/tests/convivo-admin-entry.spec.ts @@ -66,6 +66,74 @@ test.describe('Service agenda', () => { await expect(talkBlock.getByText('Different end room', { exact: false })).toHaveCount(0); await expect(talkBlock.getByText('Lunch room', { exact: false })).toHaveCount(0); }); + test('hides an orphan service slot that has no session behind it', async ({ page }) => { + const { session } = await mockApi(page, { registered: true, checkedIn: true }); + // get_agenda LEFT JOINs sessions onto slots, so an orphan service slot + // arrives as a row with the slot fields set but a null session. It must not + // render a header-only card (the inconsistency), while real service slots + // and talk slots stay. + const rows = [ + { slot_id: 1, slot_name: 'Arrival & Coffee', start_time: '08:30:00', end_time: '09:00:00', slot_type: 'service_session', session_id: 'session-1', title: 'Arrival & Coffee', room: 'Main', speakers: 'Staff' }, + { slot_id: 2, slot_name: 'Slot 10:15–11:00', start_time: '10:15:00', end_time: '11:00:00', slot_type: 'session', session_id: 'session-2', title: 'A Talk', room: 'Main', speakers: 'Speaker' }, + { slot_id: 67, slot_name: 'Service Session', start_time: '11:15:00', end_time: '12:00:00', slot_type: 'service_session', session_id: null, title: null, room: null, speakers: null }, + { slot_id: 3, slot_name: 'Lunch', start_time: '12:00:00', end_time: '13:00:00', slot_type: 'service_session', session_id: 'session-3', title: 'Lunch', room: 'Main', speakers: 'Staff' }, + ].map(row => ({ ...row, slot_date: '2026-02-20', description: '', material_path: null, capacity: null, + average_feedback: null, ai_generated_feedback: null, level: null, area: null })); + await page.route('**/rest/v1/rpc/get_agenda', route => route.fulfill({ json: rows })); + await page.goto(`${appUrl}/auth/callback#access_token=${session.access_token}&refresh_token=${session.refresh_token}&type=magiclink`); + await page.getByTestId('tab-agenda').click(); + await expect(page.locator('.slot-card')).toHaveCount(3); + await expect(page.getByText('3 slots', { exact: true })).toBeVisible(); + await expect(page.locator('.slot-card').filter({ hasText: '11:15' })).toHaveCount(0); + await expect(page.locator('.sess .title')).toHaveText(['Arrival & Coffee', 'A Talk', 'Lunch']); + }); +}); + +test.describe('Home session picks', () => { + test('tapping a pick opens its session detail in place instead of routing to the Agenda', async ({ page }) => { + const { session } = await mockApi(page, { + registered: true, checkedIn: true, + picks: [{ slot_id: 1, session_id: 'session-1' }], + }); + const rows = [ + { slot_id: 1, slot_name: 'Slot 10:15–11:00', start_time: '10:15:00', end_time: '11:00:00', slot_type: 'session', + session_id: 'session-1', title: 'My Picked Talk', room: 'Room A', speakers: 'Ada Lovelace', + description: 'Deep dive into picks.', level: 'Beginner', area: 'Power Apps' }, + { slot_id: 2, slot_name: 'Slot 11:15–12:00', start_time: '11:15:00', end_time: '12:00:00', slot_type: 'session', + session_id: 'session-2', title: 'Other Talk', room: 'Room B', speakers: 'Grace Hopper', + description: '', level: null, area: null }, + ].map(row => ({ ...row, slot_date: '2026-02-20', material_path: null, capacity: null, + average_feedback: null, ai_generated_feedback: null })); + await page.route('**/rest/v1/rpc/get_agenda', route => route.fulfill({ json: rows })); + await page.goto(`${appUrl}/auth/callback#access_token=${session.access_token}&refresh_token=${session.refresh_token}&type=magiclink`); + + await expect(page.getByTestId('tab-home')).toHaveClass(/active/); + const chip = page.getByTestId('home-pick'); + await expect(chip).toHaveCount(1); + await expect(chip).toContainText('My Picked Talk'); + + await chip.click(); + // The same detail sheet the Agenda shows, opened over Home. + await expect(page.locator('.sheet h3')).toHaveText('My Picked Talk'); + await expect(page.locator('#sd-desc')).toHaveText('Deep dive into picks.'); + // The auto slot name ("Slot 10:15–11:00") only repeats the time range, so + // the subtitle must not show it twice. + await expect(page.locator('.sheet .sub')).toHaveText('10:15–11:00 · Room A'); + await expect(page.locator('.sheet')).toContainText('10:15–11:00'); + await expect(page.locator('.sheet')).toContainText('Room A'); + await expect(page.locator('.sheet')).toContainText('Ada Lovelace'); + await expect(page.locator('.sheet')).toContainText('📶 Beginner'); + // It is the user's pick, so the sheet offers to remove it. + await expect(page.getByRole('button', { name: 'Remove my pick', exact: true })).toBeVisible(); + await expect(page.getByRole('button', { name: 'Pick this session', exact: true })).toHaveCount(0); + // Still on Home — no round trip to the Agenda tab. + await expect(page.getByTestId('tab-home')).toHaveClass(/active/); + await expect(page.getByTestId('tab-agenda')).not.toHaveClass(/active/); + + await page.locator('.sheet').getByRole('button', { name: '✕', exact: true }).click(); + await expect(page.locator('.sheet')).toHaveCount(0); + await expect(page.getByTestId('home-pick')).toHaveCount(1); + }); }); test.describe('Event demo clock', () => { @@ -146,7 +214,7 @@ function mockSession(email: string) { return { user, access_token: `eyJhbGciOiJIUzI1NiJ9.${payload}.test-signature`, refresh_token: 'mock-refresh-token', token_type: 'bearer', expires_in: 3600 }; } -async function mockApi(page: Page, options: { email?: string; admin?: boolean; registered?: boolean; checkedIn?: boolean; staff?: boolean; eventDate?: string; realtimeClock?: boolean } = {}) { +async function mockApi(page: Page, options: { email?: string; admin?: boolean; registered?: boolean; checkedIn?: boolean; staff?: boolean; eventDate?: string; realtimeClock?: boolean; picks?: { slot_id: number; session_id: string }[] } = {}) { const email = options.email || 'admin@example.org'; const session = mockSession(email); const calls = { users: 0, exchanges: 0, passwords: 0, logouts: 0, otp: 0, lanyards: 0, mutations: [] as string[] }; @@ -177,6 +245,12 @@ async function mockApi(page: Page, options: { email?: string; admin?: boolean; r await route.fulfill({ json: options.admin !== false }); } else if (pathname.endsWith('/rpc/is_admin')) await route.fulfill({ json: options.admin !== false }); + else if (pathname.endsWith('/preferences')) { + await route.fulfill({ json: (options.picks ?? []).map((p, index) => ({ + id: `pref-${index}`, event_id: '33333333-3333-4333-8333-333333333333', + contact_email: email, session_id: p.session_id, slot_id: p.slot_id, + })) }); + } else if (pathname.endsWith('/contacts')) await route.fulfill({ json: { email, full_name: 'Test Member', is_admin: false, show_email: false, show_linkedin: false } }); else if (pathname.endsWith('/registrations')) { expect(new URL(request.url()).searchParams.get('event_id')).toBe('eq.33333333-3333-4333-8333-333333333333');