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

Version 1.4.0 #411

Merged
merged 9 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
combined_coverage:
uses: yext/slapshot-reusable-workflows/.github/workflows/coverage.yml@v1
with:
test_script: npm run test
test_script: npm run build:css && npm run test
secrets:
caller_github_token: ${{ secrets.GITHUB_TOKEN }}
MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }}
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/percy-snapshots.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
call_run_tests-react-17:
uses: yext/slapshot-reusable-workflows/.github/workflows/run_tests.yml@v1
with:
node_matrix: '["14.x", "16.x", "18.x"]'
node_matrix: '["16.x", "18.x"]'
secrets:
MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }}

Expand All @@ -19,6 +19,6 @@ jobs:
build_script: |
npm i -D react@16.14 react-dom@16.14
npm run build
node_matrix: '["14.x", "16.x", "18.x"]'
node_matrix: '["16.x", "18.x"]'
secrets:
MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }}
37 changes: 37 additions & 0 deletions .github/workflows/update_snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Update Snapshots

on: pull_request

jobs:
update_snapshots:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.BOT_REPO_SCOPED_TOKEN }}
- uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- run: ./tests/scripts/start-storybook.sh
env:
MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }}
- run: npm run update-snapshots
- name: Push changes
id: push-changes
uses: EndBug/add-and-commit@v9
with:
message: "Update snapshots"
add: ".storybook/snapshots/__snapshots__"
push: true
pull: --rebase --autostash
default_author: github_actions
- name: Fail job if push changes
if: steps.push-changes.outputs.pushed == 'true'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Snapshot updates were made. A new commit with new snapshots was pushed.')
2 changes: 1 addition & 1 deletion .github/workflows/wcag_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }}
with:
build_script: ./tests/scripts/start-storybook.sh
build_script: npm run build:css && ./tests/scripts/start-storybook.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules/

# production
lib/
dist/

# testing
/coverage
Expand Down
3 changes: 0 additions & 3 deletions .storybook/index.css

This file was deleted.

46 changes: 0 additions & 46 deletions .storybook/main.js

This file was deleted.

58 changes: 58 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type { StorybookConfig } from '@storybook/react-webpack5';

const config: StorybookConfig = {
stories: [
'../tests/**/*.stories.tsx'
],
features: {
storyStoreV7: false,
},
addons: [
'@etchteam/storybook-addon-status',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-a11y',
{
name: '@storybook/addon-coverage',
options: {
istanbul: {
include: ['src/components/**']
}
}
},
],

framework: {
name: '@storybook/react-webpack5',
options: {}
},

staticDirs: ['./public'],

webpackFinal: async (config) => ({
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve?.alias,
'./SearchCore': require.resolve('../tests/__fixtures__/core/SearchCore.ts'),
'../utils/location-operations': require.resolve('../tests/__fixtures__/utils/location-operations.ts')
},
}
}),

env: (config) => {
const mapboxApiKey = process.env.MAPBOX_API_KEY || process.env.REACT_APP_MAPBOX_API_KEY;
return {
...config,
...(mapboxApiKey && { REACT_APP_MAPBOX_API_KEY: mapboxApiKey })
};
},

docs: {
autodocs: true
}
};

export default config;
5 changes: 0 additions & 5 deletions .storybook/manager.cjs

This file was deleted.

5 changes: 5 additions & 0 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { addons } from '@storybook/addons';

addons.setConfig({
theme: require('./yextTheme.ts')
});
7 changes: 0 additions & 7 deletions .storybook/postcss.config.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .storybook/preview.js → .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './index.css';
import 'mapbox-gl/dist/mapbox-gl.css';
import { SearchCoreDecorator } from '../tests/__fixtures__/core/SearchCore';
import { runOnly } from './wcagConfig';
import '../lib/bundle.css';

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions .storybook/snapshots/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import baseConfig from '../main';
import type { StorybookConfig } from '@storybook/react-webpack5';

const config: StorybookConfig = {
...baseConfig,
stories: baseConfig.stories.map((glob) => `../${glob}`),
};

export default config;
37 changes: 37 additions & 0 deletions .storybook/snapshots/test-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Page } from 'playwright-core';
import { TestRunnerConfig, TestContext } from '@storybook/test-runner';
import { toMatchImageSnapshot } from 'jest-image-snapshot';

const customSnapshotsDir = `${process.cwd()}/.storybook/snapshots/__snapshots__`;

/**
* See https://storybook.js.org/docs/react/writing-tests/test-runner#test-hook-api-experimental
* to learn more about the test-runner hooks API.
*/
const renderFunctions: TestRunnerConfig = {
setup() {
expect.extend({ toMatchImageSnapshot });
},
async postVisit(page: Page, context: TestContext) {
if (context.id === 'locationbias--loading') {
return;
}

const isMapboxMapStory = context.id.startsWith('mapboxmap--');
if (isMapboxMapStory) {
await page.waitForTimeout(7500);
}

const image = await page.screenshot();
expect(image).toMatchImageSnapshot({
customSnapshotsDir,
customSnapshotIdentifier: context.id,
failureThreshold: context.id === 'geolocation--loading' || isMapboxMapStory
? 0.005
: 0,
failureThresholdType: 'percent'
});
},
};

export default renderFunctions;
17 changes: 0 additions & 17 deletions .storybook/tailwind.config.cjs

This file was deleted.

9 changes: 9 additions & 0 deletions .storybook/wcag/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import baseConfig from '../main';
import type { StorybookConfig } from '@storybook/react-webpack5';

const config: StorybookConfig = {
...baseConfig,
stories: baseConfig.stories.map((glob) => `../${glob}`),
};

export default config;
15 changes: 9 additions & 6 deletions .storybook/test-runner.ts → .storybook/wcag/test-runner.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import { injectAxe, checkA11y } from 'axe-playwright';
import { Page } from 'playwright-core';
import { runOnly } from './wcagConfig';
import { runOnly } from '../wcagConfig';
import { TestContext, TestRunnerConfig } from '@storybook/test-runner';

/**
* See https://storybook.js.org/docs/react/writing-tests/test-runner#test-hook-api-experimental
* to learn more about the test-runner hooks API.
*/
const renderFunctions: TestRunnerConfig = {
async preRender(page: Page) {
async preVisit(page: Page) {
await injectAxe(page);
},
async postRender(page: Page, context: TestContext) {
async postVisit(page: Page, context: TestContext) {
await checkA11y(
page,
{
include: ['#root'],
exclude: ['#root .mapboxgl-canvas-container'],
exclude: [
'#root .mapboxgl-canvas-container',
'.mapboxgl-marker',
'.mapboxgl-popup-close-button'
],
},
{
axeOptions: {
Expand All @@ -34,4 +37,4 @@ const renderFunctions: TestRunnerConfig = {
},
};

export default renderFunctions;
export default renderFunctions;
4 changes: 2 additions & 2 deletions .storybook/wcagConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { axeOptionsConfig } from 'axe-playwright';
import { RunOnly } from 'axe-core';

export const runOnly: axeOptionsConfig['axeOptions']['runOnly'] = {
export const runOnly: RunOnly = {
type: 'tag',
values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']
};
2 changes: 1 addition & 1 deletion .storybook/yextTheme.cjs → .storybook/yextTheme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { create } = require('@storybook/theming');
import { create } from '@storybook/theming';

module.exports = create({
base: 'light',
Expand Down
Loading
Loading