Skip to content

Commit 745032f

Browse files
author
Juan Andrade
committed
[feature/floating-ui] Merge remote-tracking branch 'origin/main' into feature/floating-ui
2 parents f3c5eed + aa7b86a commit 745032f

File tree

133 files changed

+4035
-2038
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+4035
-2038
lines changed

.changeset/curvy-penguins-grin.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

.changeset/green-kings-hug.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

.changeset/three-jobs-knock.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

.changeset/tidy-lamps-beg.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/chromatic-build.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,32 +90,23 @@ jobs:
9090
- name: Publish to Chromatic for visual testing (review PRs only)
9191
id: chromatic_publish
9292
if: ${{ inputs.target == 'review' }}
93-
uses: chromaui/action@v11
93+
uses: chromaui/action@latest
9494
with:
9595
token: ${{ secrets.GITHUB_TOKEN }}
9696
projectToken: ${{ secrets.projectToken }}
9797
storybookBuildDir: storybook-static
9898
autoAcceptChanges: "main"
99+
# Exit with status 0 (OK) once the built version has been published to
100+
# Chromatic.
101+
exitOnceUploaded: true
99102
# Generate snapshots for only changed stories
100103
# See: https://www.chromatic.com/docs/turbosnap
101104
onlyChanged: true
102105

103-
# TODO(WB-1936): Re-enable this check once the issue with Chromatic
104-
# is resolved.
105-
# Install Playwright browsers so Vitest browser mode can run story tests
106-
# - name: Install playwright dependencies
107-
# if: ${{ inputs.target == 'review' }}
108-
# run: pnpm exec playwright install chromium --with-deps
109-
# - name: Run Storybook tests
110-
# if: ${{ inputs.target == 'review' }}
111-
# run: pnpm test:storybook
112-
# env:
113-
# SB_URL: '${{ steps.chromatic_publish.outputs.storybookUrl }}'
114-
115106
# (if) Run this step on dependabot or changesets PRs.
116107
- name: Skip Chromatic builds (dependabot or changesets PRs)
117108
if: ${{ inputs.target == 'bot' }}
118-
uses: chromaui/action@v11
109+
uses: chromaui/action@latest
119110
with:
120111
token: ${{ secrets.GITHUB_TOKEN }}
121112
projectToken: ${{ secrets.projectToken }}
@@ -128,7 +119,7 @@ jobs:
128119
# (if) Run this step on the main branch.
129120
- name: Auto-accept Chromatic build on main branch.
130121
if: ${{ inputs.target == 'main' }}
131-
uses: chromaui/action@v11
122+
uses: chromaui/action@latest
132123
with:
133124
token: ${{ secrets.GITHUB_TOKEN }}
134125
projectToken: ${{ secrets.projectToken }}

.github/workflows/chromatic-pr.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
if: |
2828
github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' &&
2929
!startsWith(github.head_ref, 'changeset-release/')
30-
name: Chromatic - Build and test on regular PRs
30+
name: Build on regular PRs
3131
uses: ./.github/workflows/chromatic-build.yml
3232
with:
3333
target: 'review'
@@ -39,7 +39,7 @@ jobs:
3939
if: |
4040
github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' &&
4141
!startsWith(github.head_ref, 'changeset-release/')
42-
name: Chromatic - Get results on regular PRs
42+
name: Get results on regular PRs
4343
needs: chromatic_review
4444
runs-on: ${{ matrix.os }}
4545
strategy:
@@ -76,3 +76,44 @@ jobs:
7676
| Total stories | ${{ needs.chromatic_review.outputs.specCount }} |
7777
| Inherited (not captured) snapshots [TurboSnap] | ${{ needs.chromatic_review.outputs.inheritedCaptureCount }} |
7878
| Tests on the build | ${{ needs.chromatic_review.outputs.testCount }} |
79+
80+
storybook_tests:
81+
# (if) Run this step on regular PRs.
82+
if: |
83+
github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' &&
84+
!startsWith(github.head_ref, 'changeset-release/')
85+
name: Run Storybook tests
86+
needs: chromatic_review
87+
runs-on: ${{ matrix.os }}
88+
strategy:
89+
fail-fast: false
90+
matrix:
91+
os: [ubuntu-latest]
92+
node-version: [20.x]
93+
steps:
94+
- name: Checking out latest commit
95+
uses: actions/checkout@v4
96+
97+
- name: Use Node.js ${{ matrix.node-version }}
98+
uses: actions/setup-node@v4
99+
with:
100+
node-version: ${{ matrix.node-version }}
101+
102+
# Cache and install dependencies
103+
- name: Install & cache node_modules
104+
uses: ./.github/actions/shared-node-cache
105+
with:
106+
node-version: ${{ matrix.node-version }}
107+
108+
# Install Playwright browsers so Vitest browser mode can run story tests
109+
- name: Install playwright dependencies
110+
run: pnpm exec playwright install chromium --with-deps
111+
112+
# Build the project
113+
- name: Generate WB build artifacts
114+
run: pnpm build
115+
116+
- name: Run Storybook tests
117+
run: pnpm test:storybook
118+
env:
119+
SB_URL: '${{ needs.chromatic_review.outputs.storybookUrl }}'

