Skip to content

Commit

Permalink
refactor(CircleOcticon): Move files to folder, add storybook and e2e …
Browse files Browse the repository at this point in the history
…tests. (#3119)

* Reorganize CircleOcticon files, add story and e2e tests.

* Add index file.

* Update generated/components.json

* refactor(CircleBadge): move files into folder, add e2e tests. (#3118)

* Reorganize CircleBadge, add e2e tests.

* Update generated/components.json

* test(vrt): update snapshots

* Update docs reference.

---------

Co-authored-by: radglob <[email protected]>

* Update generated/components.json

* test(vrt): update snapshots

---------

Co-authored-by: radglob <[email protected]>
  • Loading branch information
2 people authored and jonrohan committed Apr 11, 2023
1 parent eac347d commit 3b6d537
Show file tree
Hide file tree
Showing 26 changed files with 167 additions and 26 deletions.
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.
2 changes: 1 addition & 1 deletion docs/content/CircleOcticon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: CircleOcticon
status: Alpha
---

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

CircleOcticon renders any Octicon with a circle background. CircleOcticons are most commonly used to represent the status of a pull request in the comment timeline.

Expand Down
61 changes: 61 additions & 0 deletions e2e/components/CircleOcticon.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'

test.describe('CircleOcticon', () => {
test.describe('Default', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-circleocticon--default',
globals: {
colorScheme: theme,
},
})

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

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-circleocticon--default',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})

test.describe('Playground', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-circleocticon--playground',
globals: {
colorScheme: theme,
},
})

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

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-circleocticon--playground',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})
})
53 changes: 29 additions & 24 deletions generated/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,6 @@
],
"subcomponents": []
},
"circle_octicon": {
"id": "circle_octicon",
"name": "CircleOcticon",
"status": "alpha",
"a11yReviewed": false,
"stories": [],
"props": [
{
"name": "icon",
"type": "Octicon"
},
{
"name": "size",
"defaultValue": "32",
"type": "number",
"description": "Set the width and height of the icon in pixels."
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"dialog": {
"id": "dialog",
"name": "Dialog",
Expand Down Expand Up @@ -1668,6 +1644,35 @@
}
]
},
"circle_octicon": {
"id": "circle_octicon",
"name": "CircleOcticon",
"status": "alpha",
"a11yReviewed": false,
"stories": [
{
"id": "components-circleocticon--default",
"code": "() => (\n <CircleOcticon\n icon={CheckIcon}\n size={32}\n sx={{\n backgroundColor: 'success.fg',\n color: 'fg.onEmphasis',\n }}\n />\n)"
}
],
"props": [
{
"name": "icon",
"type": "Octicon"
},
{
"name": "size",
"defaultValue": "32",
"type": "number",
"description": "Set the width and height of the icon in pixels."
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"counter_label": {
"id": "counter_label",
"name": "CounterLabel",
Expand Down
15 changes: 15 additions & 0 deletions script/generate-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,21 @@ const components = new Map([
],
},
],
[
'CircleOcticon',
{
stories: [
{
id: 'components-circleocticon--default',
name: 'Default',
},
{
id: 'components-circleocticon--playground',
name: 'Playground',
},
],
},
],
[
'CircleBadge',
{
Expand Down
File renamed without changes.
59 changes: 59 additions & 0 deletions src/CircleOcticon/CircleOcticon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react'
import {Meta, ComponentStory} from '@storybook/react'
import CircleOcticon from './CircleOcticon'
import {CheckIcon} from '@primer/octicons-react'

export default {
title: 'Components/CircleOcticon',
component: CircleOcticon,
} as Meta<typeof CircleOcticon>

export const Default = () => (
<CircleOcticon icon={CheckIcon} size={32} sx={{backgroundColor: 'success.fg', color: 'fg.onEmphasis'}} />
)

export const Playground: ComponentStory<typeof CircleOcticon> = args => <CircleOcticon {...args} />

Playground.args = {
icon: CheckIcon,
size: 32,
sx: {backgroundColor: 'success.fg', color: 'fg.onEmphasis'},
}

Playground.argTypes = {
icon: {
controls: false,
table: {
disable: true,
},
},
size: {
controls: {
type: 'number',
},
},
sx: {
controls: false,
table: {
disable: true,
},
},
as: {
controls: false,
table: {
disable: true,
},
},
ref: {
controls: false,
table: {
disable: true,
},
},
theme: {
controls: false,
table: {
disable: true,
},
},
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {IconProps} from '@primer/octicons-react'
import React from 'react'
import Box, {BoxProps} from './Box'
import Box, {BoxProps} from '../Box'

export type CircleOcticonProps = {
as?: React.ElementType
Expand Down
1 change: 1 addition & 0 deletions src/CircleOcticon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default, CircleOcticonProps} from './CircleOcticon'

0 comments on commit 3b6d537

Please sign in to comment.