Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
724a846
PoC: Storybook a11y testing in CI
smith Apr 8, 2025
c28be56
don't change this one
smith Apr 8, 2025
b9f020b
idk
smith Apr 8, 2025
fb72f54
add skip tags to test-runner config and stories
MiriamAparicio Apr 25, 2025
e5fba40
disable test failures for a11y checks
MiriamAparicio Apr 28, 2025
12f70d4
wip
MiriamAparicio Apr 30, 2025
ef22f58
disable failing a11y tests
MiriamAparicio May 5, 2025
04ccb68
fix conflict
MiriamAparicio May 5, 2025
2dead19
add pipeline to run storybook test in CI
MiriamAparicio May 8, 2025
d9adc39
bootstrapping on the script
MiriamAparicio May 8, 2025
86075b8
Merge remote-tracking branch 'upstream/main' into nls/sb-a11y
MiriamAparicio May 8, 2025
407a24f
fix package.json
MiriamAparicio May 8, 2025
45eb361
Merge remote-tracking branch 'upstream/main' into nls/sb-a11y
MiriamAparicio May 8, 2025
ff5528c
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine May 8, 2025
fabb8f7
[CI] Auto-commit changed files from 'node scripts/styled_components_m…
kibanamachine May 8, 2025
e9f6645
add storybook test_runner.ts to tsconfig.json
MiriamAparicio May 8, 2025
9a826f2
fix merrge conflicts
MiriamAparicio May 20, 2025
028bcf9
fix merrge conflicts
MiriamAparicio May 20, 2025
82b9271
test to see storybook test fail in CI first checks
MiriamAparicio May 20, 2025
7afd4fd
test to see storybook test fail in CI first checks, second attempt
MiriamAparicio May 20, 2025
4868e89
fix conflicts yarn.lock
MiriamAparicio May 21, 2025
e8cf499
fix conflicts yarn.lock
MiriamAparicio May 21, 2025
de9b8cf
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine May 21, 2025
de8d929
[CI] Auto-commit changed files from 'ts-node .buildkite/pipeline-reso…
kibanamachine May 21, 2025
8938eec
Merge remote-tracking branch 'upstream/main' into nls/sb-a11y
Ikuni17 May 21, 2025
1565c40
move storybook tests
Ikuni17 May 21, 2025
579802b
add alias, port and modify url
MiriamAparicio May 22, 2025
1d52186
remove flag --port
MiriamAparicio May 22, 2025
5152bd6
increase wait time for storybook to run before running tests
MiriamAparicio May 26, 2025
4ba96f3
fix yarn.lock conflicts
MiriamAparicio May 26, 2025
a8f9305
try different approach to wait for storybook to be ready
MiriamAparicio May 26, 2025
c1a14fe
Merge remote-tracking branch 'upstream/main' into nls/sb-a11y
MiriamAparicio May 26, 2025
f3fbed4
change port to 9001
MiriamAparicio May 28, 2025
4820b44
changes in storybook_test.sh
MiriamAparicio May 28, 2025
3c6311e
[CI] Auto-commit changed files from 'ts-node .buildkite/pipeline-reso…
kibanamachine May 28, 2025
da79e80
Merge branch 'main' into nls/sb-a11y
smith Jun 2, 2025
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
5 changes: 5 additions & 0 deletions .buildkite/pipelines/pull_request/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ steps:
- exit_status: '-1'
limit: 3

- command: .buildkite/scripts/steps/storybooks/storybook_tests.sh
label: 'Run Storybook Tests'
env:
STORYBOOK_URL: 'http://127.0.0.1:9001'

- wait

- command: .buildkite/scripts/steps/ci_stats_ready.sh
Expand Down
6 changes: 6 additions & 0 deletions .buildkite/pipelines/pull_request/storybooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ steps:
preemptible: true
key: storybooks
timeout_in_minutes: 80

