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

Build: Add addon a11y to sandbox tests #29764

Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { fn } from '@storybook/test';

import type axe from 'axe-core';

import { A11YPanel } from '../../src/components/A11YPanel';
import { A11yContext } from '../../src/components/A11yContext';
import type { A11yContextStore } from '../../src/components/A11yContext';
import { A11YPanel } from './A11YPanel';
import { A11yContext } from './A11yContext';
import type { A11yContextStore } from './A11yContext';

const managerContext: any = {
state: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ManagerContext } from 'storybook/internal/manager-api';
import type { Meta, StoryObj } from '@storybook/react';
import { fn } from '@storybook/test';

import { TestDiscrepancyMessage } from '../../src/components/TestDiscrepancyMessage';
import { TestDiscrepancyMessage } from './TestDiscrepancyMessage';

type Story = StoryObj<typeof TestDiscrepancyMessage>;

Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/angular/template/components/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.storybook-button--primary {
background-color: #1ea7fd;
background-color: #555ab9;
color: white;
}
.storybook-button--secondary {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.storybook-button--primary {
background-color: #1ea7fd;
background-color: #555ab9;
color: white;
}
.storybook-button--secondary {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.storybook-button--primary {
background-color: #1ea7fd;
background-color: #555ab9;
color: white;
}
.storybook-button--secondary {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/create-storybook/rendererAssets/common/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.storybook-button--primary {
background-color: #1ea7fd;
background-color: #555ab9;
color: white;
}
.storybook-button--secondary {
Expand Down
5 changes: 2 additions & 3 deletions code/lib/create-storybook/rendererAssets/common/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
}

.storybook-page a {
color: #1ea7fd;
text-decoration: none;
color: inherit;
}

.storybook-page ul {
Expand All @@ -42,7 +41,7 @@
border-radius: 1em;
background: #e7fdd8;
padding: 4px 12px;
color: #66bf3c;
color: #357a14;
font-weight: 700;
font-size: 11px;
line-height: 12px;
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/react/src/__test__/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.storybook-button--primary {
background-color: #1ea7fd;
background-color: #555ab9;
color: white;
}
.storybook-button--secondary {
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/svelte/template/components/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.storybook-button--primary {
background-color: #1ea7fd;
background-color: #555ab9;
color: white;
}
.storybook-button--secondary {
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/vue3/src/__tests__/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.storybook-button--primary {
background-color: #1ea7fd;
background-color: #555ab9;
color: white;
}
.storybook-button--secondary {
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/vue3/template/components/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.storybook-button--primary {
background-color: #1ea7fd;
background-color: #555ab9;
color: white;
}
.storybook-button--secondary {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.storybook-button--primary {
background-color: #1ea7fd;
background-color: #555ab9;
color: white;
}
.storybook-button--secondary {
Expand Down
11 changes: 9 additions & 2 deletions scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ export async function setupVitest(details: TemplateDetails, options: PassedOptio
dedent`import { beforeAll } from 'vitest'
import { setProjectAnnotations } from '${storybookPackage}'
import * as rendererDocsAnnotations from '${template.expected.renderer}/dist/entry-preview-docs.mjs'
import * as addonA11yAnnotations from '@storybook/addon-a11y/preview'
import * as addonActionsAnnotations from '@storybook/addon-actions/preview'
import * as addonTestAnnotations from '@storybook/experimental-addon-test/preview'
import '../src/stories/components'
Expand All @@ -448,13 +449,14 @@ export async function setupVitest(details: TemplateDetails, options: PassedOptio
${isVue ? 'import * as vueAnnotations from "../src/stories/renderers/vue3/preview.js"' : ''}

const annotations = setProjectAnnotations([
${isVue ? 'vueAnnotations,' : ''}
rendererDocsAnnotations,
projectAnnotations,
coreAnnotations,
toolbarAnnotations,
addonActionsAnnotations,
addonTestAnnotations,
${isVue ? 'vueAnnotations,' : ''}
addonA11yAnnotations,
projectAnnotations,
])
Comment on lines 451 to 460
Copy link
Contributor

Choose a reason for hiding this comment

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

style: ensure consistent order of annotations - framework specific (Vue) first, then core features, then addons, then project level


beforeAll(annotations.beforeAll)`
Expand Down Expand Up @@ -808,6 +810,11 @@ export const extendPreview: Task['run'] = async ({ template, sandboxDir }) => {

if (template.expected.builder.includes('vite')) {
previewConfig.setFieldValue(['tags'], ['vitest']);
// TODO: Remove this once the starter components + test stories have proper accessibility
previewConfig.setFieldValue(
['parameters', 'a11y', 'warnings'],
['minor', 'moderate', 'serious', 'critical']
);
}

await writeConfig(previewConfig);
Expand Down
6 changes: 5 additions & 1 deletion scripts/tasks/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ export const sandbox: Task = {
// extraDeps.push('@testing-library/angular', '@analogjs/vitest-angular');
// }

options.addon = [...options.addon, '@storybook/experimental-addon-test'];
options.addon = [
...options.addon,
'@storybook/experimental-addon-test',
'@storybook/addon-a11y',
];
}

let startTime = now();
Expand Down
Loading