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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQAumujy5kXaOKurr6zgTP2krHrFVXi2kj8seRYrlvq2GssUjReh5MiVpQbLFQNy9HsmcasqpBNVsXytWTw0ZDjA=

Testing and stories

By the end of this guide you have a story for a TILE component, with the theme and the translations it needs.

A story is one state of a component, rendered on its own in Storybook with no app around it. A component that takes its data as props is easy to show this way. DXOS writes a story for each component, and runs the stories as tests.

A story needs the theme provider, react-ui’s translations and the component’s own. withTheme from @dxos/react-ui/testing wraps the story in Theme.Provider with Theme.defaultTx, and passes the story’s translations parameter as its resources. Use it on every story of a TILE component.

The component here is ContactList from TILE in a PLEX plugin. It is a list of contacts that shows a hint when it has none:

import {
const withTheme: ({ tx, platform }?: Partial<Theme.ThemeContextValue>) => Decorator

Adds theme decorator.

withTheme
} from '@dxos/react-ui/testing';
export default {
title: string
title
: 'contacts/ContactList',
component: ({ contacts, onSelect }: ContactListProps) => React.JSX.Element
component
:
const ContactList: ({ contacts, onSelect }: ContactListProps) => React.JSX.Element

Takes its data and callbacks as props; a container reads them from the app and passes them in.

ContactList
,
decorators: Decorator[]
decorators
: [
function withTheme({ tx, platform }?: Partial<Theme.ThemeContextValue>): Decorator

Adds theme decorator.

withTheme
()],
// react-ui's strings, and the component's own.
parameters: {
translations: ({
readonly 'en-US': {
readonly "@dxos/react-ui": {
readonly "empty.label": "No items";
readonly "error-fallback.title.label": "Runtime Error";
readonly "error-fallback.stack.label": "Stack";
readonly "error-fallback.data.label": "Data";
readonly "steps.step.label": "Step {{index}}";
readonly "remove.label": "Delete";
readonly "toolbar-menu.label": "Action menu";
readonly "toolbar-drag-handle.label": "Drag to rearrange";
readonly "toolbar-close.label": "Close";
readonly "toolbar-delete.label": "Delete";
readonly "floating-panel.minimize.label": "Minimize";
readonly "floating-panel.maximize.label": "Maximize";
readonly "floating-panel.restore.label": "Restore";
readonly "drawer.resize.label": "Resize drawer";
readonly "system-button.star.label": "Star";
readonly "system-button.unstar.label": "Unstar";
readonly "system-button.bookmark.label": "Bookmark";
readonly "system-button.unbookmark.label": "Remove bookmark";
readonly "system-button.check.label": "Check";
readonly "system-button.uncheck.label": "Uncheck";
readonly "system-button.expand.label": "Expand";
readonly "system-button.collapse.label": "Collapse";
readonly "system-button.ai.label": "Run AI";
readonly "system-button.add.label": "Add";
readonly "system-button.delete.label": "Delete";
readonly "system-button.remove.label": "Delete";
readonly "system-button.edit.label": "Edit";
readonly "system-button.close.label": "Close";
readonly "system-button.open.label": "Open";
readonly "system-button.save.label": "Save";
readonly "system-button.cancel.label": "Cancel";
readonly "system-button.upload.label": "Upload";
readonly "system-button.download.label": "Download";
readonly "system-button.clipboard.label": "Copy";
readonly "system-button.copied.label": "Copied";
readonly "carousel-viewport.label": "Carousel";
readonly "carousel-prev.label": "Previous slide";
readonly "carousel-next.label": "Next slide";
readonly "carousel-indicators.label": "Carousel slides";
readonly "carousel-go-to.label": "Go to slide {{index}}";
readonly "date-picker.placeholder.single.label": "Pick a date";
readonly "date-picker.placeholder.range.label": "Pick a date range";
readonly "date-picker.placeholder.multiple.label": "Pick dates";
readonly "date-picker.clear.label": "Clear";
readonly "calendar.nav.previous.label": "Previous month";
readonly "calendar.nav.next.label": "Next month";
readonly "calendar.nav.previous-year.label": "Previous year";
readonly "calendar.nav.next-year.label": "Next year";
readonly "calendar.nav.previous-decade.label": "Previous decade";
readonly "calendar.nav.next-decade.label": "Next decade";
readonly "calendar.footer.today.label": "Today";
readonly "trigger-button.label": "Open";
readonly "number-input.increment.label": "Increment";
readonly "number-input.decrement.label": "Decrement";
readonly "number-input.slider.label": "Adjust";
readonly "password-input.show.label": "Show password";
readonly "password-input.hide.label": "Hide password";
readonly "tag.delete.label": "Remove {{label}}";
readonly "combobox.search.label": "Search";
readonly "combobox.empty.label": "No results";
readonly "combobox.loading.label": "Loading\u2026";
readonly "combobox.create.label": "Create \u201C{{query}}\u201D";
readonly "drag-handle.label": "Drag to rearrange";
readonly "drag-handle.role.label": "drag handle";
readonly "drag-handle.grabbed.message": "Grabbed. Press the arrow keys to move, Space to drop.";
readonly "drag-handle.moved-up.message": "Moved up.";
readonly "drag-handle.moved-down.message": "Moved down.";
readonly "drag-handle.dropped.message": "Dropped.";
};
};
} | {
...;
})[];
}
parameters
: {
translations: ({
readonly 'en-US': {
readonly "@dxos/react-ui": {
readonly "empty.label": "No items";
readonly "error-fallback.title.label": "Runtime Error";
readonly "error-fallback.stack.label": "Stack";
readonly "error-fallback.data.label": "Data";
readonly "steps.step.label": "Step {{index}}";
readonly "remove.label": "Delete";
readonly "toolbar-menu.label": "Action menu";
readonly "toolbar-drag-handle.label": "Drag to rearrange";
readonly "toolbar-close.label": "Close";
readonly "toolbar-delete.label": "Delete";
readonly "floating-panel.minimize.label": "Minimize";
readonly "floating-panel.maximize.label": "Maximize";
readonly "floating-panel.restore.label": "Restore";
readonly "drawer.resize.label": "Resize drawer";
readonly "system-button.star.label": "Star";
readonly "system-button.unstar.label": "Unstar";
readonly "system-button.bookmark.label": "Bookmark";
readonly "system-button.unbookmark.label": "Remove bookmark";
readonly "system-button.check.label": "Check";
readonly "system-button.uncheck.label": "Uncheck";
readonly "system-button.expand.label": "Expand";
readonly "system-button.collapse.label": "Collapse";
readonly "system-button.ai.label": "Run AI";
readonly "system-button.add.label": "Add";
readonly "system-button.delete.label": "Delete";
readonly "system-button.remove.label": "Delete";
readonly "system-button.edit.label": "Edit";
readonly "system-button.close.label": "Close";
readonly "system-button.open.label": "Open";
readonly "system-button.save.label": "Save";
readonly "system-button.cancel.label": "Cancel";
readonly "system-button.upload.label": "Upload";
readonly "system-button.download.label": "Download";
readonly "system-button.clipboard.label": "Copy";
readonly "system-button.copied.label": "Copied";
readonly "carousel-viewport.label": "Carousel";
readonly "carousel-prev.label": "Previous slide";
readonly "carousel-next.label": "Next slide";
readonly "carousel-indicators.label": "Carousel slides";
readonly "carousel-go-to.label": "Go to slide {{index}}";
readonly "date-picker.placeholder.single.label": "Pick a date";
readonly "date-picker.placeholder.range.label": "Pick a date range";
readonly "date-picker.placeholder.multiple.label": "Pick dates";
readonly "date-picker.clear.label": "Clear";
readonly "calendar.nav.previous.label": "Previous month";
readonly "calendar.nav.next.label": "Next month";
readonly "calendar.nav.previous-year.label": "Previous year";
readonly "calendar.nav.next-year.label": "Next year";
readonly "calendar.nav.previous-decade.label": "Previous decade";
readonly "calendar.nav.next-decade.label": "Next decade";
readonly "calendar.footer.today.label": "Today";
readonly "trigger-button.label": "Open";
readonly "number-input.increment.label": "Increment";
readonly "number-input.decrement.label": "Decrement";
readonly "number-input.slider.label": "Adjust";
readonly "password-input.show.label": "Show password";
readonly "password-input.hide.label": "Hide password";
readonly "tag.delete.label": "Remove {{label}}";
readonly "combobox.search.label": "Search";
readonly "combobox.empty.label": "No results";
readonly "combobox.loading.label": "Loading\u2026";
readonly "combobox.create.label": "Create \u201C{{query}}\u201D";
readonly "drag-handle.label": "Drag to rearrange";
readonly "drag-handle.role.label": "drag handle";
readonly "drag-handle.grabbed.message": "Grabbed. Press the arrow keys to move, Space to drop.";
readonly "drag-handle.moved-up.message": "Moved up.";
readonly "drag-handle.moved-down.message": "Moved down.";
readonly "drag-handle.dropped.message": "Dropped.";
};
};
} | {
...;
})[]
translations
: [...
const uiTranslations: [{
readonly 'en-US': {
readonly "@dxos/react-ui": {
readonly "empty.label": "No items";
readonly "error-fallback.title.label": "Runtime Error";
readonly "error-fallback.stack.label": "Stack";
readonly "error-fallback.data.label": "Data";
readonly "steps.step.label": "Step {{index}}";
readonly "remove.label": "Delete";
readonly "toolbar-menu.label": "Action menu";
readonly "toolbar-drag-handle.label": "Drag to rearrange";
readonly "toolbar-close.label": "Close";
readonly "toolbar-delete.label": "Delete";
readonly "floating-panel.minimize.label": "Minimize";
readonly "floating-panel.maximize.label": "Maximize";
readonly "floating-panel.restore.label": "Restore";
readonly "drawer.resize.label": "Resize drawer";
readonly "system-button.star.label": "Star";
readonly "system-button.unstar.label": "Unstar";
readonly "system-button.bookmark.label": "Bookmark";
readonly "system-button.unbookmark.label": "Remove bookmark";
readonly "system-button.check.label": "Check";
readonly "system-button.uncheck.label": "Uncheck";
readonly "system-button.expand.label": "Expand";
readonly "system-button.collapse.label": "Collapse";
readonly "system-button.ai.label": "Run AI";
readonly "system-button.add.label": "Add";
readonly "system-button.delete.label": "Delete";
readonly "system-button.remove.label": "Delete";
readonly "system-button.edit.label": "Edit";
readonly "system-button.close.label": "Close";
readonly "system-button.open.label": "Open";
readonly "system-button.save.label": "Save";
readonly "system-button.cancel.label": "Cancel";
readonly "system-button.upload.label": "Upload";
readonly "system-button.download.label": "Download";
readonly "system-button.clipboard.label": "Copy";
readonly "system-button.copied.label": "Copied";
readonly "carousel-viewport.label": "Carousel";
readonly "carousel-prev.label": "Previous slide";
readonly "carousel-next.label": "Next slide";
readonly "carousel-indicators.label": "Carousel slides";
readonly "carousel-go-to.label": "Go to slide {{index}}";
readonly "date-picker.placeholder.single.label": "Pick a date";
readonly "date-picker.placeholder.range.label": "Pick a date range";
readonly "date-picker.placeholder.multiple.label": "Pick dates";
readonly "date-picker.clear.label": "Clear";
readonly "calendar.nav.previous.label": "Previous month";
readonly "calendar.nav.next.label": "Next month";
readonly "calendar.nav.previous-year.label": "Previous year";
readonly "calendar.nav.next-year.label": "Next year";
readonly "calendar.nav.previous-decade.label": "Previous decade";
readonly "calendar.nav.next-decade.label": "Next decade";
readonly "calendar.footer.today.label": "Today";
readonly "trigger-button.label": "Open";
readonly "number-input.increment.label": "Increment";
readonly "number-input.decrement.label": "Decrement";
readonly "number-input.slider.label": "Adjust";
readonly "password-input.show.label": "Show password";
readonly "password-input.hide.label": "Hide password";
readonly "tag.delete.label": "Remove {{label}}";
readonly "combobox.search.label": "Search";
readonly "combobox.empty.label": "No results";
readonly "combobox.loading.label": "Loading\u2026";
readonly "combobox.create.label": "Create \u201C{{query}}\u201D";
readonly "drag-handle.label": "Drag to rearrange";
readonly "drag-handle.role.label": "drag handle";
readonly "drag-handle.grabbed.message": "Grabbed. Press the arrow keys to move, Space to drop.";
readonly "drag-handle.moved-up.message": "Moved up.";
readonly "drag-handle.moved-down.message": "Moved down.";
readonly "drag-handle.dropped.message": "Dropped.";
};
};
}]
uiTranslations
, ...
const translations: [{
...;
}]
translations
] },
};
export const
const Default: {
args: {
contacts: {
id: string;
name: string;
}[];
};
}
Default
= {
args: {
contacts: {
id: string;
name: string;
}[];
}
args
: {
contacts: {
id: string;
name: string;
}[]
contacts
: [
{
id: string
id
: 'ada',
name: string
name
: 'Ada Lovelace' },
{
id: string
id
: 'grace',
name: string
name
: 'Grace Hopper' },
],
},
};
export const
const NoContacts: {
args: {
contacts: never[];
};
}
NoContacts
= {
args: {
contacts: never[];
}
args
: {
contacts: never[]
contacts
: [] } };

Default and NoContacts are two stories, because each export after the default is one. Write a story per state, rather than one story with every state at once. A change to the empty list then shows in NoContacts and nowhere else.

withTheme also passes Storybook’s theme global to the provider as themeMode. A component that calls useThemeMode then gets the mode that the switcher in Storybook’s toolbar chose.

Your app’s Storybook needs the same Vite setup as the app. Add ThemePlugin and IconsPlugin from Installation, and put the two stylesheet imports in its preview file.

@dxos/react-ui/testing also exports the helpers DXOS’s own stories use:

Export Use
withTheme The theme provider for a story
withLayout A frame around the story, with classNames for its size and padding
withSizes, SIZE_ARG_TYPES The story at the size its size arg names, and the control that picks it
Loading A loading placeholder for a story
ThrowError A component that throws after a delay, for trying an error boundary

A story can also test behavior. A play function is code that Storybook runs in the browser after it renders the story. For example, a play function can open a dialog, press a key, and check where focus went. Target elements by data-testid, which TILE parts pass through to their element.