Skip to content

(PDS-316) DataGrid Quick Filter #224

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 5 commits into from
Oct 7, 2020
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
42,478 changes: 21,168 additions & 21,310 deletions packages/data-grid/package-lock.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

248 changes: 248 additions & 0 deletions packages/data-grid/src/__test__/__snapshots__/tagBuilder.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Snapshot test Check component matches previous HTML snapshot 1`] = `
<TagBuilder
filters={
Array [
Object {
"field": "all-operating-system",
"fieldLabel": "All Operating System",
"value": "Windows",
},
Object {
"field": "puppet-installed",
"fieldLabel": "Puppet Installed",
"value": "true",
},
]
}
onRemoveAll={[MockFunction]}
onRemoveTag={[MockFunction]}
>
<div
className="dg-tag-bulder-container"
>
<div
className="dg-tag-container"
>
<Tag
class="dg-filter-tag dg-filter-tag-0"
key="dg-filter-tag-1"
label="All Operating System = Windows"
onClick={[Function]}
>
<div
className="rc-tag"
>
<div
className="rc-tag-label-background"
>
<Text
as="div"
className="rc-tag-text"
color={null}
size="medium"
style={Object {}}
>
<div
className="rc-text rc-text-size-medium rc-tag-text"
style={Object {}}
>
All Operating System = Windows
</div>
</Text>
</div>
<Button
aria-label="All Operating System = Windows Remove tag"
as="button"
className="rc-tag-remove-button"
disabled={false}
forwardRefAs="ref"
icon="close"
innerFocus={false}
loading={false}
onClick={[Function]}
trailingIcon={null}
type="primary"
weight="bold"
>
<button
aria-label="All Operating System = Windows Remove tag"
className="rc-button rc-button-primary rc-button-bold rc-button-icon rc-button-empty rc-tag-remove-button"
disabled={false}
onClick={[Function]}
type="button"
>
<Icon
className="rc-button-icon-svg"
size="medium"
style={Object {}}
svg={null}
type="close"
viewBox={null}
>
<svg
className="rc-icon rc-icon-close rc-button-icon-svg"
height="16px"
style={
Object {
"height": "16px",
"width": "16px",
}
}
viewBox="0 0 8 8"
width="16px"
>
<polygon
fillRule="evenodd"
points="6.1 .5 4 2.6 1.9 .5 .5 1.9 2.6 4 .5 6.1 1.9 7.5 4 5.4 6.1 7.5 7.5 6.1 5.4 4 7.5 1.9"
/>
</svg>
</Icon>
<span
className="rc-button-content"
/>
</button>
</Button>
</div>
</Tag>
<Tag
class="dg-filter-tag dg-filter-tag-1"
key="dg-filter-tag-2"
label="Puppet Installed = true"
onClick={[Function]}
>
<div
className="rc-tag"
>
<div
className="rc-tag-label-background"
>
<Text
as="div"
className="rc-tag-text"
color={null}
size="medium"
style={Object {}}
>
<div
className="rc-text rc-text-size-medium rc-tag-text"
style={Object {}}
>
Puppet Installed = true
</div>
</Text>
</div>
<Button
aria-label="Puppet Installed = true Remove tag"
as="button"
className="rc-tag-remove-button"
disabled={false}
forwardRefAs="ref"
icon="close"
innerFocus={false}
loading={false}
onClick={[Function]}
trailingIcon={null}
type="primary"
weight="bold"
>
<button
aria-label="Puppet Installed = true Remove tag"
className="rc-button rc-button-primary rc-button-bold rc-button-icon rc-button-empty rc-tag-remove-button"
disabled={false}
onClick={[Function]}
type="button"
>
<Icon
className="rc-button-icon-svg"
size="medium"
style={Object {}}
svg={null}
type="close"
viewBox={null}
>
<svg
className="rc-icon rc-icon-close rc-button-icon-svg"
height="16px"
style={
Object {
"height": "16px",
"width": "16px",
}
}
viewBox="0 0 8 8"
width="16px"
>
<polygon
fillRule="evenodd"
points="6.1 .5 4 2.6 1.9 .5 .5 1.9 2.6 4 .5 6.1 1.9 7.5 4 5.4 6.1 7.5 7.5 6.1 5.4 4 7.5 1.9"
/>
</svg>
</Icon>
<span
className="rc-button-content"
/>
</button>
</Button>
</div>
</Tag>
<Button
as="button"
className="dg-tag-remove-all-button"
disabled={false}
forwardRefAs="ref"
icon="close"
innerFocus={false}
loading={false}
onClick={[Function]}
onKeyDown={[Function]}
trailingIcon={null}
type="text"
weight="bold"
>
<button
aria-label="Remove all"
className="rc-button rc-button-text rc-button-bold rc-button-icon rc-button-full dg-tag-remove-all-button"
disabled={false}
onClick={[Function]}
onKeyDown={[Function]}
type="button"
>
<Icon
className="rc-button-icon-svg"
size="small"
style={Object {}}
svg={null}
type="close"
viewBox={null}
>
<svg
className="rc-icon rc-icon-close rc-button-icon-svg"
height="12px"
style={
Object {
"height": "12px",
"width": "12px",
}
}
viewBox="0 0 8 8"
width="12px"
>
<polygon
fillRule="evenodd"
points="6.1 .5 4 2.6 1.9 .5 .5 1.9 2.6 4 .5 6.1 1.9 7.5 4 5.4 6.1 7.5 7.5 6.1 5.4 4 7.5 1.9"
/>
</svg>
</Icon>
<span
className="rc-button-content"
>
Remove all
</span>
</button>
</Button>
</div>
</div>
</TagBuilder>
`;
76 changes: 76 additions & 0 deletions packages/data-grid/src/__test__/quickFitler.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react';
import { mount, configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import QuickFilter from '../quickFilter/QuickFilter';

configure({ adapter: new Adapter() });

const filters = [
{
fieldLabel: 'All Operating System',
field: 'All-Operating-System',
options: [
{
value: 'linux',
icon: 'pencil',
label: 'linux',
},
{
value: 'Windows',
icon: 'send',
label: 'Windows',
},
{
value: 'MacOS',
label: 'MacOS',
icon: 'link',
},
],
},
{
fieldLabel: 'Puppet installed',
field: 'Puppet-installed',
options: [
{
value: 'True',
icon: 'pencil',
label: 'True',
},
{
value: 'False',
icon: 'send',
label: 'False',
},
{
value: 'Unknown',
label: 'Unknown',
icon: 'link',
},
],
},
];

const mockfunc = jest.fn();
const wrapper = mount(
<QuickFilter filters={filters} onFilterSelect={mockfunc} />,
);

describe('Snapshot test', () => {
test('Check component matches previous HTML snapshot', () => {
expect(wrapper).toMatchSnapshot();
});
});

describe('Check component', () => {
test('Number of dropdowns rendered ', () => {
expect(wrapper.find('ButtonSelect.dg-quick-filter')).toHaveLength(4);
});

test('onFilterSelect function gets called', () => {
wrapper
.find('li.rc-menu-list-item')
.first()
.simulate('click');
expect(mockfunc).toHaveBeenCalled();
});
});
Loading