Skip to content

Commit bc829ff

Browse files
committed
test(json-render-ui): storybook stories for the unsupported-component placeholder
Add stories covering the new placeholder path — an unknown component type, and a subset registry missing a base component — and document that the SPA hides its nav for a single view.
1 parent 954e34b commit bc829ff

2 files changed

Lines changed: 35 additions & 5 deletions

File tree

docs/guide/json-render.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ export default createJsonRenderDevframe({
115115
```
116116

117117
The SPA discovers views from the **view index** (`JSON_RENDER_INDEX_KEY`), a
118-
shared state the node factory maintains as views are created and disposed. It
119-
renders a single view full-bleed, or presents multiple views under the shared
120-
segmented switcher, labelling each with its `title` (defaulting to the view id).
121-
The `@devframes/json-render-ui/spa` entry is node-safe — it exposes only the
122-
asset path and the wiring helper, pulling in no Vue.
118+
shared state the node factory maintains as views are created and disposed. A
119+
single view renders full-bleed on its own; once more than one view is
120+
registered, a top bar appears with the shared segmented switcher, labelling each
121+
view with its `title` (defaulting to the view id). The
122+
`@devframes/json-render-ui/spa` entry is node-safe — it exposes only the asset
123+
path and the wiring helper, pulling in no Vue.
123124

124125
### Custom frontend
125126

packages/json-render-ui/src/JsonRender.stories.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Spec } from '@devframes/json-render'
22
import type { Meta, StoryObj } from '@storybook/vue3-vite'
33
import { h } from 'vue'
4+
import { baseRegistry } from './registry'
45
import { JsonRenderView } from './renderer'
56

67
// A no-op RPC — stories don't dispatch real actions.
@@ -74,3 +75,31 @@ export const InvalidElement: StoryObj = story({
7475
bad: { type: 'Badge', props: { variant: 'purple' }, children: [] },
7576
},
7677
})
78+
79+
// An element whose `type` is absent from the registry renders behind the
80+
// unsupported placeholder (type + prop-keys gist), while its siblings render.
81+
export const UnsupportedComponent: StoryObj = story({
82+
root: 'root',
83+
elements: {
84+
root: { type: 'Stack', props: { gap: 8 }, children: ['ok', 'chart', 'more'] },
85+
ok: { type: 'Text', props: { text: 'This view uses a component the frontend does not ship.' }, children: [] },
86+
chart: { type: 'Fancy3DChart', props: { data: [1, 2, 3], title: 'Revenue', animate: true }, children: [] },
87+
more: { type: 'Badge', props: { text: 'still renders', variant: 'success' }, children: [] },
88+
},
89+
})
90+
91+
// A frontend that supports only a subset of the catalog: rendering with a
92+
// registry missing `DataTable` placeholders that element, everything else
93+
// renders normally.
94+
const { DataTable: _omitted, ...subsetRegistry } = baseRegistry as Record<string, unknown>
95+
export const SubsetRegistry: StoryObj = story(
96+
{
97+
root: 'root',
98+
elements: {
99+
root: { type: 'Stack', props: { gap: 8 }, children: ['title', 'table'] },
100+
title: { type: 'Text', props: { text: 'Registry without DataTable', variant: 'heading' }, children: [] },
101+
table: { type: 'DataTable', props: { rows: [{ id: 1, name: 'a' }], height: 120 }, children: [] },
102+
},
103+
},
104+
{ registry: subsetRegistry },
105+
)

0 commit comments

Comments
 (0)