Skip to content

test(storybook): add integration tests for generator, registry, and routing#76

Open
geoffjay wants to merge 13 commits into
issue-53from
issue-55
Open

test(storybook): add integration tests for generator, registry, and routing#76
geoffjay wants to merge 13 commits into
issue-53from
issue-55

Conversation

@geoffjay
Copy link
Copy Markdown
Owner

Closes #55

Summary

  • 13 passing tests in crates/nemo-storybook-generator/src/lib.rs
  • Tests cover: XML validity, all categories present, per-component page and nav button generation, sidebar search input, property table data for button, registry search, registry list-by-category, and file output
  • All tests pass: cargo test -p nemo-storybook-generator

Depends on #51, #52, #53. Part of epic #9.

…outing

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
geoffjay and others added 12 commits May 17, 2026 21:50
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…e errors

The layout builder validates required properties during apply_layout; bare
<alert />, <label />, <button /> etc. in preview panels failed with
MissingProperty. Add generate_preview_element() which emits placeholder
values for all required props so the layout builds cleanly.

Also replace the silent .ok() on create_runtime with a tracing::error! so
failures are visible in logs rather than silently falling back to the
project loader.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…abel rows

The generated storybook was instantiating all component pages at startup,
including one code-editor, one table, and one tabs wrapper per component
(53-54 instances each). Code editors are expensive to render due to syntax
highlighting and internal scroll state; having 53 of them in the GPUI tree
simultaneously caused the UI to be unusable.

Replace the per-page table+tabs+code-editor structure with a flat stack of
label elements — one per property showing "name: type = default". Remove
the now-unused attr_escape, generate_xml_snippet, and
generate_property_table_data helpers. Update tests to match.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Add border/margin/rounded to every page panel so component sections are
  visually distinct from one another
- Add padding to the content area stack
- Skip live preview rendering for Charts and Data category components;
  show a placeholder label instead — chart components render "No data"
  without a data source, and table/list/tree render empty

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…anel

Panels wrapped by apply_layout_styles get a div.flex_col.min_h(0) wrapper
without flex_1. The inner Stack always renders with flex_1, which collapses
to zero height inside an auto-height parent — leaving only the border line
visible.

Stacks DO get flex_1 added to their apply_layout_styles wrapper, so moving
border/margin/rounded from the page <panel> to the inner <stack> fixes the
collapse. This matches how the home page panel works (unstyled panel, styled
inner stack).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Sidebar scroll:
- Add scroll="true" to sidebar_inner stack so all categories are reachable

Navigation (three parts):
- Add ExtensionManager::load_script_from_source to load Rhai from a string
- Wire up scripts.inline in load_scripts_from_config: inline CDATA scripts
  are now loaded as the "handlers" script so call_handler("navigate_to")
  finds them
- Fix Rhai function signature to fn navigate_to(component_id, event_data)
  matching call_handler's (component_id, event_data) call convention
- Add on-click="navigate_to" to every sidebar nav button
- Set visible="false" on all component page panels so only the home page
  shows initially; navigate_to hides home and shows the selected page

Layout previews:
- Add ComponentCategory::Layout to the preview skip list; dock/stack/panel/
  tabs render as empty containers with no visible content

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Layout components (stack, panel, tabs, dock) are containers that render
empty when childless. Previously they showed "Connect a data source" which
was wrong. Now each gets a component-specific preview with placeholder
children:

- stack: vertical stack with three label children and a visible border
- panel: panel with a label child
- tabs: two-tab layout with label content in each tab
- dock (and any unrecognised Layout): informational label

Charts and Data categories still show the data-source placeholder.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
All anonymous elements in the layout share a flat component map keyed by
their auto-generated ID (__anon_1, __anon_2, ...). The counter resets for
each children_to_component_map call, so every component page's preview
element and every sidebar category label independently received __anon_1.
Each successive page overwrote the previous in the flat map, leaving all
pages trying to render the same last-inserted component.

Fix by giving every preview element an explicit id ("{name}_preview_ex")
and every sidebar category label an explicit id ("cat_{name}"), eliminating
all __anon_N collisions.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…iews

Charts and Data category components now render with inline sample data
instead of "Connect a data source at runtime to preview this component":

Data components:
- table: 3-row sample with name/score columns
- list: three sample string items
- tree: root node with two children

Chart components (sample data uses field names matching the component's
required x_field/y_field/y_fields):
- line/bar/column/scatter: x+y series data
- area/stacked/clustered variants: x+a+b multi-series data
- realtime: x+y series with y_fields array
- pie: label+value slice data
- candlestick: OHLC data with t/o/h/l/c fields
- bubble: x+y+r point data
- unrecognised chart types: "Sample data preview not available" label

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- stacked_bar_chart / clustered_bar_chart are horizontal — they use
  y_field (category axis) + x_fields (value series array), not the
  column-chart orientation; fix the generated preview accordingly
- Add heatmap_chart preview: x_field, y_field, value_field + grid data
- Add radar_chart preview: categories array + y_fields + data
- Add pyramid_chart / funnel_chart preview: label_field + value_field + data

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant