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 1 commit
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
45 changes: 29 additions & 16 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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-essentials"),
getAbsolutePath("@storybook/addon-links"),
{
name: '@storybook/addon-storysource',
options: {
Expand All @@ -20,20 +20,22 @@ module.exports = {
}
}
},
"@storybook/addon-viewport",
"storybook-react-intl"
getAbsolutePath("@storybook/addon-viewport"),
getAbsolutePath("storybook-react-intl")
],

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

webpackFinal: async (config, { configType }) => {
// This method is for altering Storybook's webpack configuration.

// 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 @@ -44,17 +46,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")));
}
22 changes: 20 additions & 2 deletions .storybook/preview.js → .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { setupWorker } from "msw";
import { withReactIntl } from "storybook-react-intl/dist/cjs/withReactIntl";

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 { reactIntl } from './react-intl.js';
import { Preview } from "@storybook/react";

// Only install worker when running in browser
if (typeof global.process === "undefined") {
Expand Down Expand Up @@ -69,4 +69,22 @@ export const parameters = {
// Per https://www.npmjs.com/package/@storybook/addon-storyshots,
// explicitly export the storybook-react-intl decorator
// so it is included in jest snapshots.
export const decorators = [withReactIntl];
// export const decorators = [withReactIntl];

const preview: Preview = {
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
4 changes: 1 addition & 3 deletions .storybook/react-intl.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ const packages = [
"location-field",
"printable-itinerary",
"map-popup",
"stops-overlay",
"transit-vehicle-overlay",
"trip-details",
"trip-form",
"vehicle-rental-overlay"
"trip-form"
];

/** Messages for all packages AND locales above. */
Expand Down
32 changes: 18 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
"@formatjs/cli": "^4.2.32",
"@graphql-eslint/eslint-plugin": "^3.19.1",
"@semantic-release/git": "^9.0.0",
"@storybook/addon-a11y": "^6.4.19",
"@storybook/addon-actions": "^6.4.19",
"@storybook/addon-docs": "^6.4.19",
"@storybook/addon-essentials": "^6.4.19",
"@storybook/addon-knobs": "^6.3.0",
"@storybook/addon-links": "^6.4.19",
"@storybook/addon-storyshots": "^6.4.19",
"@storybook/addon-storyshots-puppeteer": "^6.4.19",
"@storybook/addon-storysource": "^6.4.19",
"@storybook/addon-viewport": "^6.4.19",
"@storybook/react": "^6.4.19",
"@storybook/addon-a11y": "7.6.17",
"@storybook/addon-actions": "7.6.17",
"@storybook/addon-docs": "7.6.17",
"@storybook/addon-essentials": "7.6.17",
"@storybook/addon-links": "7.6.17",
"@storybook/addon-storyshots": "7.6.17",
"@storybook/addon-storyshots-puppeteer": "7.6.17",
"@storybook/addon-storysource": "7.6.17",
"@storybook/addon-viewport": "7.6.17",
"@storybook/react": "7.6.17",
"@storybook/react-webpack5": "7.6.17",
"@storybook/storybook-deployer": "^2.8.10",
"@types/jest": "^26.0.23",
"@types/node": "^15.0.0",
Expand Down Expand Up @@ -81,7 +81,8 @@
"semantic-release": "^17.1.1",
"semantic-release-monorepo": "^7.0.2",
"semver": "^7.3.2",
"storybook-react-intl": "^1.0.5",
"storybook": "7.6.17",
"storybook-react-intl": "^2.0.10",
"styled-components": "^5.3.0",
"stylelint": "^10.1.0",
"stylelint-config-prettier": "^5.2.0",
Expand All @@ -92,7 +93,7 @@
"typescript": "^4.2.4",
"webpack": "^4.33.0",
"yaml-jest": "^1.2.0",
"yaml-loader": "^0.6.0",
"yaml-loader": "^0.8.1",
"yaml-sort": "^2.0.0"
},
"scripts": {
Expand All @@ -106,7 +107,7 @@
"check-eslint-config": "eslint --print-config jestconfig.js | eslint-config-prettier-check",
"coverage": "jest --coverage",
"deploy-storybook": "storybook-to-ghpages",
"dev": "start-storybook -s ./public -p 5555",
"dev": "storybook dev -s ./public -p 5555",
"predev": "yarn",
"lint:js": "eslint . --ext .js,.jsx,.ts,.tsx --ignore-pattern esm --ignore-pattern lib --ignore-pattern node_modules --ignore-pattern storybook-static --quiet",
"lint:graphql": "eslint . --ext .graphql --ignore-pattern esm --ignore-pattern lib --ignore-pattern node_modules --ignore-pattern storybook-static",
Expand Down Expand Up @@ -271,5 +272,8 @@
},
"msw": {
"workerDirectory": "public"
},
"dependencies": {
"@storybook/icons": "^1.2.9"
}
}
2 changes: 1 addition & 1 deletion packages/building-blocks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import blue from "./colors/blue";
import red from "./colors/red";
import grey from "./colors/grey";

export { blue, red, grey };
export default { blue, red, grey };
8 changes: 6 additions & 2 deletions packages/building-blocks/src/stories/index.story.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import React, { ReactElement } from "react";
import { Meta } from "@storybook/react";
import ColorPalette from "./ColorPalette";

import grey from "../colors/grey";
import blue from "../colors/blue";
import red from "../colors/red";

export default {
title: "Building-Blocks/Colors"
const meta: Meta<typeof ColorPalette> = {
title: "Building-Blocks/Colors",
component: ColorPalette
};

export default meta;

export const Grey = (): ReactElement => {
return <ColorPalette color={grey} />;
};
Expand Down
3 changes: 1 addition & 2 deletions packages/building-blocks/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
"lib": ["es2019", "dom"],
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["src/__tests__/**/*"]
"include": ["src/**/*"]
}
3 changes: 1 addition & 2 deletions packages/core-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
"lib": ["es2019", "dom"],
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["src/__tests__/**/*"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exclude was overriding the exclude from the extended config at the root level

"include": ["src/**/*"]
}
9 changes: 6 additions & 3 deletions packages/otp2-tile-overlay/src/mocks/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { rest } from "msw";

import tilejson from "./tilejson.json";

import seventy from "!url-loader!./4770-6206.pbf";
import seventyOne from "!url-loader!./4771-6206.pbf";
import seventyTwo from "!url-loader!./4772-6206.pbf";
// import seventy from "./4770-6206.pbf";
// import seventyOne from "./4771-6206.pbf";
// import seventyTwo from "./4772-6206.pbf";
const seventy = new URL("./4770-6206.pbf", import.meta.url);
const seventyOne = new URL("./4771-6206.pbf", import.meta.url);
const seventyTwo = new URL("./4772-6206.pbf", import.meta.url);
daniel-heppner-ibigroup marked this conversation as resolved.
Show resolved Hide resolved

export default [
rest.get(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { action } from "@storybook/addon-actions";
import { boolean } from "@storybook/addon-knobs";
// import { boolean } from "@storybook/addon-knobs";
daniel-heppner-ibigroup marked this conversation as resolved.
Show resolved Hide resolved

import { Company, Station } from "@opentripplanner/types";
import bikeRentalStations from "../__mocks__/bike-rental-stations.json";
Expand Down Expand Up @@ -41,7 +41,7 @@ type StoryProps = {
getStationName?: (configCompanies: Company[], station: Station) => string;
refreshVehicles: () => void;
stations: Station[];
visible?: boolean;
// visible?: boolean;
};

const ZoomControlledMapWithVehicleRentalOverlay = ({
Expand Down Expand Up @@ -82,16 +82,16 @@ export const RentalBicycles = () => (
);

export const RentalBicyclesVisibilityControlledByKnob = () => {
const isOverlayVisible = boolean(
"Toggle visibility of vehicle rental overlay",
false
);
// const isOverlayVisible = boolean(
// "Toggle visibility of vehicle rental overlay",
// false
// );
return (
<ZoomControlledMapWithVehicleRentalOverlay
companies={["BIKETOWN"]}
refreshVehicles={action("refresh bicycles")}
stations={bikeRentalStations}
visible={isOverlayVisible}
// visible={isOverlayVisible}
/>
);
};
Expand Down
9 changes: 8 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@
"jsx": "react",
"noEmit": false
},
"exclude": ["**/*.test.ts", "**/*.story.tsx", "node_modules", "lib", "esm"]
"exclude": [
"**/*.test.ts",
"**/*.story.tsx",
"node_modules",
"lib",
"esm",
"**/__tests__/**/*"
]
}
Loading
Loading