Skip to content

Commit

Permalink
Refactor(FilteredSearch): move files to folder, add storybook and e2e…
Browse files Browse the repository at this point in the history
… tests. (#3125)

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

* Add aria-label to TextInput, fix docs reference.

* Update generated/components.json

* test(vrt): update snapshots

* replace createRef with useRef (#3124)

* replace createRef with useRef

* changeset

* missed null

* refactor(FilterList): add files to folder, add storybook and e2e tests. (#3122)

* Reorganize FilterList files into folder, add storybook and e2e tests.

* Update generated/components.json

* test(vrt): update snapshots

---------

Co-authored-by: radglob <radglob@users.noreply.github.com>

* Fix generated components.

---------

Co-authored-by: radglob <radglob@users.noreply.github.com>
Co-authored-by: Matthew Costabile <mattcosta7@github.com>
  • Loading branch information
3 people committed Apr 6, 2023
1 parent 6ee3565 commit ce03159
Show file tree
Hide file tree
Showing 26 changed files with 153 additions and 23 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/FilteredSearch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: FilteredSearch
status: Alpha
---

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

The FilteredSearch component helps style an ActionMenu and a TextInput side-by-side.

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

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

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

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

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-filteredsearch--playground',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})
})
43 changes: 24 additions & 19 deletions generated/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,6 @@
}
]
},
"filtered_search": {
"id": "filtered_search",
"name": "FilteredSearch",
"status": "alpha",
"a11yReviewed": false,
"stories": [],
"props": [
{
"name": "children",
"type": "React.ReactNode",
"description": "FilteredSearch is expected to contain an `ActionMenu` followed by a `TextInput`."
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"label_group": {
"id": "label_group",
"name": "LabelGroup",
Expand Down Expand Up @@ -2060,6 +2041,30 @@
}
]
},
"filtered_search": {
"id": "filtered_search",
"name": "FilteredSearch",
"status": "alpha",
"a11yReviewed": false,
"stories": [
{
"id": "components-filteredsearch--default",
"code": "() => (\n <FilteredSearch>\n <ActionMenu>\n <ActionMenu.Button as=\"summary\">Filter</ActionMenu.Button>\n <ActionMenu.Overlay>\n <ActionList>\n <ActionList.Item>Item 1</ActionList.Item>\n <ActionList.Item>Item 2</ActionList.Item>\n <ActionList.Item>Item 3</ActionList.Item>\n </ActionList>\n </ActionMenu.Overlay>\n </ActionMenu>\n <TextInput aria-label=\"filtered-search\" leadingVisual={SearchIcon} />\n </FilteredSearch>\n)"
}
],
"props": [
{
"name": "children",
"type": "React.ReactNode",
"description": "FilteredSearch is expected to contain an `ActionMenu` followed by a `TextInput`."
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"flash": {
"id": "flash",
"name": "Flash",
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 @@ -402,6 +402,21 @@ const components = new Map([
],
},
],
[
'FilteredSearch',
{
stories: [
{
id: 'components-filteredsearch--default',
name: 'Default',
},
{
id: 'components-filteredsearch--playground',
name: 'Playground',
},
],
},
],
[
'FilterList',
{
Expand Down
File renamed without changes.
48 changes: 48 additions & 0 deletions src/FilteredSearch/FilteredSearch.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react'
import {Meta, ComponentStory} from '@storybook/react'
import FilteredSearch from './FilteredSearch'
import {ActionList} from '../ActionList'
import {ActionMenu} from '../ActionMenu'
import TextInput from '../TextInput'
import {SearchIcon} from '@primer/octicons-react'

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

export const Default = () => (
<FilteredSearch>
<ActionMenu>
<ActionMenu.Button as="summary">Filter</ActionMenu.Button>
<ActionMenu.Overlay>
<ActionList>
<ActionList.Item>Item 1</ActionList.Item>
<ActionList.Item>Item 2</ActionList.Item>
<ActionList.Item>Item 3</ActionList.Item>
</ActionList>
</ActionMenu.Overlay>
</ActionMenu>
<TextInput aria-label="filtered-search" leadingVisual={SearchIcon} />
</FilteredSearch>
)

export const Playground: ComponentStory<typeof FilteredSearch> = args => (
<FilteredSearch {...args}>
<ActionMenu>
<ActionMenu.Button as="summary">Filter</ActionMenu.Button>
<ActionMenu.Overlay>
<ActionList>
<ActionList.Item>Item 1</ActionList.Item>
<ActionList.Item>Item 2</ActionList.Item>
<ActionList.Item>Item 3</ActionList.Item>
</ActionList>
</ActionMenu.Overlay>
</ActionMenu>
<TextInput aria-label="filtered-search" leadingVisual={SearchIcon} />
</FilteredSearch>
)

Playground.args = {}

Playground.argTypes = {}
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 FilteredSearch = styled.div<SxProp>`
display: flex;
Expand Down
1 change: 1 addition & 0 deletions src/FilteredSearch/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default, FilteredSearchProps} from './FilteredSearch'

0 comments on commit ce03159

Please sign in to comment.