fix: event details dialog crashed on a string timestamp

Merged
HA
3d ago
+26-1

Clicking an event in the admin event browser did nothing on main since #335. The page threw e.getTime is not a function and the details dialog never opened.

hey-api's transformer plugin skips any field whose schema is a union. EventDetailResponse.event is the DomainEvent union, so its timestamp stays a string while the generated type says Date, and formatTimestamp crashed on it. The events store now converts that one field in a select when it loads the detail. Nothing about the generated client changes.

Arrays of the union, the browse list and the user overview's recent events, get the first variant's transformer for every item. That converts timestamp, which every variant has, so those pages are fine. Fields that only some variants carry, such as sent_at or cancelled_at, stay strings there too, but nothing formats them; they only show up in the raw JSON view.

A store unit test feeds a string timestamp and expects a Date. A new Playwright test opens the first event in the browser and checks the Timestamp row. It fails against a build without the fix and passes with it, along with the rest of the admin events spec. Vitest passes 1062 tests and the gates are clean.


Summary by cubic

Fixes the admin event details dialog crashing when opening an event. Since #335 the generated SDK returns timestamp as a string on the event detail's event field — the transformer skips union-typed fields — so formatTimestamp called getTime on a string and the dialog never opened.

The events store now converts that field to a Date when loading the detail. Browse lists already work because arrays apply the first variant's transformer, which converts timestamp for every variant.

  • Converts event.timestamp to a Date in the event detail query via a select callback.
  • Adds a unit test with a string timestamp and a Playwright test that opens an event and checks the Timestamp row.