Skip to content

Commit 31f0425

Browse files
Merge branch 'master' into alpha
# Conflicts: # .github/workflows/node-ci.yml # __snapshots__/storybook.test.ts.snap # packages/base-map/package.json # packages/core-utils/package.json # packages/core-utils/src/itinerary.ts # packages/endpoints-overlay/i18n/ko.yml # packages/endpoints-overlay/i18n/ru.yml # packages/endpoints-overlay/i18n/tl.yml # packages/endpoints-overlay/i18n/zh_Hans.yml # packages/geocoder/package.json # packages/icons/package.json # packages/itinerary-body/i18n/es.yml # packages/itinerary-body/package.json # packages/location-field/package.json # packages/map-popup/i18n/es.yml # packages/map-popup/package.json # packages/otp2-tile-overlay/package.json # packages/printable-itinerary/package.json # packages/route-viewer-overlay/package.json # packages/stops-overlay/package.json # packages/transitive-overlay/package.json # packages/trip-details/i18n/es.yml # packages/trip-details/package.json # packages/trip-form/i18n/en-US.yml # packages/trip-form/package.json # packages/types/package.json
2 parents dd92680 + 4b34b09 commit 31f0425

File tree

275 files changed

+112811
-5002
lines changed

Some content is hidden

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

275 files changed

+112811
-5002
lines changed

.github/workflows/node-ci.yml

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
11
jobs:
22
test-build-release:
3-
runs-on: ubuntu-latest
3+
runs-on: ubuntu-22.04
44
steps:
55
- uses: actions/checkout@v2
66
with:
77
persist-credentials: false
8-
- name: Use Node.js 16.x
8+
- name: Use Node.js 21.x
99
uses: actions/setup-node@v1
1010
with:
11-
node-version: 16.x
11+
node-version: 21.x
1212
- name: Install npm packages using cache
1313
uses: bahmutov/npm-install@v1
14+
- name: Install Playwright
15+
run: npx playwright install --with-deps
16+
- name: Lint code
17+
run: yarn lint:js
18+
- name: Lint styles
19+
run: yarn lint:styles
20+
- name: i18n check (en-US, fr only)
21+
run: yarn check:i18n-en-fr
22+
- name: Type check
23+
run: yarn typescript
24+
- name: Run unit tests
25+
run: yarn unit
26+
- name: Build Storybook
27+
run: yarn build-storybook --quiet
28+
- name: Serve Storybook and run test runner
29+
# env:
30+
# ONLY_RUN: SNAPSHOTS
31+
run: |
32+
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
33+
"npx http-server storybook-static --port 5555 --silent" \
34+
"npx wait-on tcp:5555 && yarn test-storybook --ci"
1435
- env:
1536
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1637
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.storybook/main.js

+42-18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
import { dirname, join } from "path";
12
const path = require("path");
23

