-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(BaseStyles): Add vrt tests (#5346)
* Add tests for basestyles * Add changeset * test(vrt): update snapshots * Add snapshot * Remove changeset --------- Co-authored-by: JelloBagel <[email protected]>
- Loading branch information
1 parent
17637a8
commit 4bb159b
Showing
13 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+4.61 KB
...s/BaseStyles.test.ts-snapshots/BaseStyles-Dev-Default-dark-colorblind-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.61 KB
...nents/BaseStyles.test.ts-snapshots/BaseStyles-Dev-Default-dark-dimmed-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.62 KB
...aseStyles.test.ts-snapshots/BaseStyles-Dev-Default-dark-high-contrast-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.61 KB
...s/components/BaseStyles.test.ts-snapshots/BaseStyles-Dev-Default-dark-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.61 KB
...s/BaseStyles.test.ts-snapshots/BaseStyles-Dev-Default-dark-tritanopia-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.63 KB
.../BaseStyles.test.ts-snapshots/BaseStyles-Dev-Default-light-colorblind-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.62 KB
...seStyles.test.ts-snapshots/BaseStyles-Dev-Default-light-high-contrast-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.63 KB
.../components/BaseStyles.test.ts-snapshots/BaseStyles-Dev-Default-light-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.63 KB
.../BaseStyles.test.ts-snapshots/BaseStyles-Dev-Default-light-tritanopia-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {test, expect} from '@playwright/test' | ||
import {visit} from '../test-helpers/storybook' | ||
import {themes} from '../test-helpers/themes' | ||
|
||
const stories = [ | ||
{ | ||
id: 'behaviors-basestyles-dev--default', | ||
title: 'Dev Default', | ||
}, | ||
] as const | ||
|
||
test.describe('BaseStyles', () => { | ||
for (const story of stories) { | ||
test.describe(story.title, () => { | ||
for (const theme of themes) { | ||
test.describe(theme, () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: story.id, | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
|
||
// Default state | ||
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot( | ||
`BaseStyles.${story.title}.${theme}.png`, | ||
) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: story.id, | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
}) | ||
} | ||
}) | ||
} | ||
}) |
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,11 @@ | ||
import {BaseStyles} from '.' | ||
import type {Meta} from '@storybook/react' | ||
import React from 'react' | ||
import type {ComponentProps} from './utils/types' | ||
|
||
export default { | ||
title: 'Behaviors/BaseStyles/Dev', | ||
component: BaseStyles, | ||
} as Meta<ComponentProps<typeof BaseStyles>> | ||
|
||
export const Default = () => <BaseStyles>Hello</BaseStyles> |
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,33 @@ | ||
import {render} from '@testing-library/react' | ||
import MatchMediaMock from 'jest-matchmedia-mock' | ||
import 'jest-styled-components' | ||
import React from 'react' | ||
import {BaseStyles} from '..' | ||
|
||
let matchMedia: MatchMediaMock | ||
|
||
describe('BaseStyles', () => { | ||
beforeAll(() => { | ||
matchMedia = new MatchMediaMock() | ||
}) | ||
|
||
afterEach(() => { | ||
matchMedia.clear() | ||
}) | ||
|
||
it('has default styles', () => { | ||
const {container} = render(<BaseStyles></BaseStyles>) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
it('respects styling props', () => { | ||
const styles = { | ||
color: '#f00', | ||
fontFamily: 'Arial', | ||
lineHeight: '3.5', | ||
} | ||
|
||
const {container} = render(<BaseStyles {...styles}></BaseStyles>) | ||
expect(container.children[0]).toHaveStyle({color: '#f00', 'font-family': 'Arial', 'line-height': '3.5'}) | ||
}) | ||
}) |
19 changes: 19 additions & 0 deletions
19
packages/react/src/__tests__/__snapshots__/BaseStyles.test.tsx.snap
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,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`BaseStyles has default styles 1`] = ` | ||
.c0 { | ||
font-family: normal; | ||
line-height: default; | ||
color: fg.default; | ||
} | ||
<div> | ||
<div | ||
class="c0" | ||
color="fg.default" | ||
data-color-mode="light" | ||
data-portal-root="true" | ||
font-family="normal" | ||
/> | ||
</div> | ||
`; |