clients/.storybook/preview.tsx
Will Martin 69c937e592
[CL-954] Upgrade to Angular 21 (#19725)
* prune desktop packages

* Fix @napi-rs/cli version mismatch in desktop napi workspace

Aligns package.json declaration with the locked version (3.2.0) to
resolve npm workspace inconsistency that was blocking ng update.

* update Storybook to v10

* update Angular to v21

* override jest in ng builder

* Add jest-environment-jsdom as explicit dependency

Previously installed as a side effect of a jest@29 override; removing
that override caused it to disappear from node_modules.

* Add .claude/worktrees/ to .gitignore

* Restore @napi-rs/cli to 3.5.1 to match main

* Pin jest-environment-jsdom to 29.7.0 and add to renovate config

* Override jest-environment-jsdom to 29.7.0 in build-angular context

* Add isolatedModules to libs/subscription tsconfig.spec.json to fix Angular 21 module resolution

* Change moduleResolution to bundler for Angular 21 subpath export compatibility

* Add isolatedModules to Angular libs with old spec tsconfig pattern

* Disable emitDecoratorMetadata in spec tsconfigs with isolatedModules

* Fix HostListener event parameter types for Angular 21 compiler strictness

* Revert accidental change to access-selector spec

* Remove accidentally generated desktop package-lock.json

* Fix type-only imports/exports caught by Rolldown in Storybook v10/Vite v8

* fix vault-wrapper type error from Angular 21 stricter generic inference

ngComponentOutlet accepts Type<unknown>; annotate computed() explicitly
since VaultComponent is generic and VaultOrigComponent is not, preventing
TypeScript from inferring a compatible union constructor type.

* Fix kitchen-sink interaction tests for Storybook v10

Replace fire-and-forget navigateTo + synchronous getByRole with
navigateAndWaitFor<T>, which sets the hash and retries the ready
callback via waitFor. Storybook v10 starts play functions before
Angular's initial router navigation completes, so synchronous DOM
queries after navigation were failing intermittently.

* Provide ZoneJS change detection scheduler for Storybook stories

Angular 21 no longer sets up the ZoneJS change detection scheduler by
default in bootstrapApplication. Storybook's Angular renderer uses
bootstrapApplication internally and does not add provideZoneChangeDetection
automatically, so Default CD components relying on zone.js to trigger
re-renders after async operations were not updating before Chromatic
snapshots.

* Wait for dialog/side nav to render before Chromatic snapshot

After userEvent.click the dialog and side nav open asynchronously.
Without an explicit waitFor, Chromatic captures the snapshot before the
resulting UI state is present.

* Fix kitchen-sink waitFor: re-query side nav button, use querySelector for dialog

- openSideNav: re-query the toggle button inside waitFor to avoid reading
  a stale DOM reference after Angular re-renders the element post-click
- SimpleDialogOpen / VirtualScrollBlockingDialog: replace getByRole("dialog")
  with querySelector("cdk-dialog-container") to avoid testing-library's
  visibility check failing on a momentarily inaccessible overlay element

* Revert kitchen-sink stories to main

* Bump Angular, Storybook, and ng-select to latest patch versions

* Trigger pre-commit hooks on merge

* Regenerate package-lock.json with --force to fix npm ci sync
2026-05-18 10:55:47 -05:00

66 lines
1.5 KiB
TypeScript

import { provideZoneChangeDetection } from "@angular/core";
import { setCompodocJson } from "@storybook/addon-docs/angular";
import { withThemeByClassName } from "@storybook/addon-themes";
import { applicationConfig, componentWrapperDecorator } from "@storybook/angular";
import type { Preview } from "@storybook/angular";
import docJson from "../documentation.json";
setCompodocJson(docJson);
const wrapperDecorator = componentWrapperDecorator((story) => {
return /*html*/ `
<div class="tw-bg-bg-primary tw-px-5 tw-py-10 tw-@container">
${story}
</div>
`;
});
const preview: Preview = {
decorators: [
applicationConfig({
providers: [provideZoneChangeDetection()],
}),
withThemeByClassName({
themes: {
light: "theme_light",
dark: "theme_dark",
},
defaultTheme: "light",
}),
wrapperDecorator,
],
parameters: {
a11y: {
context: {
include: ["#storybook-root", ".cdk-overlay-container"],
exclude: [".cdk-visually-hidden"],
},
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
options: {
storySort: {
method: "alphabetical",
order: ["Documentation", ["Introduction", "Colors", "Icons"], "Component Library"],
},
},
docs: {
source: {
type: "dynamic",
excludeDecorators: true,
},
},
backgrounds: {
disabled: true,
},
},
tags: ["autodocs"],
};
export default preview;