Skip to content

Commit 469f49c

Browse files
committed
final cleanup
1 parent f07f64e commit 469f49c

File tree

66 files changed

+556
-1596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+556
-1596
lines changed

code/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ module.exports = {
208208
},
209209
{
210210
files: ['**/*.ts', '!**/*.test.*', '!**/*.spec.*'],
211+
excludedFiles: ['**/*.test.*', '**/*.mockdata.*'],
211212
rules: {
212213
'local-rules/no-uncategorized-errors': 'warn',
213214
},

code/.yarnrc.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ compressionLevel: 0
22

33
enableGlobalCache: true
44

5+
logFilters:
6+
- code: YN0005
7+
level: discard
8+
- code: YN0076
9+
level: discard
10+
511
nodeLinker: node-modules
612

713
npmRegistryServer: 'https://registry.yarnpkg.com'

code/addons/a11y/src/components/A11YPanel.test.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ describe('A11YPanel', () => {
100100
expect(getByText(/Initializing/)).toBeTruthy();
101101
});
102102

103+
it('should set running status on event', async () => {
104+
const { getByText } = render(<ThemedA11YPanel />);
105+
const useChannelArgs = mockedApi.useChannel.mock.calls[0][0];
106+
act(() => useChannelArgs[EVENTS.RUNNING]());
107+
await waitFor(() => {
108+
expect(getByText(/Please wait while the accessibility scan is running/)).toBeTruthy();
109+
});
110+
});
111+
112+
// TODO: The tests below are skipped because of unknown issues with ThemeProvider
113+
// which cause errors like TypeError: Cannot read properties of undefined (reading 'defaultText')
103114
it.skip('should handle "manual" status', async () => {
104115
mockedApi.useParameter.mockReturnValue({ manual: true });
105116
const { getByText } = render(<ThemedA11YPanel />);
@@ -123,15 +134,6 @@ describe('A11YPanel', () => {
123134
});
124135
});
125136

126-
it('should set running status on event', async () => {
127-
const { getByText } = render(<ThemedA11YPanel />);
128-
const useChannelArgs = mockedApi.useChannel.mock.calls[0][0];
129-
act(() => useChannelArgs[EVENTS.RUNNING]());
130-
await waitFor(() => {
131-
expect(getByText(/Please wait while the accessibility scan is running/)).toBeTruthy();
132-
});
133-
});
134-
135137
it.skip('should handle "ran" status', async () => {
136138
const { getByText } = render(<ThemedA11YPanel />);
137139
const useChannelArgs = mockedApi.useChannel.mock.calls[0][0];

code/addons/a11y/src/components/VisionSimulator.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ function ThemedVisionSimulator() {
2525
}
2626

2727
describe('Vision Simulator', () => {
28+
// TODO: there are issues with the ThemeProvider from lib/theming for some reason
29+
// which are causing rendering issues in the component for all these tests
2830
it.skip('should render tool button', async () => {
2931
// when
3032
render(<ThemedVisionSimulator />);

code/addons/a11y/src/manager.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('A11yManager', () => {
3636
mockedApi.useAddonState.mockImplementation(() => [undefined]);
3737
registrationImpl(api as unknown as api.API);
3838
const title = mockedAddons.add.mock.calls.map(([_, def]) => def).find(isPanel)
39-
?.title as Function;
39+
?.title as () => void;
4040

4141
// when / then
4242
expect(title()).toMatchInlineSnapshot(`
@@ -70,7 +70,7 @@ describe('A11yManager', () => {
7070
]);
7171
registrationImpl(mockedApi);
7272
const title = mockedAddons.add.mock.calls.map(([_, def]) => def).find(isPanel)
73-
?.title as Function;
73+
?.title as () => void;
7474

7575
// when / then
7676
expect(title()).toMatchInlineSnapshot(`

code/addons/jest/src/shared.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
import { describe, expect, test } from 'vitest';
1+
import { describe, expect, it } from 'vitest';
22
import { defineJestParameter } from './shared';
33

44
describe('defineJestParameter', () => {
5-
test('infers from story file name if jest parameter is not provided', () => {
5+
it('infers from story file name if jest parameter is not provided', () => {
66
expect(defineJestParameter({ fileName: './stories/addon-jest.stories.js' })).toEqual([
77
'addon-jest',
88
]);
99
});
1010

11-
test('wraps string jest parameter with an array', () => {
11+
it('wraps string jest parameter with an array', () => {
1212
expect(defineJestParameter({ jest: 'addon-jest' })).toEqual(['addon-jest']);
1313
});
1414

15-
test('returns as is if jest parameter is an array', () => {
15+
it('returns as is if jest parameter is an array', () => {
1616
expect(defineJestParameter({ jest: ['addon-jest', 'something-else'] })).toEqual([
1717
'addon-jest',
1818
'something-else',
1919
]);
2020
});
2121

22-
test('returns null if disabled option is passed to jest parameter', () => {
22+
it('returns null if disabled option is passed to jest parameter', () => {
2323
expect(defineJestParameter({ jest: { disabled: true } })).toBeNull();
2424
});
2525

26-
test('returns null if no filename to infer from', () => {
26+
it('returns null if no filename to infer from', () => {
2727
expect(defineJestParameter({})).toBeNull();
2828
});
2929

30-
test('returns null if filename is a module ID that cannot be inferred from', () => {
30+
it('returns null if filename is a module ID that cannot be inferred from', () => {
3131
// @ts-expect-error Storybook's fileName type is string, but according to this test it could be number in case it is a module id.
3232
expect(defineJestParameter({ fileName: 1234 })).toBeNull();
3333
});

code/builders/builder-manager/src/utils/files.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { test, expect } from 'vitest';
1+
import { it, expect } from 'vitest';
22
import type { OutputFile } from 'esbuild';
33
import { platform } from 'os';
44
import { sanitizePath } from './files';
55

66
const os = platform();
77
const isWindows = os === 'win32';
88

9-
test('sanitizePath', () => {
9+
it('sanitizePath', () => {
1010
const addonsDir = isWindows
1111
? 'C:\\Users\\username\\Projects\\projectname\\storybook'
1212
: '/Users/username/Projects/projectname/storybook';

code/builders/builder-vite/src/plugins/external-globals-plugin.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from 'vitest';
1+
import { it, expect } from 'vitest';
22
import { rewriteImport } from './external-globals-plugin';
33

44
const packageName = '@storybook/package';
@@ -37,7 +37,7 @@ const cases = [
3737
},
3838
];
3939

40-
test('rewriteImport', () => {
40+
it('rewriteImport', () => {
4141
cases.forEach(({ input, output, globals: caseGlobals, packageName: casePackage }) => {
4242
expect(rewriteImport(input, caseGlobals, casePackage)).toStrictEqual(output);
4343
});

code/deprecated/channel-websocket/vitest.config.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

code/lib/channels/src/index.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,15 @@ describe('Channel', () => {
116116
});
117117

118118
it('should use setImmediate if async is true', () => {
119+
// @ts-expect-error no idea what's going on here!
120+
global.setImmediate = vi.fn(setImmediate);
121+
119122
channel = new Channel({ async: true, transport });
120123
channel.addListener('event1', vi.fn());
124+
125+
channel.emit('event1', 'test-data');
126+
127+
expect(setImmediate).toHaveBeenCalled();
121128
});
122129
});
123130

0 commit comments

Comments
 (0)