# - command: ".buildkite/scripts/steps/storybooks/storybook_tests.sh"
# label: "Run Storybook Tests"
# soft_fail: true
# env:
# STORYBOOK_URL: 'http://localhost:9001'
17 changes: 17 additions & 0 deletions .buildkite/scripts/steps/storybooks/storybook_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euo pipefail

.buildkite/scripts/bootstrap.sh

echo "Starting Storybook server..."
yarn storybook apm &
STORYBOOK_PID=$!

echo "Waiting for Storybook to be ready..."
sleep 60
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we're going to be waiting for a server to be available we should do it by polling the server until it's ready, rather than waiting 60s no matter what. Probably just by putting curl with a HEAD request in a while loop.


echo "Running Storybook tests..."
yarn test:storybook --url "$STORYBOOK_URL"

kill $STORYBOOK_PID
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"test:ftr:server": "node scripts/functional_tests_server",
"test:jest": "node scripts/jest",
"test:jest_integration": "node scripts/jest_integration",
"test:storybook": "npx test-storybook",
"test:type_check": "node scripts/type_check"
},
"repository": {
Expand Down Expand Up @@ -1140,6 +1141,7 @@
"archiver": "^7.0.1",
"async": "^3.2.6",
"aws4": "^1.13.2",
"axe-playwright": "^2.1.0",
"axios": "^1.8.3",
"base64-js": "^1.3.1",
"bitmap-sdf": "^1.0.3",
Expand Down Expand Up @@ -1620,6 +1622,7 @@
"@storybook/react": "^8.6.3",
"@storybook/react-webpack5": "^8.6.3",
"@storybook/test": "^8.6.3",
"@storybook/test-runner": "^0.22.0",
"@storybook/theming": "^8.6.3",
"@storybook/types": "^8.6.3",
"@testing-library/dom": "^10.4.0",
Expand Down Expand Up @@ -1879,7 +1882,7 @@
"pirates": "^4.0.1",
"piscina": "^3.2.0",
"pixelmatch": "^5.3.0",
"playwright": "1.49.0",
"playwright": "1.51.1",
"playwright-chromium": "1.49.0",
"pngjs": "^7.0.0",
"postcss": "^8.4.31",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const preview: Preview = {
},
},
},
parameters: {
a11y: { test: 'error' },
},
};

// eslint-disable-next-line import/no-default-export
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { getStoryContext, type TestRunnerConfig } from '@storybook/test-runner';
import { injectAxe, checkA11y } from 'axe-playwright';

