|
| 1 | +import {createSmokeScenarios} from '@gravity-ui/playwright-tools/component-tests'; |
1 | 2 | import {expect} from '@playwright/experimental-ct-react'; |
2 | 3 |
|
3 | | -import {createSmokeScenarios} from 'src/stories/tests-factory/create-smoke-scenarios'; |
4 | | -import {smokeTest, test} from '~playwright/core'; |
5 | | - |
6 | | -import type {Cases, CasesWithName} from '../../../stories/tests-factory/models'; |
| 4 | +import {test} from '~playwright/core'; |
7 | 5 |
|
8 | 6 | import type {TestSuggestProps} from './TestSuggest'; |
9 | 7 | import {TestSuggest} from './TestSuggest'; |
10 | 8 |
|
11 | 9 | const QA_SUGGEST_POPUP = 'qa-suggest-popup'; |
12 | 10 | const QA_SUGGEST_TEXT_INPUT = 'qa-suggest-text-input'; |
13 | 11 |
|
14 | | -const sizeCases: Cases<TestSuggestProps['size']> = ['s', 'm', 'l', 'xl']; |
15 | | - |
16 | | -const disabledCases: Cases<TestSuggestProps['disabled']> = [true]; |
17 | | - |
18 | | -const hasClearCases: Cases<TestSuggestProps['hasClear']> = [true]; |
19 | | - |
20 | | -const popupWidthCases: CasesWithName<TestSuggestProps['popupWidth']> = [ |
21 | | - ['fit', 'fit'], |
22 | | - ['auto', 'auto'], |
23 | | - ['number', 256], |
24 | | -]; |
25 | | - |
26 | | -const customPopupCases: Cases<TestSuggestProps['customPopup']> = [true]; |
27 | | - |
28 | 12 | test.describe('Suggest', {tag: '@Suggest'}, () => { |
29 | 13 | const defaultProps: TestSuggestProps = { |
30 | 14 | value: 'Earth', |
31 | 15 | qa: QA_SUGGEST_TEXT_INPUT, |
32 | 16 | popupQa: QA_SUGGEST_POPUP, |
33 | 17 | }; |
34 | 18 |
|
35 | | - createSmokeScenarios<TestSuggestProps>(defaultProps, { |
36 | | - disabled: disabledCases, |
37 | | - hasClear: hasClearCases, |
38 | | - size: sizeCases, |
39 | | - }).forEach(([title, props]) => { |
40 | | - smokeTest(title, async ({mount, page, expectScreenshot}) => { |
41 | | - await mount( |
42 | | - <div style={{height: 512}}> |
43 | | - <h4>{title}</h4> |
44 | | - <TestSuggest {...props} /> |
45 | | - </div>, |
46 | | - ); |
47 | | - |
48 | | - await expect(page.getByTestId(QA_SUGGEST_TEXT_INPUT)).toBeVisible(); |
49 | | - |
50 | | - await expectScreenshot({themes: ['light']}); |
| 19 | + test('smoke', {tag: ['@smoke']}, async ({mount, expectScreenshot}) => { |
| 20 | + const smokeScenarios = createSmokeScenarios<TestSuggestProps>(defaultProps, { |
| 21 | + size: ['s', 'm', 'l', 'xl'], |
| 22 | + disabled: [true], |
| 23 | + hasClear: [true], |
51 | 24 | }); |
52 | | - }); |
53 | | - |
54 | | - createSmokeScenarios<TestSuggestProps>( |
55 | | - defaultProps, |
56 | | - {popupWidth: popupWidthCases}, |
57 | | - {scenarioName: 'opened'}, |
58 | | - ).forEach(([title, props]) => { |
59 | | - smokeTest(title, async ({mount, page, expectScreenshot}) => { |
60 | | - await mount( |
61 | | - <div style={{height: 512}}> |
62 | | - <h4>{title}</h4> |
63 | | - <TestSuggest {...props} /> |
64 | | - </div>, |
65 | | - ); |
66 | 25 |
|
67 | | - await page.getByRole('textbox').click(); |
68 | | - await expect(page.getByTestId(QA_SUGGEST_POPUP)).toBeVisible(); |
69 | | - |
70 | | - await expectScreenshot({themes: ['light']}); |
71 | | - }); |
| 26 | + await mount( |
| 27 | + <div> |
| 28 | + {smokeScenarios.map(([title, props]) => ( |
| 29 | + <div key={title}> |
| 30 | + <h4>{title}</h4> |
| 31 | + <TestSuggest {...props} /> |
| 32 | + </div> |
| 33 | + ))} |
| 34 | + </div>, |
| 35 | + ); |
| 36 | + |
| 37 | + await expectScreenshot({themes: ['light']}); |
72 | 38 | }); |
73 | 39 |
|
74 | | - createSmokeScenarios<TestSuggestProps>( |
75 | | - defaultProps, |
76 | | - {customPopup: customPopupCases}, |
77 | | - {scenarioName: 'customPopup'}, |
78 | | - ).forEach(([title, props]) => { |
79 | | - smokeTest(title, async ({mount, page, expectScreenshot}) => { |
80 | | - await mount( |
81 | | - <div style={{height: 512}}> |
82 | | - <h4>{title}</h4> |
83 | | - <TestSuggest {...props} /> |
84 | | - </div>, |
85 | | - ); |
| 40 | + test('smoke opened', {tag: ['@smoke']}, async ({mount, page, expectScreenshot}) => { |
| 41 | + const smokeScenarios = createSmokeScenarios<TestSuggestProps>(defaultProps, { |
| 42 | + popupWidth: [ |
| 43 | + ['fit', 'fit'], |
| 44 | + ['auto', 'auto'], |
| 45 | + ['number', 256], |
| 46 | + ], |
| 47 | + }); |
86 | 48 |
|
87 | | - await page.getByRole('textbox').click(); |
88 | | - await expect(page.getByTestId(QA_SUGGEST_POPUP)).toBeVisible(); |
| 49 | + await mount( |
| 50 | + <div> |
| 51 | + {smokeScenarios.map(([title, props]) => ( |
| 52 | + <div key={title} style={{height: 200}}> |
| 53 | + <h4>{title}</h4> |
| 54 | + <TestSuggest {...props} /> |
| 55 | + </div> |
| 56 | + ))} |
| 57 | + </div>, |
| 58 | + ); |
| 59 | + |
| 60 | + await page.getByRole('textbox').first().click(); |
| 61 | + await expect(page.getByTestId(QA_SUGGEST_POPUP).first()).toBeVisible(); |
| 62 | + |
| 63 | + await expectScreenshot({themes: ['light']}); |
| 64 | + }); |
89 | 65 |
|
90 | | - await expectScreenshot({themes: ['light']}); |
| 66 | + test('smoke customPopup', {tag: ['@smoke']}, async ({mount, page, expectScreenshot}) => { |
| 67 | + const smokeScenarios = createSmokeScenarios<TestSuggestProps>(defaultProps, { |
| 68 | + customPopup: [true], |
91 | 69 | }); |
| 70 | + |
| 71 | + await mount( |
| 72 | + <div> |
| 73 | + {smokeScenarios.map(([title, props]) => ( |
| 74 | + <div key={title} style={{height: 200}}> |
| 75 | + <h4>{title}</h4> |
| 76 | + <TestSuggest {...props} /> |
| 77 | + </div> |
| 78 | + ))} |
| 79 | + </div>, |
| 80 | + ); |
| 81 | + |
| 82 | + await page.getByRole('textbox').first().click(); |
| 83 | + await expect(page.getByTestId(QA_SUGGEST_POPUP).first()).toBeVisible(); |
| 84 | + |
| 85 | + await expectScreenshot({themes: ['light']}); |
92 | 86 | }); |
93 | 87 | }); |
0 commit comments