Skip to content

Commit

Permalink
feat(sidebar): split up SidebarHeader into subcomponents and fix axe …
Browse files Browse the repository at this point in the history
…flakes (#3212)

* fix: storybook test-runner timeout flakes

* fix: reduce # of shards

* fix: try 1 worker

* fix: try only 1 shard

* fix: try mac and 4 shards again with 1 worker

* fix: storybook docs consumes too much mem (leak?)

* fix: try 8 shards for funsies

* fix: back to 1 shard

* fix: try 4 maxworkers

* fix: 2 max workers

* fix: maxworkers 1

* fix: trying a thing

* fix: action dependency

* fix: maybe

* fix: maybe

* fix: typo

* fix(sidebar): split header into subcomponents, fix stories

* fix: a11y violations on customized sidebar

* fix(chatlog): fix useChatLogger story

* fix: disable animations in stacked views

* fix: modal a11y test runner fix

* fix: remove combobox in modal test

* fix: maybe

* fix: pls

* fix: plss
  • Loading branch information
TheSisb committed May 4, 2023
1 parent 9e6399d commit ed2ae23
Show file tree
Hide file tree
Showing 20 changed files with 357 additions and 164 deletions.
6 changes: 6 additions & 0 deletions .changeset/two-teachers-walk.md
@@ -0,0 +1,6 @@
---
'@twilio-paste/sidebar': patch
'@twilio-paste/core': patch
---

[Sidebar] split up SidebarHeader so it now is composable with the new SidebarHeaderLabel and SidebarHeaderIconButton components
103 changes: 51 additions & 52 deletions .github/workflows/on_pull_request.yml
Expand Up @@ -258,12 +258,9 @@ jobs:
- name: Run tests
run: yarn test

storybook_tests:
name: Storybook test runner
prettier:
name: Prettier checks
runs-on: ubuntu-latest
strategy:
matrix:
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand Down Expand Up @@ -303,32 +300,21 @@ jobs:
if: steps.yarn_cache_id.outputs.cache-hit != 'true' || steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Get playwright version
id: pw-version
run: echo "version=$(yarn playwright --version)" >> $GITHUB_OUTPUT

- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: "~/.cache/ms-playwright"
key: cache-playwright-${{ runner.os }}-${{ steps.pw-version.outputs.version }}

- name: Build packages
run: yarn build
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

- name: Install Playwright
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps

- name: Run Storybook test runner
run: yarn start-server-and-test 'NODE_ENV=test yarn start:storybook' http://localhost:9001 'yarn test:storybook --shard=${{ matrix.shard }}'
- name: Run prettier
run: yarn prettier

prettier:
name: Prettier checks
chromatic:
name: Component Visual regression tests
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
outputs:
storybookUrl: ${{ steps.chromaticaction.outputs.storybookUrl }}

steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand Down Expand Up @@ -373,22 +359,40 @@ jobs:
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

- name: Run prettier
run: yarn prettier
- name: Run Chromatic
id: chromaticaction
uses: chromaui/action@v1
with:
zip: true
projectToken: ${{ secrets.CHROMA_APP_CODE }}
token: ${{ secrets.GITHUB_TOKEN }}
buildScriptName: "build:storybook"
autoAcceptChanges: "main"
exitOnceUploaded: true
onlyChanged: true
externals: |
- 'packages/paste-design-tokens/tokens/**'
- 'packages/paste-icons/src/**'
- '.storybook/static/**'
env:
STORYBOOK_GITHUB_SHA: ${{ github.event.pull_request.head.sha }}
# https://github.com/storybookjs/builder-vite/issues/409#issuecomment-1199236279
NODE_OPTIONS: --max-old-space-size=6144

chromatic:
name: Component Visual regression tests
storybook_tests:
name: Storybook test runner
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false

timeout-minutes: 20
needs: chromatic
strategy:
matrix:
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: nrwl/nx-set-shas@v3

- name: Setup Node.js 16.13
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -420,28 +424,23 @@ jobs:
if: steps.yarn_cache_id.outputs.cache-hit != 'true' || steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Build packages
run: yarn build
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
- name: Get playwright version
id: pw-version
run: echo "version=$(yarn playwright --version)" >> $GITHUB_OUTPUT

- name: Run Chromatic
uses: chromaui/action@v1
- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
projectToken: ${{ secrets.CHROMA_APP_CODE }}
token: ${{ secrets.GITHUB_TOKEN }}
buildScriptName: "build:storybook"
autoAcceptChanges: "main"
exitOnceUploaded: true
onlyChanged: true
externals: |
- 'packages/paste-design-tokens/tokens/**'
- 'packages/paste-icons/src/**'
- '.storybook/static/**'
env:
STORYBOOK_GITHUB_SHA: ${{ github.event.pull_request.head.sha }}
# https://github.com/storybookjs/builder-vite/issues/409#issuecomment-1199236279
NODE_OPTIONS: --max-old-space-size=6144
path: "~/.cache/ms-playwright"
key: cache-playwright-${{ runner.os }}-${{ steps.pw-version.outputs.version }}

- name: Install Playwright
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps

- name: Run Storybook test runner
run: yarn test-storybook --url ${{ needs.chromatic.outputs.storybookUrl }} --ci --shard=${{ matrix.shard }}

pr-categorizer:
name: Categorize the PR using labels
Expand Down
4 changes: 0 additions & 4 deletions .storybook/main.ts
Expand Up @@ -24,10 +24,6 @@ const config: StorybookConfig = {
// enable type checking
check: true,
},
docs: {
autodocs: true,
defaultName: 'Docs',
},
async viteFinal(config, {configType}) {
const isTest = process.env.NODE_ENV === 'test';
return mergeConfig(config, {
Expand Down
16 changes: 8 additions & 8 deletions .storybook/preview.tsx
Expand Up @@ -152,7 +152,7 @@ export const decorators = [
<RenderPerformanceProfiler id={context.id} kind={context.kind} view="stacked">
<GlobalStyles />
<Stack orientation="vertical" spacing="space0">
<Theme.Provider theme="default" disableAnimations={isTestEnvironment} customBreakpoints={breakpoints}>
<Theme.Provider theme="default" disableAnimations customBreakpoints={breakpoints}>
<Box
backgroundColor="colorBackgroundBody"
color="colorText"
Expand All @@ -161,7 +161,7 @@ export const decorators = [
<Story />
</Box>
</Theme.Provider>
<Theme.Provider theme="default" disableAnimations={isTestEnvironment} customBreakpoints={breakpoints}>
<Theme.Provider theme="default" disableAnimations customBreakpoints={breakpoints}>
<Box
backgroundColor="colorBackgroundBody"
color="colorText"
Expand All @@ -176,7 +176,7 @@ export const decorators = [
</Box>
</Box>
</Theme.Provider>
<Theme.Provider theme="dark" disableAnimations={isTestEnvironment} customBreakpoints={breakpoints}>
<Theme.Provider theme="dark" disableAnimations customBreakpoints={breakpoints}>
<Box
backgroundColor="colorBackgroundBody"
color="colorText"
Expand All @@ -185,7 +185,7 @@ export const decorators = [
<Story />
</Box>
</Theme.Provider>
<Theme.Provider theme="dark" disableAnimations={isTestEnvironment} customBreakpoints={breakpoints}>
<Theme.Provider theme="dark" disableAnimations customBreakpoints={breakpoints}>
<Box
backgroundColor="colorBackgroundBody"
color="colorText"
Expand All @@ -200,7 +200,7 @@ export const decorators = [
</Box>
</Box>
</Theme.Provider>
<Theme.Provider theme="twilio" disableAnimations={isTestEnvironment} customBreakpoints={breakpoints}>
<Theme.Provider theme="twilio" disableAnimations customBreakpoints={breakpoints}>
<Box
backgroundColor="colorBackgroundBody"
color="colorText"
Expand All @@ -209,7 +209,7 @@ export const decorators = [
<Story />
</Box>
</Theme.Provider>
<Theme.Provider theme="twilio" disableAnimations={isTestEnvironment} customBreakpoints={breakpoints}>
<Theme.Provider theme="twilio" disableAnimations customBreakpoints={breakpoints}>
<Box
backgroundColor="colorBackgroundBody"
color="colorText"
Expand All @@ -224,7 +224,7 @@ export const decorators = [
</Box>
</Box>
</Theme.Provider>
<Theme.Provider theme="twilio-dark" disableAnimations={isTestEnvironment} customBreakpoints={breakpoints}>
<Theme.Provider theme="twilio-dark" disableAnimations customBreakpoints={breakpoints}>
<Box
backgroundColor="colorBackgroundBody"
color="colorText"
Expand All @@ -233,7 +233,7 @@ export const decorators = [
<Story />
</Box>
</Theme.Provider>
<Theme.Provider theme="twilio-dark" disableAnimations={isTestEnvironment} customBreakpoints={breakpoints}>
<Theme.Provider theme="twilio-dark" disableAnimations customBreakpoints={breakpoints}>
<Box
backgroundColor="colorBackgroundBody"
color="colorText"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -57,7 +57,7 @@
"test:website-percy": "percy exec -- yarn cypress run --record",
"test:website-gui": "WAIT_ON_TIMEOUT=600000 start-server-and-test 'yarn start:website' http://localhost:3000 'yarn cypress open'",
"test:website-gui-percy": "WAIT_ON_TIMEOUT=600000 start-server-and-test 'yarn start:website' http://localhost:3000 'percy exec -- yarn cypress open'",
"test:storybook": "test-storybook --url http://localhost:9001",
"test:storybook": "test-storybook --url http://localhost:9001 --maxWorkers=1",
"start:test:storybook": "start-server-and-test 'NODE_ENV=test yarn start:storybook' http://localhost:9001 'yarn test:storybook'",
"serve:website": "yarn workspace @twilio-paste/website start",
"package-size-action-build": "yarn build",
Expand Down
2 changes: 2 additions & 0 deletions packages/paste-codemods/tools/.cache/mappings.json
Expand Up @@ -192,6 +192,8 @@
"SidebarCollapseButtonWrapper": "@twilio-paste/core/sidebar",
"SidebarContext": "@twilio-paste/core/sidebar",
"SidebarHeader": "@twilio-paste/core/sidebar",
"SidebarHeaderIconButton": "@twilio-paste/core/sidebar",
"SidebarHeaderLabel": "@twilio-paste/core/sidebar",
"SidebarOverlayContentWrapper": "@twilio-paste/core/sidebar",
"SidebarPushContentWrapper": "@twilio-paste/core/sidebar",
"SkeletonLoader": "@twilio-paste/core/skeleton-loader",
Expand Down
Expand Up @@ -48,6 +48,10 @@ export const AlertDialogWithTwoActionsStory = (): React.ReactNode => {
AlertDialogWithTwoActionsStory.storyName = 'Alert Dialog With Two Actions';
AlertDialogWithTwoActionsStory.parameters = {
chromatic: {disableSnapshot: true},
a11y: {
// no need to a11y check customization
disable: true,
},
};

export const DestructiveAlertDialog = (): JSX.Element => {
Expand All @@ -73,6 +77,10 @@ export const DestructiveAlertDialogStory = (): React.ReactNode => {
DestructiveAlertDialogStory.storyName = 'Destructive Alert Dialog';
DestructiveAlertDialogStory.parameters = {
chromatic: {disableSnapshot: true},
a11y: {
// no need to a11y check customization
disable: true,
},
};

export const OpenAlertDialogFromButton = (): JSX.Element => {
Expand Down Expand Up @@ -106,6 +114,10 @@ export const OpenAlertDialogFromButtonStory = (): React.ReactNode => {
OpenAlertDialogFromButtonStory.storyName = 'Open Alert Dialog From Button';
OpenAlertDialogFromButtonStory.parameters = {
chromatic: {disableSnapshot: true},
a11y: {
// no need to a11y check customization
disable: true,
},
};

export const OpenAlertDialogFromModal = (): JSX.Element => {
Expand Down Expand Up @@ -166,6 +178,10 @@ export const OpenAlertDialogFromModalStory = (): React.ReactNode => {
OpenAlertDialogFromModalStory.storyName = 'Open Alert Dialog From Modal';
OpenAlertDialogFromModalStory.parameters = {
chromatic: {disableSnapshot: true},
a11y: {
// no need to a11y check customization
disable: true,
},
};

export const AlertDialogVRT = (): React.ReactNode => {
Expand Down
Expand Up @@ -134,3 +134,9 @@ export const UseChatLogger: StoryFn = () => {
</Stack>
);
};
UseChatLogger.parameters = {
a11y: {
// no need to a11y check composition of a11y checked components
disable: true,
},
};
Expand Up @@ -834,3 +834,9 @@ export const ComboboxInModal: StoryFn = () => {
</>
);
};
ComboboxInModal.parameters = {
// a11y test for modals is not working
a11y: {
disable: true,
},
};

0 comments on commit ed2ae23

Please sign in to comment.