-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Avatar): move files to folder, add e2e tests and stories (#2904
) * refactor(Avatar): move files to folder and add stories * Update generated/components.json * Adjust source and data in docs * Add e2e tests * test(vrt): update snapshots * Opt the component into storybook tests * Add e2e test * test(vrt): update snapshots --------- Co-authored-by: josepmartins <josepmartins@users.noreply.github.com>
- Loading branch information
1 parent
6db8c8a
commit 55a1ce5
Showing
38 changed files
with
250 additions
and
38 deletions.
There are no files selected for viewing
Binary file added
BIN
+6.19 KB
...ts/components/Avatar.test.ts-snapshots/Avatar-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
+6.17 KB
...pshots/components/Avatar.test.ts-snapshots/Avatar-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
+6.35 KB
...components/Avatar.test.ts-snapshots/Avatar-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
+6.19 KB
...ght/snapshots/components/Avatar.test.ts-snapshots/Avatar-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
+6.19 KB
...ts/components/Avatar.test.ts-snapshots/Avatar-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
+6.29 KB
...s/components/Avatar.test.ts-snapshots/Avatar-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
+6.32 KB
...omponents/Avatar.test.ts-snapshots/Avatar-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
+6.29 KB
...ht/snapshots/components/Avatar.test.ts-snapshots/Avatar-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
+6.29 KB
...s/components/Avatar.test.ts-snapshots/Avatar-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.
Binary file added
BIN
+28.9 KB
...shots/components/Avatar.test.ts-snapshots/Avatar-Size-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
+28.1 KB
...snapshots/components/Avatar.test.ts-snapshots/Avatar-Size-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
+31.2 KB
...ts/components/Avatar.test.ts-snapshots/Avatar-Size-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
+28.9 KB
...wright/snapshots/components/Avatar.test.ts-snapshots/Avatar-Size-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
+28.9 KB
...shots/components/Avatar.test.ts-snapshots/Avatar-Size-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
+30.7 KB
...hots/components/Avatar.test.ts-snapshots/Avatar-Size-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
+31 KB
...s/components/Avatar.test.ts-snapshots/Avatar-Size-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
+30.7 KB
...right/snapshots/components/Avatar.test.ts-snapshots/Avatar-Size-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
+30.7 KB
...hots/components/Avatar.test.ts-snapshots/Avatar-Size-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.
Binary file added
BIN
+5.61 KB
...ots/components/Avatar.test.ts-snapshots/Avatar-Square-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
+5.62 KB
...apshots/components/Avatar.test.ts-snapshots/Avatar-Square-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
+5.64 KB
.../components/Avatar.test.ts-snapshots/Avatar-Square-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
+5.61 KB
...ight/snapshots/components/Avatar.test.ts-snapshots/Avatar-Square-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
+5.61 KB
...ots/components/Avatar.test.ts-snapshots/Avatar-Square-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
+5.59 KB
...ts/components/Avatar.test.ts-snapshots/Avatar-Square-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
+5.62 KB
...components/Avatar.test.ts-snapshots/Avatar-Square-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
+5.59 KB
...ght/snapshots/components/Avatar.test.ts-snapshots/Avatar-Square-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.59 KB
...ts/components/Avatar.test.ts-snapshots/Avatar-Square-light-tritanopia-linux.png
Oops, something went wrong.
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
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,107 @@ | ||
import {test, expect} from '@playwright/test' | ||
import {visit} from '../test-helpers/storybook' | ||
import {themes} from '../test-helpers/themes' | ||
|
||
test.describe('Avatar', () => { | ||
test.describe('Default', () => { | ||
for (const theme of themes) { | ||
test.describe(theme, () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-avatar--default', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
|
||
// Default state | ||
expect(await page.screenshot()).toMatchSnapshot(`Avatar.Default.${theme}.png`) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-avatar--default', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
await expect(page).toHaveNoViolations({ | ||
rules: { | ||
'color-contrast': { | ||
enabled: theme !== 'dark_dimmed', | ||
}, | ||
}, | ||
}) | ||
}) | ||
}) | ||
} | ||
}) | ||
|
||
test.describe('Size', () => { | ||
for (const theme of themes) { | ||
test.describe(theme, () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-avatar-features--size', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
|
||
// Default state | ||
expect(await page.screenshot()).toMatchSnapshot(`Avatar.Size.${theme}.png`) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-avatar-features--size', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
await expect(page).toHaveNoViolations({ | ||
rules: { | ||
'color-contrast': { | ||
enabled: theme !== 'dark_dimmed', | ||
}, | ||
}, | ||
}) | ||
}) | ||
}) | ||
} | ||
}) | ||
|
||
test.describe('Square', () => { | ||
for (const theme of themes) { | ||
test.describe(theme, () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-avatar-features--square', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
|
||
// Default state | ||
expect(await page.screenshot()).toMatchSnapshot(`Avatar.Square.${theme}.png`) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-avatar-features--square', | ||
globals: { | ||
colorScheme: theme, | ||
}, | ||
}) | ||
await expect(page).toHaveNoViolations({ | ||
rules: { | ||
'color-contrast': { | ||
enabled: theme !== 'dark_dimmed', | ||
}, | ||
}, | ||
}) | ||
}) | ||
}) | ||
} | ||
}) | ||
}) |
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
File renamed without changes.
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,27 @@ | ||
import React from 'react' | ||
import {ComponentMeta} from '@storybook/react' | ||
import Avatar from './Avatar' | ||
|
||
export default { | ||
title: 'Components/Avatar/Features', | ||
component: Avatar, | ||
} as ComponentMeta<typeof Avatar> | ||
|
||
export const Square = () => <Avatar square src="https://avatars.githubusercontent.com/primer" /> | ||
|
||
export const Size = () => ( | ||
<div> | ||
<Avatar size={4} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={8} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={12} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={16} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={20} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={24} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={28} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={32} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={40} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={48} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={56} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
<Avatar size={64} src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
</div> | ||
) |
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,57 @@ | ||
import React from 'react' | ||
import {ComponentMeta, ComponentStory} from '@storybook/react' | ||
import Avatar from './Avatar' | ||
|
||
export default { | ||
title: 'Components/Avatar', | ||
component: Avatar, | ||
} as ComponentMeta<typeof Avatar> | ||
|
||
export const Default = () => <Avatar src="https://avatars.githubusercontent.com/u/92997159?v=4" /> | ||
|
||
export const Playground: ComponentStory<typeof Avatar> = args => ( | ||
<Avatar src="https://avatars.githubusercontent.com/u/92997159?v=4" {...args} /> | ||
) | ||
|
||
Playground.args = { | ||
size: '20', | ||
} | ||
|
||
Playground.argTypes = { | ||
alt: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
ref: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
forwardedAs: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
sx: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
as: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
theme: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
} |
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 @@ | ||
export {default, AvatarProps} from './Avatar' |
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