Skip to content

refactor(AvatarPair): move files to folder, add e2e tests and stories #2906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/content/AvatarPair.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
componentId: avatar_pair
title: AvatarPair
status: Alpha
source: https://github.com/primer/react/blob/main/src/AvatarPair.tsx
source: https://github.com/primer/react/blob/main/src/AvatarPair
---

import data from '../../src/AvatarPair.docs.json'
import data from '../../src/AvatarPair/AvatarPair.docs.json'

```js
import {AvatarPair} from '@primer/react'
Expand Down
107 changes: 107 additions & 0 deletions e2e/components/AvatarPair.test.ts
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('AvatarPair', () => {
test.describe('Default', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-avatarpair--default',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`AvatarPair.Default.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-avatarpair--default',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations({
rules: {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},
},
})
})
})
}
})

test.describe('Parent Circle', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-avatarpair-features--parent-circle',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`AvatarPair.Parent Circle.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-avatarpair-features--parent-circle',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations({
rules: {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},
},
})
})
})
}
})

test.describe('Parent Square', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-avatarpair-features--parent-square',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`AvatarPair.Parent Square.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-avatarpair-features--parent-square',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations({
rules: {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},
},
})
})
})
}
})
})
40 changes: 20 additions & 20 deletions generated/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,6 @@
}
]
},
"avatar_pair": {
"id": "avatar_pair",
"name": "AvatarPair",
"status": "alpha",
"a11yReviewed": false,
"stories": [],
"props": [
{
"name": "children",
"type": "Avatar[]",
"defaultValue": "",
"description": ""
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"avatar_stack": {
"id": "avatar_stack",
"name": "AvatarStack",
Expand Down Expand Up @@ -2220,6 +2200,26 @@
],
"subcomponents": []
},
"avatar_pair": {
"id": "avatar_pair",
"name": "AvatarPair",
"status": "alpha",
"a11yReviewed": false,
"stories": [],
"props": [
{
"name": "children",
"type": "Avatar[]",
"defaultValue": "",
"description": ""
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"branch_name": {
"id": "branch_name",
"name": "BranchName",
Expand Down
19 changes: 19 additions & 0 deletions script/generate-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ const components = new Map([
],
},
],
[
'AvatarPair',
{
stories: [
{
id: 'components-avatarpair--default',
name: 'Default',
},
{
id: 'components-avatarpair-features--parent-circle',
name: 'Parent Circle',
},
{
id: 'components-avatarpair-features--parent-square',
name: 'Parent Square',
},
],
},
],
[
'BranchName',
{
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions src/AvatarPair/AvatarPair.features.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react'
import {ComponentMeta} from '@storybook/react'
import AvatarPair from './AvatarPair'
import Avatar from '../Avatar'

export default {
title: 'Components/AvatarPair/Features',
component: AvatarPair,
} as ComponentMeta<typeof AvatarPair>

export const ParentCircle = () => (
<AvatarPair>
<Avatar src="https://avatars.githubusercontent.com/u/92997159?v=4" />
<Avatar square src="https://avatars.githubusercontent.com/primer" />
</AvatarPair>
)

export const ParentSquare = () => (
<AvatarPair>
<Avatar square src="https://avatars.githubusercontent.com/primer" />
<Avatar src="https://avatars.githubusercontent.com/u/92997159?v=4" />
</AvatarPair>
)
16 changes: 16 additions & 0 deletions src/AvatarPair/AvatarPair.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react'
import {ComponentMeta} from '@storybook/react'
import AvatarPair from './AvatarPair'
import Avatar from '../Avatar'

export default {
title: 'Components/AvatarPair',
component: AvatarPair,
} as ComponentMeta<typeof AvatarPair>

export const Default = () => (
<AvatarPair>
<Avatar src="https://avatars.githubusercontent.com/u/92997159?v=4" />
<Avatar src="https://avatars.githubusercontent.com/primer" />
</AvatarPair>
)
6 changes: 3 additions & 3 deletions src/AvatarPair.tsx → src/AvatarPair/AvatarPair.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import styled from 'styled-components'
import Avatar, {AvatarProps} from './Avatar'
import {get} from './constants'
import Box, {BoxProps} from './Box'
import Avatar, {AvatarProps} from '../Avatar'
import {get} from '../constants'
import Box, {BoxProps} from '../Box'

const ChildAvatar = styled(Avatar)`
position: absolute;
Expand Down
1 change: 1 addition & 0 deletions src/AvatarPair/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default, AvatarPairProps} from './AvatarPair'
1 change: 1 addition & 0 deletions src/__tests__/storybook.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const ROOT_DIRECTORY = path.resolve(__dirname, '..', '..')
const allowlist = [
'ActionList',
'Avatar',
'AvatarPair',
'Breadcrumbs',
'BranchName',
'Button',
Expand Down