-
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(Tabs): add smoke visual tests (#1794)
- Loading branch information
1 parent
264118e
commit f022e8b
Showing
8 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
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
Binary file added
BIN
+9.88 KB
...isual.test.tsx-snapshots/Tabs-smoke-allow-not-selected-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
+68 KB
..._snapshots__/Tabs.visual.test.tsx-snapshots/Tabs-smoke-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
+55.1 KB
...s.visual.test.tsx-snapshots/Tabs-smoke-with-custom-tab-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.
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
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,93 @@ | ||
import {smokeTest, test} from '~playwright/core'; | ||
|
||
import {createSmokeScenarios} from '../../../stories/tests-factory/create-smoke-scenarios'; | ||
import type {TabsProps} from '../Tabs'; | ||
|
||
import {directionCases, sizeCases} from './cases'; | ||
import {TestTabs, TestTabsWithCustomTabs} from './helpers'; | ||
|
||
test.describe('Tabs', {tag: '@Tabs'}, () => { | ||
smokeTest('', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<TabsProps>( | ||
{ | ||
activeTab: 'active', | ||
}, | ||
{ | ||
size: sizeCases, | ||
direction: directionCases, | ||
}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<TestTabs {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
smokeTest('allow not selected', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<TabsProps>( | ||
{ | ||
allowNotSelected: true, | ||
}, | ||
{}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<TestTabs {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</div>, | ||
); | ||
|
||
await expectScreenshot({ | ||
themes: ['light'], | ||
}); | ||
}); | ||
|
||
smokeTest('with custom tab', async ({mount, expectScreenshot}) => { | ||
const smokeScenarios = createSmokeScenarios<TabsProps>( | ||
{ | ||
activeTab: 'active', | ||
}, | ||
{ | ||
size: sizeCases, | ||
direction: directionCases, | ||
}, | ||
); | ||
|
||
await mount( | ||
<div> | ||
{smokeScenarios.map(([title, props]) => ( | ||
<div key={title}> | ||
<h4>{title}</h4> | ||
<div> | ||
<TestTabsWithCustomTabs {...props} /> | ||
</div> | ||
</div> | ||
))} | ||
</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,9 @@ | ||
import type {Cases} from '../../../stories/tests-factory/models'; | ||
import type {TabsProps} from '../Tabs'; | ||
import {TabsDirection} from '../Tabs'; | ||
|
||
export const sizeCases: Cases<TabsProps['size']> = ['m', 'l', 'xl']; | ||
export const directionCases: Cases<TabsProps['direction']> = [ | ||
TabsDirection.Horizontal, | ||
TabsDirection.Vertical, | ||
]; |
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,28 @@ | ||
import type {TabsItemProps, TabsProps} from '../Tabs'; | ||
import {Tabs} from '../Tabs'; | ||
import {getTabsMock} from '../__stories__/getTabsMock'; | ||
|
||
export const TestTabs = (props: Partial<TabsProps>) => { | ||
const items = getTabsMock({}); | ||
|
||
return <Tabs items={items} {...props} />; | ||
}; | ||
|
||
export const TestTabsWithCustomTabs = (props: Partial<TabsProps>) => { | ||
const items = getTabsMock({}); | ||
|
||
return ( | ||
<Tabs | ||
items={items} | ||
wrapTo={(item: TabsItemProps) => { | ||
return ( | ||
// eslint-disable-next-line jsx-a11y/anchor-is-valid | ||
<a key={item.id} href="#" style={{textDecoration: 'none'}} data-qa={item.qa}> | ||
{item.title} | ||
</a> | ||
); | ||
}} | ||
{...props} | ||
/> | ||
); | ||
}; |