Skip to content

Commit 138cf5f

Browse files
committed
test(Toc): update snapshots
1 parent f1e11ad commit 138cf5f

16 files changed

+31
-16
lines changed

src/components/Toc/__tests__/Toc.visual.test.tsx

+30-13
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,46 @@
1-
import React from 'react';
2-
3-
import {test} from '~playwright/core';
1+
import {smokeTest, test} from '~playwright/core';
42

53
import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios';
64
import type {TocProps} from '../Toc';
75

86
import {TestToc} from './helpers';
97

108
test.describe('Toc', {tag: '@Toc'}, () => {
11-
createSmokeScenarios<Partial<TocProps>>({}, {}).forEach(([title, details, props]) => {
12-
test(title, details, async ({mount, expectScreenshot}) => {
13-
const root = await mount(<TestToc {...props} />);
9+
smokeTest('', async ({mount, expectScreenshot}) => {
10+
const smokeScenarios = createSmokeScenarios<Partial<TocProps>>(
11+
{
12+
value: 'control',
13+
},
14+
{},
15+
);
16+
17+
await mount(
18+
<div>
19+
{smokeScenarios.map(([title, props]) => (
20+
<div key={title}>
21+
<h4>{title}</h4>
22+
<div>
23+
<TestToc {...props} />
24+
</div>
25+
</div>
26+
))}
27+
</div>,
28+
);
29+
30+
await expectScreenshot({
31+
themes: ['light'],
32+
});
33+
});
1434

15-
await expectScreenshot({});
35+
createSmokeScenarios<Partial<TocProps>>({}, {}).forEach(([title, props]) => {
36+
smokeTest(`${title}-hover`, async ({mount, expectScreenshot}) => {
37+
const root = await mount(<TestToc {...props} />);
1638

1739
await root.getByText('Disk controls').hover();
1840

1941
await expectScreenshot({
2042
nameSuffix: 'hovered',
21-
});
22-
23-
await root.getByText('Disk controls').click();
24-
25-
await expectScreenshot({
26-
nameSuffix: 'after click',
43+
themes: ['light'],
2744
});
2845
});
2946
});

src/components/Toc/__tests__/helpers.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import type {TocProps} from '../Toc';
42
import {Toc} from '../Toc';
53

@@ -33,7 +31,7 @@ const testItems: TocProps['items'] = [
3331
] as const;
3432

3533
export const TestToc = (props: Partial<TocProps>) => {
36-
const [active, setActive] = React.useState<string | undefined>(undefined);
34+
const [active, setActive] = React.useState<string | undefined>(props.value);
3735

3836
return (
3937
<Toc

0 commit comments

Comments
 (0)