Skip to content
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

Refactor(FilteredSearch): move files to folder, add storybook and e2e tests. #3125

Merged
merged 8 commits into from
Apr 6, 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.
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
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'