Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sara4994 committed Aug 8, 2023
1 parent a1a5d9c commit 6219edd
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const CustomDashboardListToolbar: React.FC<
onKeyPress={onEnterClicked}
placeholder="Filter by dashboard name"
value={dashboardNameInput}
data-testid="search-input"
/>
</InputGroup>
</ToolbarFilter>
Expand All @@ -146,7 +147,12 @@ const CustomDashboardListToolbar: React.FC<
<ToolbarGroup variant="icon-button-group">
<ToolbarItem>
<Tooltip content={'Refresh'}>
<Button variant="plain" onClick={doRefresh} id="refresh">
<Button
variant="plain"
onClick={doRefresh}
id="refresh"
data-testid="refresh"
>
<SyncIcon />
</Button>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ describe('CustomDashboard list toolbar tests', () => {
});

it('reset click', () => {
const applyFilter = jest.fn();
render(
<CustomDashboardListToolbar
applyFilter={applyFilter}
setFilterDashboardNames={jest.fn()}
filterDashboardNames={['dashboard']}
/>
);
const resetButton = screen.getAllByText('Reset to default')[1];
fireEvent.click(resetButton);
expect(applyFilter).toHaveBeenCalled();
});
it('refresh click', () => {
const applyFilter = jest.fn();
render(
<CustomDashboardListToolbar
Expand All @@ -54,67 +67,44 @@ describe('CustomDashboard list toolbar tests', () => {
filterDashboardNames={[]}
/>
);
screen.debug();
// act(() => {
// wrapper.find('Toolbar').props()['clearAllFilters']();
// });

const refreshButton = screen.getByTestId('refresh');
fireEvent.click(refreshButton);
expect(applyFilter).toHaveBeenCalled();
});

// it('refresh click', () => {
// const applyFilter = jest.fn();
// const wrapper = mount(
// <CustomDashboardListToolbar
// applyFilter={applyFilter}
// setFilterDashboardNames={jest.fn()}
// filterDashboardNames={[]}
// />
// );
// act(() => {
// wrapper.find(Tooltip).find(Button).simulate('click');
// });
// expect(applyFilter).toHaveBeenCalled();
// });
it('enter clicked', () => {
const applyFilter = jest.fn();
const { container } = render(
<CustomDashboardListToolbar
applyFilter={applyFilter}
setFilterDashboardNames={jest.fn()}
filterDashboardNames={[]}
/>
);
const searchInput = screen.getByTestId('search-input');
fireEvent.keyPress(searchInput, { key: 'Enter', code: 13 });

const applyFilterButton = screen.getByTestId('apply-filter');

fireEvent.click(applyFilterButton);

expect(applyFilter).toHaveBeenCalled();
});

it('on delete chip', () => {
const applyFilter = jest.fn();
const { container } = render(
<CustomDashboardListToolbar
applyFilter={applyFilter}
setFilterDashboardNames={jest.fn()}
filterDashboardNames={['dashboard']}
/>
);

// it('enter clicked', () => {
// const applyFilter = jest.fn();
// const wrapper = mount(
// <CustomDashboardListToolbar
// applyFilter={applyFilter}
// setFilterDashboardNames={jest.fn()}
// filterDashboardNames={[]}
// />
// );
// act(() => {
// wrapper
// .find('TextInputBase')
// .props()
// ['onKeyPress']({
// key: 'Enter',
// target: {
// value: 'dashboard'
// }
// } as any);
// });
// wrapper.find('#apply-filter').find('button').simulate('click');
// expect(applyFilter).toHaveBeenCalled();
// });
const closeButton = screen.getByLabelText('close');
fireEvent.click(closeButton);

// it('on delete chip', () => {
// const applyFilter = jest.fn();
// const wrapper = mount(
// <CustomDashboardListToolbar
// applyFilter={applyFilter}
// setFilterDashboardNames={jest.fn()}
// filterDashboardNames={[]}
// />
// );
// act(() => {
// wrapper
// .find(ToolbarFilter)
// .props()
// ['deleteChip']('Custom Dashboard name', 'dashboard');
// });
// expect(applyFilter).toHaveBeenCalled();
// });
expect(applyFilter).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ exports[`CustomDashboard list toolbar tests render toolbar 1`] = `
data-ouia-component-id="OUIA-Generated-TextInputBase-2"
data-ouia-component-type="PF4/TextInput"
data-ouia-safe="true"
data-testid="search-input"
id="customDashboardName"
name="customDashboardName"
placeholder="Filter by dashboard name"
Expand Down Expand Up @@ -101,6 +102,7 @@ exports[`CustomDashboard list toolbar tests render toolbar 1`] = `
data-ouia-component-id="OUIA-Generated-Button-plain-2"
data-ouia-component-type="PF4/Button"
data-ouia-safe="true"
data-testid="refresh"
id="refresh"
type="button"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ HTMLCollection [
data-ouia-component-id="OUIA-Generated-TextInputBase-2"
data-ouia-component-type="PF4/TextInput"
data-ouia-safe="true"
data-testid="search-input"
id="customDashboardName"
name="customDashboardName"
placeholder="Filter by dashboard name"
Expand Down Expand Up @@ -156,6 +157,7 @@ HTMLCollection [
data-ouia-component-id="OUIA-Generated-Button-plain-2"
data-ouia-component-type="PF4/Button"
data-ouia-safe="true"
data-testid="refresh"
id="refresh"
type="button"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exports[`DevUILayout tests Snapshot test with Processing disabled 1`] = `
sidebar={
<PageSidebar
data-ouia-navigation="true"
data-testid="page-sidebar"
isNavOpen={true}
nav={
<DevUINav
Expand All @@ -45,6 +46,7 @@ exports[`DevUILayout tests Snapshot test with Processing disabled 1`] = `
>
<PageSidebar
data-ouia-navigation="true"
data-testid="page-sidebar"
isNavOpen={true}
nav={
<DevUINav
Expand All @@ -57,6 +59,7 @@ exports[`DevUILayout tests Snapshot test with Processing disabled 1`] = `
aria-hidden={false}
className="pf-c-page__sidebar pf-m-expanded"
data-ouia-navigation="true"
data-testid="page-sidebar"
id="page-sidebar"
>
<div
Expand Down Expand Up @@ -223,6 +226,7 @@ exports[`DevUILayout tests Snapshot test with Tracing disabled 1`] = `
sidebar={
<PageSidebar
data-ouia-navigation="true"
data-testid="page-sidebar"
isNavOpen={true}
nav={
<DevUINav
Expand All @@ -240,6 +244,7 @@ exports[`DevUILayout tests Snapshot test with Tracing disabled 1`] = `
>
<PageSidebar
data-ouia-navigation="true"
data-testid="page-sidebar"
isNavOpen={true}
nav={
<DevUINav
Expand All @@ -252,6 +257,7 @@ exports[`DevUILayout tests Snapshot test with Tracing disabled 1`] = `
aria-hidden={false}
className="pf-c-page__sidebar pf-m-expanded"
data-ouia-navigation="true"
data-testid="page-sidebar"
id="page-sidebar"
>
<div
Expand Down Expand Up @@ -628,6 +634,7 @@ exports[`DevUILayout tests Snapshot test with default props 1`] = `
sidebar={
<PageSidebar
data-ouia-navigation="true"
data-testid="page-sidebar"
isNavOpen={true}
nav={
<DevUINav
Expand All @@ -645,6 +652,7 @@ exports[`DevUILayout tests Snapshot test with default props 1`] = `
>
<PageSidebar
data-ouia-navigation="true"
data-testid="page-sidebar"
isNavOpen={true}
nav={
<DevUINav
Expand All @@ -657,6 +665,7 @@ exports[`DevUILayout tests Snapshot test with default props 1`] = `
aria-hidden={false}
className="pf-c-page__sidebar pf-m-expanded"
data-ouia-navigation="true"
data-testid="page-sidebar"
id="page-sidebar"
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ exports[`CustomWorkflowForm Test Custom Workflow Form - loading 2`] = `
>
<div
class="pf-c-action-list"
data-testid="action-list"
>
<div
class="pf-c-action-list__item"
data-testid="action-list-item"
>
<button
aria-disabled="false"
Expand All @@ -138,6 +140,7 @@ exports[`CustomWorkflowForm Test Custom Workflow Form - loading 2`] = `
</div>
<div
class="pf-c-action-list__item"
data-testid="action-list-item"
>
<button
aria-disabled="false"
Expand Down Expand Up @@ -229,9 +232,11 @@ exports[`CustomWorkflowForm Test Custom Workflow Form rendering 1`] = `
>
<div
class="pf-c-action-list"
data-testid="action-list"
>
<div
class="pf-c-action-list__item"
data-testid="action-list-item"
>
<button
aria-disabled="false"
Expand All @@ -246,6 +251,7 @@ exports[`CustomWorkflowForm Test Custom Workflow Form rendering 1`] = `
</div>
<div
class="pf-c-action-list__item"
data-testid="action-list-item"
>
<button
aria-disabled="false"
Expand Down Expand Up @@ -337,9 +343,11 @@ exports[`CustomWorkflowForm Test Custom Workflow Form with reset 1`] = `
>
<div
class="pf-c-action-list"
data-testid="action-list"
>
<div
class="pf-c-action-list__item"
data-testid="action-list-item"
>
<button
aria-disabled="false"
Expand All @@ -354,6 +362,7 @@ exports[`CustomWorkflowForm Test Custom Workflow Form with reset 1`] = `
</div>
<div
class="pf-c-action-list__item"
data-testid="action-list-item"
>
<button
aria-disabled="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ exports[`WorkflowFormEnvelopeView tests Custom Workflow Form 1`] = `
>
<div
class="pf-c-action-list"
data-testid="action-list"
>
<div
class="pf-c-action-list__item"
data-testid="action-list-item"
>
<button
aria-disabled="false"
Expand All @@ -90,6 +92,7 @@ exports[`WorkflowFormEnvelopeView tests Custom Workflow Form 1`] = `
</div>
<div
class="pf-c-action-list__item"
data-testid="action-list-item"
>
<button
aria-disabled="false"
Expand Down

0 comments on commit 6219edd

Please sign in to comment.