Skip to content

Commit

Permalink
Merge pull request #30257 from storybookjs/valentin/remove-a11y-test-…
Browse files Browse the repository at this point in the history
…tag-comment-in-preview

Addon A11y: Don't set a11y tag as comment in automigrations
  • Loading branch information
valentinpalkovic authored Jan 15, 2025
2 parents ccb214d + e82df08 commit 3f702aa
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 695 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';

import { formatFileContent } from '@storybook/core/common';

import { formatConfig, loadConfig } from '@storybook/core/csf-tools';

import { existsSync, readFileSync, writeFileSync } from 'fs';
import * as jscodeshift from 'jscodeshift';
import path from 'path';
Expand Down Expand Up @@ -157,12 +153,12 @@ describe('addonA11yAddonTest', () => {
previewFile: null,
transformedPreviewCode: null,
transformedSetupCode: expect.any(String),
skipPreviewTransformation: false,
skipPreviewTransformation: true,
skipVitestSetupTransformation: false,
});
});

it('should return previewFile and transformedPreviewCode if preview file exists', async () => {
it.skip('should return previewFile and transformedPreviewCode if preview file exists', async () => {
vi.mocked(getAddonNames).mockReturnValue([
'@storybook/addon-a11y',
'@storybook/experimental-addon-test',
Expand Down Expand Up @@ -229,7 +225,7 @@ describe('addonA11yAddonTest', () => {
previewFile: null,
transformedPreviewCode: null,
transformedSetupCode: null,
skipPreviewTransformation: false,
skipPreviewTransformation: true,
skipVitestSetupTransformation: false,
});
});
Expand Down Expand Up @@ -265,7 +261,7 @@ describe('addonA11yAddonTest', () => {
previewFile: path.join(configDir, 'preview.js'),
transformedPreviewCode: null,
transformedSetupCode: null,
skipPreviewTransformation: false,
skipPreviewTransformation: true,
skipVitestSetupTransformation: false,
});
});
Expand Down Expand Up @@ -345,14 +341,7 @@ describe('addonA11yAddonTest', () => {
},
configDir,
} as any);
expect(result).toEqual({
setupFile: path.join(configDir, 'vitest.setup.js'),
previewFile: path.join(configDir, 'preview.js'),
transformedPreviewCode: expect.any(String),
transformedSetupCode: null,
skipPreviewTransformation: false,
skipVitestSetupTransformation: true,
});
expect(result).toEqual(null);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ export const addonA11yAddonTest: Fix<AddonA11yAddonTestOptions> = {
.find((filePath) => existsSync(filePath)) ?? null;

let skipVitestSetupTransformation = false;
let skipPreviewTransformation = false;
// TODO: Set it to false after we have decided how to deal with a11y:test tag.
const skipPreviewTransformation = true;

if (vitestSetupFile && previewFile) {
const vitestSetupSource = readFileSync(vitestSetupFile, 'utf8');
const previewSetupSource = readFileSync(previewFile, 'utf8');
// const previewSetupSource = readFileSync(previewFile, 'utf8');

skipVitestSetupTransformation = vitestSetupSource.includes('@storybook/addon-a11y');
skipPreviewTransformation = previewSetupSource.includes('a11y-test');
// skipPreviewTransformation = previewSetupSource.includes('a11y-test');

if (skipVitestSetupTransformation && skipPreviewTransformation) {
return null;
Expand Down
236 changes: 0 additions & 236 deletions docs/_snippets/addon-a11y-meta-tag-exclude.md

This file was deleted.

Loading

0 comments on commit 3f702aa

Please sign in to comment.