Skip to content

Commit 1470891

Browse files
Nigel Tatschnerntatschner
authored andcommitted
fix(kb): drop 'use client' from event-summary-react + tighten detail spec selectors
Two test failures from the previous CI run: 1. Dashboard + journey TypesTab tests blew up with: Error: Attempted to call renderEventSummary() from the server but renderEventSummary is on the client. event-summary-react.tsx was marked 'use client' but the dashboard and TypesTab are server components that *call* renderEventSummary directly. Next 15 rejects that — a client function can only be rendered as JSX, not invoked from server code. The function is pure (no hooks, no state — just a switch returning JSX), so the directive was wrong from the start. Removed it. Server components can still return JSX containing <EntityLink> (which IS 'use client') — that's the normal server/client composition pattern. 2. kb_detail_renders_summary_and_full_metadata hit strict-mode collision: `getByText('Manufacturer')` matched three elements because the at-a-glance <dt>Manufacturer</dt> and the full metadata table's <dt>manufacturer.name</dt> + <dt>manufacturer.code</dt> all match (Playwright getByText normalises case for substring). Pinned the at-a-glance assertions to `exact: true` so only the capitalised label matches, not the dotted metadata-table keys.
1 parent e4185b6 commit 1470891

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

apps/web/e2e/kb.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,13 @@ test('kb_detail_renders_summary_and_full_metadata', async ({
200200
await expect(
201201
page.getByRole('heading', { name: 'Aegis Avenger Stalker', level: 1 }),
202202
).toBeVisible();
203-
// At-a-glance section.
203+
// At-a-glance section. `exact: true` to avoid the strict-mode
204+
// collision with the metadata table's `manufacturer.name` /
205+
// `manufacturer.code` dotted-path keys.
204206
await expect(page.getByText('At a glance')).toBeVisible();
205-
await expect(page.getByText('Manufacturer')).toBeVisible();
207+
await expect(page.getByText('Manufacturer', { exact: true })).toBeVisible();
206208
await expect(page.getByText('Aegis Dynamics').first()).toBeVisible();
207-
await expect(page.getByText('Hull size')).toBeVisible();
209+
await expect(page.getByText('Hull size', { exact: true })).toBeVisible();
208210
// Full metadata section.
209211
await expect(page.getByText('All metadata')).toBeVisible();
210212
await expect(page.getByText('manufacturer.name')).toBeVisible();

apps/web/src/lib/event-summary-react.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
'use client';
2-
31
/**
42
* ReactNode-returning mirror of `formatEventSummary` in
5-
* `event-summary.ts`. The two functions must produce the same
3+
* `event-summary.ts`.
4+
*
5+
* Universal (no `'use client'`): the function is a pure switch
6+
* returning JSX with no React state, so it can be invoked directly
7+
* from server components (dashboard / journey TypesTab). It DOES
8+
* return `<EntityLink>` instances — those are client components,
9+
* and server components composing client components is the
10+
* standard pattern (the boundary is handled by Next's bundler). The two functions must produce the same
611
* visible text for every variant — but this one inserts
712
* `<EntityLink>` wrappers around resolved entity identifiers so
813
* the dashboard / journey UI can navigate into `/kb/{category}/{slug}`

0 commit comments

Comments
 (0)