34
module.exports = {
45
addons: [
5-
"@storybook/addon-a11y",
6-
"@storybook/addon-actions",
7-
"@storybook/addon-docs",
8-
"@storybook/addon-essentials",
9-
"@storybook/addon-knobs",
10-
"@storybook/addon-links",
6+
getAbsolutePath("@storybook/addon-a11y"),
7+
getAbsolutePath("@storybook/addon-actions"),
8+
getAbsolutePath("@storybook/addon-docs"),
9+
getAbsolutePath("@storybook/addon-controls"),
10+
getAbsolutePath("@storybook/addon-essentials"),
11+
getAbsolutePath("@storybook/addon-links"),
1112
{
1213
name: '@storybook/addon-storysource',
1314
options: {
@@ -20,20 +21,32 @@ module.exports = {
2021
}
2122
}
2223
},
23-
"@storybook/addon-viewport",
24-
"storybook-react-intl"
24+
getAbsolutePath("@storybook/addon-viewport"),
25+
"@danielhep/storybook-react-intl"
2526
],
27+
2628
stories: [
2729
"../packages/**/*.story.mdx",
28-
"../packages/**/*.story.@(js|jsx|ts|tsx)"
30+
"../packages/*/src/**/*.story.@(js|jsx|ts|tsx)"
2931
],
32+
staticDirs: ['../public'],
33+
3034
webpackFinal: async (config, { configType }) => {
3135
// This method is for altering Storybook's webpack configuration.
32-
36+
// Add support for importing image files
37+
config.module.rules.push({
38+
test: /\.(png|jpg|gif|svg)$/,
39+
use: [
40+
{
41+
loader: 'file-loader',
42+
},
43+
],
44+
include: path.resolve(__dirname, './packages/transitive-overlay/src/images'),
45+
});
3346
// Add support for importing YAML files.
3447
config.module.rules.push({
3548
test: /\.(yml|yaml)$/,
36-
loader: ["json-loader", "yaml-loader"]
49+
loader: "yaml-loader"
3750
});
3851

3952
config.module.rules.push({
@@ -44,17 +57,28 @@ module.exports = {
4457

4558
config.module.rules.push({
4659
test: /uFuzzy/,
47-
use: {
48-
loader: 'babel-loader',
49-
options: {
50-
presets: [
51-
['@babel/preset-env', { targets: 'defaults' }]
52-
]
53-
}
60+
loader: 'babel-loader',
61+
options: {
62+
presets: [
63+
['@babel/preset-env', { targets: 'defaults' }]
64+
]
5465
}
5566
})
5667

5768
// Return the altered config
5869
return config;
70+
},
71+
72+
framework: {
73+
name: getAbsolutePath("@storybook/react-webpack5"),
74+
options: {}
75+
},
76+
77+
docs: {
78+
autodocs: true
5979
}
80+
}
81+
82+
function getAbsolutePath(value) {
83+
return dirname(require.resolve(join(value, "package.json")));
6084
}

.storybook/manager.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ addons.setConfig({
66
// nested hierarchies.
77
// See https://storybook.js.org/docs/react/writing-stories/naming-components-and-hierarchy#roots
88
showRoots: false
9-
}
9+
},
10+
showPanel: true,
11+
panelPosition: "bottom",
1012
})

.storybook/preview.js

-72
This file was deleted.

.storybook/preview.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { setupWorker } from "msw/browser";
2+
3+
import locationFieldHandlers from "../packages/location-field/src/mocks/handlers";
4+
import itineraryBodyHandlers from "../packages/itinerary-body/src/__mocks__/handlers";
5+
import geocoderHandlers from "../packages/geocoder/src/test-fixtures/handlers";
6+
import tileLayerHandlers from '../packages/otp2-tile-overlay/src/mocks/handlers'
7+
import baseMapHandlers from '../packages/base-map/src/mocks/handlers';
8+
import parameters from './previewParameters'
9+
10+
import { reactIntl } from './react-intl.ts';
11+
import { Preview } from "@storybook/react";
12+
import { mockDateDecorator } from "storybook-mock-date-decorator";
13+
14+
// Only install worker when running in browser
15+
if (typeof global.process === "undefined") {
16+
const worker = setupWorker(
17+
...locationFieldHandlers,
18+
...itineraryBodyHandlers,
19+
...geocoderHandlers,
20+
...tileLayerHandlers,
21+
...baseMapHandlers
22+
);
23+
worker.start({ onUnhandledRequest: "bypass" });
24+
}
25+
26+
const preview: Preview = {
27+
decorators: [mockDateDecorator],
28+
globals: {
29+
locale: reactIntl.defaultLocale,
30+
locales: {
31+
"en-US": { title: "English (US)" },
32+
fr: { title: "Français" },
33+
es: { title: "Español" },
34+
vi: { title: "Tiếng Việt" },
35+
ko: { title: "한국어" },
36+
zh: { title: "中文" },
37+
unknown: { title: "Unsupported locale" }
38+
}
39+
},
40+
parameters
41+
}
42+
43+
export default preview

.storybook/previewParameters.ts

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { reactIntl } from './react-intl.ts';
2+
3+
const parameters = {
4+
a11y: {
5+
config: {
6+
rules: [
7+
{
8+
// moved to technical backlog
9+
id: "aria-required-parent",
10+
reviewOnFail: true,
11+
},
12+
{
13+
// Appears to be a story bug
14+
id: "duplicate-id",
15+
reviewOnFail: true
16+
},
17+
{
18+
// Appears to be a story bug
19+
id: "duplicate-id-aria",
20+
reviewOnFail: true
21+
},
22+
{
23+
// Not really applicable to stories and causes problems with the WithMap decorator
24+
id: "landmark-unique",
25+
enabled: false
26+
}
27+
],
28+
},
29+
},
30+
actions: { argTypesRegex: "^on[A-Z].*" },
31+
controls: {
32+
matchers: {
33+
color: /(background|color)$/i,
34+
date: /Date$/,
35+
},
36+
},
37+
reactIntl
38+
};
39+
40+
export default parameters;

.storybook/react-intl.js .storybook/react-intl.ts

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import flatten from "flat";
22

3-
/**
4-
* Copied from https://stackoverflow.com/questions/50940640/how-to-determine-if-jest-is-running-the-code-or-not
5-
*/
6-
export function isRunningJest() {
7-
return process.env.JEST_WORKER_ID !== undefined;
8-
}
3+
export const isTestRunner = () => window.navigator.userAgent.match(/StorybookTestRunner/);
94

105
/** Locale supported in the storybook "Globe" dropdown menu. */
116
const locales = ["en-US", "fr", "es", "vi", "ko", "zh", "unknown"];
@@ -22,27 +17,26 @@ const packages = [
2217
"location-field",
2318
"printable-itinerary",
2419
"map-popup",
25-
"stops-overlay",
2620
"transit-vehicle-overlay",
2721
"trip-details",
28-
"trip-form",
29-
"vehicle-rental-overlay"
22+
"trip-form"
3023
];
3124

3225
/** Messages for all packages AND locales above. */
3326
const messages = {};
3427

35-
if (!isRunningJest()) {
36-
// Populate messages if not running snapshots.
37-
// (Message printouts would be unnecessary replicated in snapshots without that check.)
28+
// Populate messages if not running snapshots.
29+
// (Message printouts would be unnecessary replicated in snapshots without that check.)
30+
if (typeof window !== "undefined") {
31+
3832
packages.forEach((pkg) => {
3933
locales.forEach((locale) => {
4034
// Chinese-simplified is assigned a special file name by Weblate.
4135
const localeFile = locale === "zh" ? "zh_Hans" : locale;
4236
try {
4337
messages[locale] = {
4438
...messages[locale],
45-
...flatten(require(`../packages/${pkg}/i18n/${localeFile}.yml`))
39+
...flatten(require(`../packages/${pkg}/i18n/${localeFile}.yml`).default)
4640
};
4741
} catch (e) {
4842
// There is no yml files for the "unknown" locale,
@@ -60,5 +54,6 @@ export const reactIntl = {
6054
defaultLocale: "en-US",
6155
formats,
6256
locales,
63-
messages
57+
messages,
58+
timeZone: 'America/Los_Angeles'
6459
};

0 commit comments

Comments
 (0)