-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(Bradcrumbs): add smoke visual tests (#1819)
- Loading branch information
1 parent
232cd1f
commit 970d10a
Showing
25 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+10.8 KB
...-snapshots/Breadcrumbs-smoke-with-custom-icons-default-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.3 KB
...hots/Breadcrumbs-smoke-with-custom-icons-disabled-true-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.92 KB
...pshots/Breadcrumbs-smoke-with-custom-separator-default-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.16 KB
.../Breadcrumbs-smoke-with-custom-separator-disabled-true-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.29 KB
...sx-snapshots/Breadcrumbs-smoke-with-link-items-default-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.29 KB
...pshots/Breadcrumbs-smoke-with-link-items-disabled-true-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.9 KB
...sx-snapshots/Breadcrumbs-smoke-with-text-items-default-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.7 KB
...adcrumbs-smoke-with-text-items-popupPlacement-auto-end-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.8 KB
.../Breadcrumbs-smoke-with-text-items-popupPlacement-auto-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.7 KB
...crumbs-smoke-with-text-items-popupPlacement-auto-start-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.9 KB
...crumbs-smoke-with-text-items-popupPlacement-bottom-end-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.9 KB
...readcrumbs-smoke-with-text-items-popupPlacement-bottom-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.9 KB
...umbs-smoke-with-text-items-popupPlacement-bottom-start-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.6 KB
...adcrumbs-smoke-with-text-items-popupPlacement-left-end-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16 KB
.../Breadcrumbs-smoke-with-text-items-popupPlacement-left-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.9 KB
...crumbs-smoke-with-text-items-popupPlacement-left-start-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.7 KB
...dcrumbs-smoke-with-text-items-popupPlacement-right-end-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.8 KB
...Breadcrumbs-smoke-with-text-items-popupPlacement-right-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.7 KB
...rumbs-smoke-with-text-items-popupPlacement-right-start-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.3 KB
...eadcrumbs-smoke-with-text-items-popupPlacement-top-end-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.3 KB
...s/Breadcrumbs-smoke-with-text-items-popupPlacement-top-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.4 KB
...dcrumbs-smoke-with-text-items-popupPlacement-top-start-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions
108
src/components/lab/Breadcrumbs/__tests__/Breadcrumbs.visual.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import {expect, smokeTest, test} from '~playwright/core'; | ||
|
||
import {createSmokeScenarios} from '../../../../stories/tests-factory/create-smoke-scenarios'; | ||
import type {BreadcrumbsProps} from '../Breadcrumbs'; | ||
|
||
import {disabledCases, popupPlacementCases} from './cases'; | ||
import { | ||
TestBreadcrumbsWithCustomIcons, | ||
TestBreadcrumbsWithCustomSeparator, | ||
TestBreadcrumbsWithLinkItems, | ||
TestBreadcrumbsWithTextItems, | ||
} from './helpersPlaywright'; | ||
|
||
test.describe('Breadcrumbs', {tag: '@Breadcrumbs'}, () => { | ||
const defaultProps: Omit<BreadcrumbsProps, 'children'> = {}; | ||
|
||
createSmokeScenarios( | ||
defaultProps, | ||
{ | ||
popupPlacement: popupPlacementCases, | ||
}, | ||
{ | ||
scenarioName: 'with text items', | ||
}, | ||
).forEach(([title, props]) => { | ||
smokeTest(title, async ({mount, page, expectScreenshot}) => { | ||
const root = await mount( | ||
<div style={{width: '200px', padding: '100px'}}> | ||
<TestBreadcrumbsWithTextItems {...props} /> | ||
</div>, | ||
); | ||
|
||
await root.locator('button').click(); | ||
|
||
await expect(page.locator(`ul[role="menu"]`)).toBeVisible(); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
}); | ||
|
||
createSmokeScenarios( | ||
defaultProps, | ||
{ | ||
disabled: disabledCases, | ||
}, | ||
{ | ||
scenarioName: 'with link items', | ||
}, | ||
).forEach(([title, props]) => { | ||
smokeTest(title, async ({mount, expectScreenshot}) => { | ||
await mount( | ||
<div style={{width: '200px'}}> | ||
<TestBreadcrumbsWithLinkItems {...props} /> | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
}); | ||
|
||
createSmokeScenarios( | ||
defaultProps, | ||
{ | ||
disabled: disabledCases, | ||
}, | ||
{ | ||
scenarioName: 'with custom icons', | ||
}, | ||
).forEach(([title, props]) => { | ||
smokeTest(title, async ({mount, expectScreenshot}) => { | ||
await mount( | ||
<div style={{width: '400px'}}> | ||
<TestBreadcrumbsWithCustomIcons {...props} /> | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
}); | ||
|
||
createSmokeScenarios( | ||
defaultProps, | ||
{ | ||
disabled: disabledCases, | ||
}, | ||
{ | ||
scenarioName: 'with custom separator', | ||
}, | ||
).forEach(([title, props]) => { | ||
smokeTest(title, async ({mount, expectScreenshot}) => { | ||
await mount( | ||
<div style={{width: '400px'}}> | ||
<TestBreadcrumbsWithCustomSeparator {...props} /> | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type {Cases} from '../../../../stories/tests-factory/models'; | ||
import type {BreadcrumbsProps} from '../Breadcrumbs'; | ||
|
||
export const disabledCases: Cases<BreadcrumbsProps['disabled']> = [true]; | ||
|
||
export const popupPlacementCases: Cases<BreadcrumbsProps['popupPlacement']> = [ | ||
'top', | ||
'right', | ||
'left', | ||
'bottom', | ||
'top-start', | ||
'top-end', | ||
'bottom-start', | ||
'bottom-end', | ||
'right-start', | ||
'right-end', | ||
'left-start', | ||
'left-end', | ||
'auto', | ||
'auto-start', | ||
'auto-end', | ||
]; |
76 changes: 76 additions & 0 deletions
76
src/components/lab/Breadcrumbs/__tests__/helpersPlaywright.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import {ChevronRight, Flame, House, Rocket} from '@gravity-ui/icons'; | ||
|
||
import {Box} from '../../../layout/Box/Box'; | ||
import {Flex} from '../../../layout/Flex/Flex'; | ||
import type {BreadcrumbsProps} from '../Breadcrumbs'; | ||
import {Breadcrumbs} from '../Breadcrumbs'; | ||
|
||
export const TestBreadcrumbsWithTextItems = (props: Omit<BreadcrumbsProps, 'children'>) => { | ||
return ( | ||
<Breadcrumbs {...props}> | ||
<Breadcrumbs.Item>Region</Breadcrumbs.Item> | ||
<Breadcrumbs.Item>Country</Breadcrumbs.Item> | ||
<Breadcrumbs.Item>City</Breadcrumbs.Item> | ||
<Breadcrumbs.Item>District</Breadcrumbs.Item> | ||
<Breadcrumbs.Item>Street</Breadcrumbs.Item> | ||
</Breadcrumbs> | ||
); | ||
}; | ||
|
||
export const TestBreadcrumbsWithLinkItems = (props: Omit<BreadcrumbsProps, 'children'>) => { | ||
return ( | ||
<Breadcrumbs {...props}> | ||
<Breadcrumbs.Item href="/">Home</Breadcrumbs.Item> | ||
<Breadcrumbs.Item href="/components">Components</Breadcrumbs.Item> | ||
<Breadcrumbs.Item href="/components/uikit/breadcrumbs">Breadcrumbs</Breadcrumbs.Item> | ||
</Breadcrumbs> | ||
); | ||
}; | ||
|
||
export const TestBreadcrumbsCollapsed = (props: Omit<BreadcrumbsProps, 'children'>) => { | ||
return ( | ||
<Box overflow="hidden" width={200}> | ||
<Breadcrumbs showRoot {...props}> | ||
<Breadcrumbs.Item key="home">Home</Breadcrumbs.Item> | ||
<Breadcrumbs.Item key="trendy">Trendy</Breadcrumbs.Item> | ||
<Breadcrumbs.Item key="2020 assets">March 2020 Assets</Breadcrumbs.Item> | ||
<Breadcrumbs.Item key="winter">Winter</Breadcrumbs.Item> | ||
<Breadcrumbs.Item key="holiday">Holiday</Breadcrumbs.Item> | ||
</Breadcrumbs> | ||
</Box> | ||
); | ||
}; | ||
|
||
export const TestBreadcrumbsWithCustomSeparator = (props: Omit<BreadcrumbsProps, 'children'>) => { | ||
return ( | ||
<Breadcrumbs separator={<ChevronRight />} {...props}> | ||
<Breadcrumbs.Item>Region</Breadcrumbs.Item> | ||
<Breadcrumbs.Item>Country</Breadcrumbs.Item> | ||
<Breadcrumbs.Item>City</Breadcrumbs.Item> | ||
<Breadcrumbs.Item>District</Breadcrumbs.Item> | ||
<Breadcrumbs.Item>Street</Breadcrumbs.Item> | ||
</Breadcrumbs> | ||
); | ||
}; | ||
|
||
export const TestBreadcrumbsWithCustomIcons = (props: Omit<BreadcrumbsProps, 'children'>) => { | ||
return ( | ||
<Breadcrumbs {...props}> | ||
<Breadcrumbs.Item> | ||
<Flex alignItems="center" gap={1}> | ||
<House /> uikit | ||
</Flex> | ||
</Breadcrumbs.Item> | ||
<Breadcrumbs.Item> | ||
<Flex alignItems="center" gap={1}> | ||
<Flame /> components | ||
</Flex> | ||
</Breadcrumbs.Item> | ||
<Breadcrumbs.Item> | ||
<Flex alignItems="center" gap={1}> | ||
<Rocket style={{minWidth: 16}} /> Breadcrumbs | ||
</Flex> | ||
</Breadcrumbs.Item> | ||
</Breadcrumbs> | ||
); | ||
}; |