Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Storybook 7 #726

Merged
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
6371ad5
chore: initial work on upgrading storybook
daniel-heppner-ibigroup Mar 18, 2024
ea46e33
add test runner
daniel-heppner-ibigroup Mar 19, 2024
0c5d27a
fix react intl
daniel-heppner-ibigroup Mar 20, 2024
50db8b5
deps: upgrade react to 18
daniel-heppner-ibigroup Mar 29, 2024
675397b
fix trimet icon export names
daniel-heppner-ibigroup Apr 5, 2024
817ecc6
test: create snapshots
daniel-heppner-ibigroup Apr 5, 2024
d40c3e2
update node-ci workflow for new tests
daniel-heppner-ibigroup Apr 5, 2024
90c80e6
remove old test file
daniel-heppner-ibigroup Apr 5, 2024
c881a6e
use mock ids for snapshots
daniel-heppner-ibigroup Apr 5, 2024
07f68d8
commit snapshots current state
daniel-heppner-ibigroup Apr 7, 2024
879241a
rerun snapshots with delay
daniel-heppner-ibigroup Apr 8, 2024
fde4456
add a11y test
daniel-heppner-ibigroup Apr 10, 2024
9999917
update ci test command
daniel-heppner-ibigroup Apr 10, 2024
39c3bc7
test: overwrite all classnames
daniel-heppner-ibigroup Apr 11, 2024
9091897
use date mocking in stories with current date/time
daniel-heppner-ibigroup Apr 19, 2024
2084689
extend wait time before capturing
daniel-heppner-ibigroup Apr 19, 2024
0ccaa07
allow a11y and snapshot tests to be run separately
daniel-heppner-ibigroup Apr 19, 2024
3b082bf
attempt fixing the timezone
daniel-heppner-ibigroup Apr 19, 2024
819a726
Merge branch 'master' into upgrade-storybook7
daniel-heppner-ibigroup Apr 19, 2024
0385d4a
attempt using custom version of storybook plugin
daniel-heppner-ibigroup Apr 22, 2024
68689df
fix bug in flattening of i18n files
daniel-heppner-ibigroup Apr 25, 2024
6e6b7fb
another attempt at separating the a11y and snapshot tests
daniel-heppner-ibigroup Apr 25, 2024
edec18e
fix yaml syntax
daniel-heppner-ibigroup Apr 25, 2024
bf608c8
fix typo
daniel-heppner-ibigroup Apr 25, 2024
07f5a0d
try fixed width for itinerary body stories
daniel-heppner-ibigroup Apr 25, 2024
fbd20cf
update snapshots
daniel-heppner-ibigroup Apr 25, 2024
8dc5e58
force set viewport size
daniel-heppner-ibigroup Apr 25, 2024
2705465
add position relative to wrapper
daniel-heppner-ibigroup Apr 25, 2024
bb28726
update snapshots after forcing viewport size
daniel-heppner-ibigroup Apr 25, 2024
3987954
give up, just detect test runner and bypass problem
daniel-heppner-ibigroup Apr 25, 2024
f60d8a8
update snapshots
daniel-heppner-ibigroup Apr 25, 2024
d1128fd
Revert "add position relative to wrapper"
daniel-heppner-ibigroup Apr 25, 2024
7acfe88
Revert "force set viewport size"
daniel-heppner-ibigroup Apr 25, 2024
0eba0e2
Revert "try fixed width for itinerary body stories"
daniel-heppner-ibigroup Apr 25, 2024
55063d1
update snapshots
daniel-heppner-ibigroup Apr 25, 2024
14b1cf2
deps: upgrade react peer dependencies
daniel-heppner-ibigroup Apr 26, 2024
91444ae
add controls
daniel-heppner-ibigroup May 14, 2024
4cfb67c
Merge branch 'master' into upgrade-storybook7
daniel-heppner-ibigroup May 14, 2024
50b439f
rename story prop to match component
daniel-heppner-ibigroup May 14, 2024
b471a1c
docs: add note to readme about hidden addon bar
daniel-heppner-ibigroup May 14, 2024
bb64daa
add permanent fix for addon bar bug
daniel-heppner-ibigroup May 14, 2024
c86871f
address PR feedback
daniel-heppner-ibigroup May 14, 2024
dccd952
chore(lockfile): update caniuse
miles-grant-ibigroup May 30, 2024
52a7444
Merge branch 'master' into upgrade-storybook7
daniel-heppner-ibigroup Jun 5, 2024
4463362
Merge branch 'master' into upgrade-storybook7
daniel-heppner-ibigroup Jun 5, 2024
ceacd3e
deps: update internal dependencies
daniel-heppner-ibigroup Jun 5, 2024
f711776
add custom suspense with test mode fallback
daniel-heppner-ibigroup Jun 5, 2024
491de28
disable some incorrect a11y tests
daniel-heppner-ibigroup Jun 11, 2024
6aff951
fix(location-field): hide listbox when menu hidden
daniel-heppner-ibigroup Jun 15, 2024
935ebf1
fix failing location field test
daniel-heppner-ibigroup Jun 15, 2024
bd26e2e
Merge branch 'master' into upgrade-storybook7
daniel-heppner-ibigroup Jun 15, 2024
a686b62
Merge branch 'master' into upgrade-storybook7
daniel-heppner-ibigroup Jun 15, 2024
62ae8a1
fix github action
daniel-heppner-ibigroup Jun 15, 2024
108d5e1
update snapshots
daniel-heppner-ibigroup Jun 17, 2024
886f9c9
update snapshots again
daniel-heppner-ibigroup Jun 17, 2024
6cb1366
Merge branch 'master' into upgrade-storybook7
daniel-heppner-ibigroup Jun 17, 2024
ba9cfce
update snapshots
daniel-heppner-ibigroup Jun 17, 2024
4d53e33
dont run on dev server
daniel-heppner-ibigroup Jun 17, 2024
309114b
update map snapshots!!! again!
daniel-heppner-ibigroup Jun 17, 2024
f0cd633
maps!
daniel-heppner-ibigroup Jun 17, 2024
d79337a
4th time is the charm!
daniel-heppner-ibigroup Jun 17, 2024
156f345
add nock for map tiles
daniel-heppner-ibigroup Jun 17, 2024
9a49c6a
deps: update msw
daniel-heppner-ibigroup Jun 18, 2024
cb87774
update nocks
daniel-heppner-ibigroup Jun 18, 2024
6379d76
ci: use new node
daniel-heppner-ibigroup Jun 18, 2024
fe23cf6
disable all map snapshots
daniel-heppner-ibigroup Jun 19, 2024
eda24fe
ci: recombine
daniel-heppner-ibigroup Jun 20, 2024
05a7ad4
try disabling fixed date in itin body
daniel-heppner-ibigroup Jun 20, 2024
53801e9
test(itin-body): fix test runner detection
daniel-heppner-ibigroup Jun 20, 2024
49489bd
re-add missing story
daniel-heppner-ibigroup Jun 28, 2024
aa67282
Merge branch 'master' into upgrade-storybook7
daniel-heppner-ibigroup Jun 28, 2024
e951978
pr feedback fixes
daniel-heppner-ibigroup Jul 5, 2024
2089e85
Merge branch 'master' into upgrade-storybook7
daniel-heppner-ibigroup Jul 19, 2024
b6143a3
update snapshots
daniel-heppner-ibigroup Jul 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ jobs:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Use Node.js 16.x
- name: Use Node.js 21.x
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 21.x
- name: Install npm packages using cache
uses: bahmutov/npm-install@v1
- name: Install Playwright
run: npx playwright install --with-deps
- name: Lint code
run: yarn lint:js
- name: Lint styles
Expand All @@ -19,10 +21,17 @@ jobs:
run: yarn check:i18n-en-fr
- name: Type check
run: yarn typescript
- name: Run tests
- name: Run unit tests
run: yarn unit
- name: Run a11y tests
run: yarn a11y-test
- name: Build Storybook
run: yarn build-storybook --quiet
- name: Serve Storybook and run test runner
# env:
# ONLY_RUN: SNAPSHOTS
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"npx http-server storybook-static --port 5555 --silent" \
"npx wait-on tcp:5555 && yarn test-storybook --ci"
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
47 changes: 31 additions & 16 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { dirname, join } from "path";
const path = require("path");

