Skip to content

Commit

Permalink
Refactor(LabelGroup): add files to folder, add storybook and e2e test…
Browse files Browse the repository at this point in the history
…s. (#3131)

* Move files to folder, add storybook and e2e tests.

* Update generated/components.json

* test(vrt): update snapshots

---------

Co-authored-by: radglob <radglob@users.noreply.github.com>
  • Loading branch information
radglob and radglob committed Apr 11, 2023
1 parent 8243a2f commit 0355521
Show file tree
Hide file tree
Showing 26 changed files with 134 additions and 18 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/LabelGroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ status: Alpha
componentId: label_group
---

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

## Example

Expand Down
61 changes: 61 additions & 0 deletions e2e/components/LabelGroup.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('LabelGroup', () => {
test.describe('Default', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-labelgroup--default',
globals: {
colorScheme: theme,
},
})

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

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-labelgroup--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-labelgroup--playground',
globals: {
colorScheme: theme,
},
})

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

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-labelgroup--playground',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})
})
33 changes: 19 additions & 14 deletions generated/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,6 @@
}
]
},
"label_group": {
"id": "label_group",
"name": "LabelGroup",
"status": "alpha",
"a11yReviewed": false,
"stories": [],
"props": [
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"overlay": {
"id": "overlay",
"name": "Overlay",
Expand Down Expand Up @@ -2357,6 +2343,25 @@
],
"subcomponents": []
},
"label_group": {
"id": "label_group",
"name": "LabelGroup",
"status": "alpha",
"a11yReviewed": false,
"stories": [
{
"id": "components-labelgroup--default",
"code": "() => (\n <LabelGroup>\n <Label>Default label</Label>\n <Label variant=\"danger\">\n Label with background indicating a closed PR state\n </Label>\n <Label variant=\"primary\">Default outline label</Label>\n </LabelGroup>\n)"
}
],
"props": [
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"link": {
"id": "link",
"name": "Link",
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 @@ -615,6 +615,21 @@ const components = new Map([
],
},
],
[
'LabelGroup',
{
stories: [
{
id: 'components-labelgroup--default',
name: 'Default',
},
{
id: 'components-labelgroup--playground',
name: 'Playground',
},
],
},
],
[
'Link',
{
Expand Down
File renamed without changes.
34 changes: 34 additions & 0 deletions src/LabelGroup/LabelGroup.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react'
import {Meta, ComponentStory} from '@storybook/react'
import LabelGroup from './LabelGroup'
import Label from '../Label'

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

export const Default = () => (
<LabelGroup>
<Label>Default label</Label>
<Label variant="danger">Label with background indicating a closed PR state</Label>
<Label variant="primary">Default outline label</Label>
</LabelGroup>
)

export const Playground: ComponentStory<typeof LabelGroup> = args => (
<LabelGroup {...args}>
<Label>Default label</Label>
<Label variant="danger">Label with background indicating a closed PR state</Label>
<Label variant="primary">Default outline label</Label>
</LabelGroup>
)

Playground.argTypes = {
sx: {
controls: false,
table: {
disable: true,
},
},
}
6 changes: 3 additions & 3 deletions src/LabelGroup.tsx → src/LabelGroup/LabelGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components'
import {get} from './constants'
import sx, {SxProp} from './sx'
import {ComponentProps} from './utils/types'
import {get} from '../constants'
import sx, {SxProp} from '../sx'
import {ComponentProps} from '../utils/types'

const LabelGroup = styled.span<SxProp>`
& * {
Expand Down
1 change: 1 addition & 0 deletions src/LabelGroup/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default, LabelGroupProps} from './LabelGroup'

0 comments on commit 0355521

Please sign in to comment.