/*
* See https://storybook.js.org/docs/writing-tests/test-runner#test-hook-api
* to learn more about the test-runner hooks API.
*/
const config: TestRunnerConfig = {
tags: {
skip: ['skip-test'],
},
async preVisit(page) {
await injectAxe(page);
},
async postVisit(page, context) {
const storyContext = await getStoryContext(page, context);
// // Do not run a11y tests on disabled stories.
if (storyContext.parameters?.a11y?.disable) {
return;
}
await checkA11y(page, 'body', {
detailedReport: true,
detailedReportOptions: {
html: true,
},
});
},
};
// eslint-disable-next-line import/no-default-export
export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export const CreatingInApmFromService: StoryObj<Args> = {
render: ({ ruleParams, metadata }) => (
<CreatingInApmFromServiceComponent ruleParams={ruleParams} metadata={metadata} />
),
// TODO: fix a11y errors
parameters: {
a11y: { disable: true },
},

args: {
ruleParams: {},
Expand Down Expand Up @@ -143,7 +147,10 @@ export const EditingInStackManagement: StoryObj<Args> = {
render: ({ ruleParams, metadata }) => (
<EditingInStackManagementComponent ruleParams={ruleParams} metadata={metadata} />
),

// TODO: fix a11y errors
parameters: {
a11y: { disable: true },
},
args: {
ruleParams: {
environment: 'testEnvironment',
Expand Down Expand Up @@ -177,6 +184,10 @@ export const CreatingInStackManagement: StoryObj<Args> = {
render: ({ ruleParams, metadata }) => (
<CreatingInStackManagementComponent ruleParams={ruleParams} metadata={metadata} />
),
// TODO: fix a11y errors
parameters: {
a11y: { disable: true },
},

args: {
ruleParams: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ interface Args {
export default {
title: 'alerting/TransactionDurationRuleType',
component: TransactionDurationRuleType,
// TODO: fix a11y errors
parameters: {
a11y: { disable: true },
},
decorators: [
(StoryComponent: ComponentType) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ export const CreatingInStackManagement: StoryObj<Args> = {
render: ({ ruleParams, metadata }) => (
<CreatingInStackManagementComponent ruleParams={ruleParams} metadata={metadata} />
),

// TODO: fix a11y errors
parameters: {
a11y: { disable: true },
},
args: {
ruleParams: {
environment: 'testEnvironment',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,86 +5,94 @@
* 2.0.
*/

import type { ComponentType } from 'react';
import type { ComponentProps } from 'react';
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { ErrorDistribution } from '.';
import { MockApmPluginStorybook } from '../../../../context/apm_plugin/mock_apm_plugin_storybook';
import { FETCH_STATUS } from '../../../../hooks/use_fetcher';

export default {
type Args = ComponentProps<typeof ErrorDistribution>;

const stories: Meta<Args> = {
title: 'app/ErrorGroupDetails/distribution',
component: ErrorDistribution,
tags: ['skip-test'],
decorators: [
(Story: ComponentType) => {
(StoryComponent) => {
return (
<MockApmPluginStorybook routePath="/services/{serviceName}/errors/{groupId}?kuery=&rangeFrom=now-15m&rangeTo=now&environment=ENVIRONMENT_ALL&serviceGroup=&comparisonEnabled=true&transactionType=request&offset=1d">
<Story />
<StoryComponent />
</MockApmPluginStorybook>
);
},
],
};

export function Example() {
const distribution = {
bucketSize: 62350,
currentPeriod: [
{ x: 1624279912350, y: 6 },
{ x: 1624279974700, y: 1 },
{ x: 1624280037050, y: 2 },
{ x: 1624280099400, y: 3 },
{ x: 1624280161750, y: 13 },
{ x: 1624280224100, y: 1 },
{ x: 1624280286450, y: 2 },
{ x: 1624280348800, y: 0 },
{ x: 1624280411150, y: 4 },
{ x: 1624280473500, y: 4 },
{ x: 1624280535850, y: 1 },
{ x: 1624280598200, y: 4 },
{ x: 1624280660550, y: 0 },
{ x: 1624280722900, y: 2 },
{ x: 1624280785250, y: 3 },
{ x: 1624280847600, y: 0 },
],
previousPeriod: [
{ x: 1624279912350, y: 6 },
{ x: 1624279974700, y: 1 },
{ x: 1624280037050, y: 2 },
{ x: 1624280099400, y: 3 },
{ x: 1624280161750, y: 13 },
{ x: 1624280224100, y: 1 },
{ x: 1624280286450, y: 2 },
{ x: 1624280348800, y: 0 },
{ x: 1624280411150, y: 4 },
{ x: 1624280473500, y: 4 },
{ x: 1624280535850, y: 1 },
{ x: 1624280598200, y: 4 },
{ x: 1624280660550, y: 0 },
{ x: 1624280722900, y: 2 },
{ x: 1624280785250, y: 3 },
{ x: 1624280847600, y: 0 },
],
};
export default stories;

return (
<ErrorDistribution
fetchStatus={FETCH_STATUS.SUCCESS}
distribution={distribution}
title="Foo title"
/>
);
}
export const Example: StoryObj<Args> = {
render: (args) => {
return <ErrorDistribution {...args} />;
},
args: {
distribution: {
bucketSize: 62350,
currentPeriod: [
{ x: 1624279912350, y: 6 },
{ x: 1624279974700, y: 1 },
{ x: 1624280037050, y: 2 },
{ x: 1624280099400, y: 3 },
{ x: 1624280161750, y: 13 },
{ x: 1624280224100, y: 1 },
{ x: 1624280286450, y: 2 },
{ x: 1624280348800, y: 0 },
{ x: 1624280411150, y: 4 },
{ x: 1624280473500, y: 4 },
{ x: 1624280535850, y: 1 },
{ x: 1624280598200, y: 4 },
{ x: 1624280660550, y: 0 },
{ x: 1624280722900, y: 2 },
{ x: 1624280785250, y: 3 },
{ x: 1624280847600, y: 0 },
],
previousPeriod: [
{ x: 1624279912350, y: 6 },
{ x: 1624279974700, y: 1 },
{ x: 1624280037050, y: 2 },
{ x: 1624280099400, y: 3 },
{ x: 1624280161750, y: 13 },
{ x: 1624280224100, y: 1 },
{ x: 1624280286450, y: 2 },
{ x: 1624280348800, y: 0 },
{ x: 1624280411150, y: 4 },
{ x: 1624280473500, y: 4 },
{ x: 1624280535850, y: 1 },
{ x: 1624280598200, y: 4 },
{ x: 1624280660550, y: 0 },
{ x: 1624280722900, y: 2 },
{ x: 1624280785250, y: 3 },
{ x: 1624280847600, y: 0 },
],
},
fetchStatus: FETCH_STATUS.SUCCESS,
title: 'Foo title',
},
tags: ['skip-test'],
};

export function EmptyState() {
return (
<ErrorDistribution
fetchStatus={FETCH_STATUS.SUCCESS}
distribution={{
bucketSize: 10,
currentPeriod: [],
previousPeriod: [],
}}
title="Foo title"
/>
);
}
export const EmptyState: StoryObj<Args> = {
render: (args) => {
return <ErrorDistribution {...args} />;
},
args: {
fetchStatus: FETCH_STATUS.SUCCESS,
distribution: {
bucketSize: 10,
currentPeriod: [],
previousPeriod: [],
},
title: 'Foo title',
},
tags: ['skip-test'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Args = ComponentProps<typeof ErrorGroupList>;
const stories: Meta<Args> = {
title: 'app/ErrorGroupOverview/ErrorGroupList',
component: ErrorGroupList,
tags: ['skip-test'],
decorators: [
(StoryComponent, { args }) => {
const coreMock = {
Expand Down Expand Up @@ -110,7 +111,7 @@ export const Example: StoryObj<Args> = {
render: (args) => {
return <ErrorGroupList {...args} />;
},

tags: ['skip-test'],
args: {
serviceName: 'test service',
initialPageSize: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { FETCH_STATUS } from '../../../../../../hooks/use_fetcher';
export default {
title: 'app/ErrorsAndCrashGroupDetails/distribution',
component: ErrorDistribution,
tags: ['skip-test'],
decorators: [
(Story: ComponentType) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export const EmptyState: StoryObj<Args> = {
render: (args) => {
return <MobileCrashGroupList {...args} />;
},
// TODO: fix a11y errors
// parameters: {
// a11y: { disable: true },
// },

args: {
mainStatistics: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ type Args = ComponentProps<typeof MobileErrorGroupList>;
const stories: Meta<Args> = {
title: 'app/ErrorGroupOverview/MobileErrorGroupList',
component: MobileErrorGroupList,
// TODO: fix a11y errors
parameters: {
a11y: { disable: true },
},

decorators: [
(StoryComponent) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FETCH_STATUS } from '../../../hooks/use_fetcher';
const stories: Meta<{}> = {
title: 'app/ServiceInventory',
component: ServiceInventory,
tags: ['skip-test'],
decorators: [
(StoryComponent) => {
const coreMock = {
Expand Down
Loading
Loading