module.exports = {
addons: [
"@storybook/addon-a11y",
"@storybook/addon-actions",
"@storybook/addon-docs",
"@storybook/addon-essentials",
"@storybook/addon-knobs",
"@storybook/addon-links",
getAbsolutePath("@storybook/addon-a11y"),
getAbsolutePath("@storybook/addon-actions"),
getAbsolutePath("@storybook/addon-docs"),
getAbsolutePath("@storybook/addon-controls"),
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@storybook/addon-links"),
{
name: '@storybook/addon-storysource',
options: {
Expand All @@ -20,13 +21,16 @@ module.exports = {
}
}
},
"@storybook/addon-viewport",
"storybook-react-intl"
getAbsolutePath("@storybook/addon-viewport"),
"@danielhep/storybook-react-intl"
],

stories: [
"../packages/**/*.story.mdx",
"../packages/**/*.story.@(js|jsx|ts|tsx)"
],
staticDirs: ['../public'],

webpackFinal: async (config, { configType }) => {
// This method is for altering Storybook's webpack configuration.
// Add support for importing image files
Expand All @@ -42,7 +46,7 @@ module.exports = {
// Add support for importing YAML files.
config.module.rules.push({
test: /\.(yml|yaml)$/,
loader: ["json-loader", "yaml-loader"]
loader: "yaml-loader"
});

config.module.rules.push({
Expand All @@ -53,17 +57,28 @@ module.exports = {

config.module.rules.push({
test: /uFuzzy/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', { targets: 'defaults' }]
]
}
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', { targets: 'defaults' }]
]
}
})

// Return the altered config
return config;
},

framework: {
name: getAbsolutePath("@storybook/react-webpack5"),
options: {}
},

docs: {
autodocs: true
}
}

