fix(review-gates): green success badges, null-safe preview rows, optional section items
- Extract shared statusBadgeClass() helper (src/viewers/statusBadge.ts) so SqlViewer, CteResultViewer and PhaseSummaryViewer can't drift: ok/success/ passed/promoted render green (--success), warn renders amber (--warning), error/failed stay destructive red, everything else stays neutral outline. Previously CteResultViewer/PhaseSummaryViewer mapped "ok"/"promoted" to the default badge variant, which is bg-primary (GSD red) — success states rendered red. - enrich.js: buildCteResultV2 now falls back preview.rows to [] instead of null when last_test.preview_rows is missing (pre-upgrade ok records), and CteResultViewer reads result.preview?.rows?.length with a null-safe fallback so it degrades to the "No preview rows" empty state instead of crashing. - PhaseSummaryViewer: section.items is optional (model-authored sections can be prose-only); render (section.items ?? []) instead of crashing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,16 @@ test("renders open_questions as a bullet list", () => {
|
||||
expect(screen.getByText("Serve confermare la finestra temporale?")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test("renders a section with title only (no items key) without crashing", () => {
|
||||
const proseOnly: PhaseSummaryV2 = {
|
||||
schema_version: 2,
|
||||
phase: { id: "F5", num: 5, name: "sintesi" },
|
||||
sections: [{ title: "Note libere" }],
|
||||
};
|
||||
render(<PhaseSummaryViewer phase={proseOnly} />);
|
||||
expect(screen.getByText("Note libere")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test("omits open_questions section when empty and shows no 'undefined' text", () => {
|
||||
const minimal: PhaseSummaryV2 = {
|
||||
schema_version: 2,
|
||||
|
||||
Reference in New Issue
Block a user