.github/workflows/publish.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,10 @@ jobs:
156156
# PR code in a host applicaiton without doing a release.
157157
publish_snapshot:
158158
name: Publish npm snapshot
159-
# [FEI-7341] DISABLED: Snapshots temporarily disabled due to security concerns (shai-halud worm)
160-
# To re-enable, replace the condition below with the original multi-line condition
161-
if: false
162-
# Original condition (commented out):
163-
# if: |
164-
# (github.event_name == 'workflow_dispatch' && inputs.run_type == 'snapshot') ||
165-
# (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'changeset-release/'))
159+
# We don't publish snapshots on Changeset "Version Packages" PRs
160+
if: |
161+
(github.event_name == 'workflow_dispatch' && inputs.run_type == 'snapshot') ||
162+
(github.event_name == 'pull_request' && !startsWith(github.head_ref, 'changeset-release/'))
166163
runs-on: ${{ matrix.os }}
167164
permissions:
168165
id-token: write # required for publishing to npm with provenance

.storybook/main.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
1-
import { createRequire } from "node:module";
2-
import { dirname, join } from "node:path";
31
import remarkGfm from "remark-gfm";
42
import type {StorybookConfig} from "@storybook/react-vite";
53

6-
const require = createRequire(import.meta.url);
7-
84
const config: StorybookConfig = {
95
stories: [
106
"../__docs__/**/*.@(mdx|stories.@(ts|tsx))",
117
"../__docs__/**/*.mdx",
128
],
139
addons: [
14-
getAbsolutePath("@storybook/addon-a11y"),
15-
getAbsolutePath("storybook-addon-pseudo-states"),
16-
getAbsolutePath("@storybook/addon-vitest"),
10+
"@storybook/addon-a11y",
11+
"storybook-addon-pseudo-states",
12+
"@storybook/addon-vitest",
1713
{
18-
name: getAbsolutePath("@storybook/addon-docs"),
14+
name: "@storybook/addon-docs",
1915
options: {
2016
mdxPluginOptions: {
2117
mdxCompileOptions: {
2218
remarkPlugins: [remarkGfm],
2319
},
2420
},
2521
},
26-
}
22+
},
2723
],
2824
staticDirs: ["../static"],
2925
core: {
30-
builder: getAbsolutePath("@storybook/builder-vite"),
26+
builder: "@storybook/builder-vite",
3127
disableTelemetry: true,
3228
},
33-
framework: getAbsolutePath("@storybook/react-vite"),
29+
framework: "@storybook/react-vite",
3430
async viteFinal(config) {
3531
// Merge custom configuration into the default config
3632
const {mergeConfig} = await import("vite");
@@ -45,7 +41,3 @@ const config: StorybookConfig = {
4541
};
4642

4743
export default config;
48-
49-
function getAbsolutePath(value: string): any {
50-
return dirname(require.resolve(join(value, "package.json")));
51-
}

.storybook/preview.tsx

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from "react";
22
import wonderBlocksTheme from "./wonder-blocks-theme";
33
import {Decorator} from "@storybook/react-vite";
44
import {DocsContainer} from "@storybook/addon-docs/blocks";
5-
import {RenderStateRoot} from "@khanacademy/wonder-blocks-core";
65
import {semanticColor} from "@khanacademy/wonder-blocks-tokens";
76
import {initAnnouncer} from "@khanacademy/wonder-blocks-announcer";
87
import Link from "@khanacademy/wonder-blocks-link";
@@ -11,7 +10,7 @@ import {
1110
ThemeSwitcher,
1211
THEME_DATA_ATTRIBUTE,
1312
} from "@khanacademy/wonder-blocks-theming";
14-
import {Preview} from "@storybook/react-vite";
13+
import type {Preview} from "@storybook/react-vite";
1514

1615
// Import the Wonder Blocks CSS variables
1716
import "@khanacademy/wonder-blocks-tokens/styles.css";
@@ -75,8 +74,26 @@ function DocsContainerWithTheme({children, context, ...props}) {
7574
}
7675

7776
const parameters: Preview["parameters"] = {
78-
// Enable the RenderStateRoot decorator by default.
79-
enableRenderStateRootDecorator: true,
77+
// Accessibility testing configuration
78+
a11y: {
79+
/*
80+
* Configure test behavior. Error means that any a11y violations will fail the tests in CI.
81+
* See: https://storybook.js.org/docs/next/writing-tests/accessibility-testing#test-behavior
82+
*/
83+
test: "error",
84+
/*
85+
* Axe's configuration
86+
* See https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axeconfigure
87+
* to learn more about the available properties.
88+
*/
89+
config: {},
90+
/*
91+
* Axe's options parameter
92+
* See https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#options-parameter
93+
* to learn more about the available options.
94+
*/
95+
options: {},
96+
},
8097
backgrounds: {
8198
default: "baseDefault",
8299
options: {
@@ -109,6 +126,7 @@ const parameters: Preview["parameters"] = {
109126
},
110127
},
111128
docs: {
129+
codePanel: true,
112130
// Customize the DocsContainer to use the WB theme in MDX pages.
113131
container: DocsContainerWithTheme,
114132
toc: {
@@ -129,10 +147,7 @@ const parameters: Preview["parameters"] = {
129147
},
130148
};
131149

132-
const withThemeSwitcher: Decorator = (
133-
Story,
134-
{globals: {theme}, parameters: {enableRenderStateRootDecorator}},
135-
) => {
150+
const withThemeSwitcher: Decorator = (Story, {globals: {theme}}) => {
136151
// Keep track of the theme locally so we can re-render the story after the
137152
// attribute is updated.
138153
const [localTheme, setLocalTheme] = React.useState(null);
@@ -144,18 +159,6 @@ const withThemeSwitcher: Decorator = (
144159
}
145160
}, [theme]);
146161

147-
if (enableRenderStateRootDecorator) {
148-
return (
149-
<RenderStateRoot key={localTheme}>
150-
<ThemeSwitcherContext.Provider value={theme}>
151-
<ThemeSwitcher theme={theme}>
152-
<Story />
153-
</ThemeSwitcher>
154-
</ThemeSwitcherContext.Provider>
155-
</RenderStateRoot>
156-
);
157-
}
158-
159162
return (
160163
<ThemeSwitcherContext.Provider value={theme} key={localTheme}>
161164
<ThemeSwitcher theme={theme}>

.storybook/vitest.setup.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import { beforeAll } from 'vitest';
2-
import { setProjectAnnotations } from '@storybook/react-vite';
3-
import * as projectAnnotations from './preview';
1+
import {beforeAll} from "vitest";
2+
import {setProjectAnnotations} from "@storybook/react-vite";
3+
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
4+
5+
import * as previewAnnotations from "./preview";
46

57
// This is an important step to apply the right configuration when testing your stories.
68
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7-
const project = setProjectAnnotations([projectAnnotations]);
9+
const annotations = setProjectAnnotations([
10+
a11yAddonAnnotations,
11+
previewAnnotations,
12+
]);
813

9-
beforeAll(project.beforeAll);
14+
beforeAll(annotations.beforeAll);

0 commit comments

Comments
 (0)