function getAbsolutePath(value) {
return dirname(require.resolve(join(value, "package.json")));
}
4 changes: 3 additions & 1 deletion .storybook/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ addons.setConfig({
// nested hierarchies.
// See https://storybook.js.org/docs/react/writing-stories/naming-components-and-hierarchy#roots
showRoots: false
}
},
showPanel: true,
panelPosition: "bottom",
})
72 changes: 0 additions & 72 deletions .storybook/preview.js

This file was deleted.

45 changes: 45 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { setupWorker } from "msw/browser";

import locationFieldHandlers from "../packages/location-field/src/mocks/handlers";
import itineraryBodyHandlers from "../packages/itinerary-body/src/__mocks__/handlers";
import geocoderHandlers from "../packages/geocoder/src/test-fixtures/handlers";
import tileLayerHandlers from '../packages/otp2-tile-overlay/src/mocks/handlers'
import baseMapHandlers from '../packages/base-map/src/mocks/handlers';
import parameters from './previewParameters'

import { reactIntl } from './react-intl.ts';
import { Preview } from "@storybook/react";
import { mockDateDecorator } from "storybook-mock-date-decorator";

// Only install worker when running in browser
if (typeof global.process === "undefined") {
const worker = setupWorker(
...locationFieldHandlers,
...itineraryBodyHandlers,
...geocoderHandlers,
...tileLayerHandlers,
...baseMapHandlers
);
worker.start({ onUnhandledRequest: "bypass" });
}

export { parameters }
daniel-heppner-ibigroup marked this conversation as resolved.
Show resolved Hide resolved

const preview: Preview = {
decorators: [mockDateDecorator],
globals: {
locale: reactIntl.defaultLocale,
locales: {
"en-US": { title: "English (US)" },
fr: { title: "Français" },
es: { title: "Español" },
vi: { title: "Tiếng Việt" },
ko: { title: "한국어" },
zh: { title: "中文" },
unknown: { title: "Unsupported locale" }
}
},
parameters
}

export default preview
40 changes: 40 additions & 0 deletions .storybook/previewParameters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { reactIntl } from './react-intl.ts';

const parameters = {
a11y: {
config: {
rules: [
{
// moved to technical backlog
id: "aria-required-parent",
reviewOnFail: true,
},
{
// Appears to be a story bug
id: "duplicate-id",
reviewOnFail: true
},
{
// Appears to be a story bug
id: "duplicate-id-aria",
reviewOnFail: true
},
{
// Not really applicable to stories and causes problems with the WithMap decorator
id: "landmark-unique",
enabled: false
}
],
},
},
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
reactIntl
};

export default parameters;
64 changes: 0 additions & 64 deletions .storybook/react-intl.js

This file was deleted.

Loading
Loading