diff --git a/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/CustomDashboardListToolbar.tsx b/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/CustomDashboardListToolbar.tsx index 38c9c6acdb..bb2cf48c9f 100755 --- a/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/CustomDashboardListToolbar.tsx +++ b/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/CustomDashboardListToolbar.tsx @@ -121,6 +121,7 @@ const CustomDashboardListToolbar: React.FC< onKeyPress={onEnterClicked} placeholder="Filter by dashboard name" value={dashboardNameInput} + data-testid="search-input" /> @@ -146,7 +147,12 @@ const CustomDashboardListToolbar: React.FC< - diff --git a/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/tests/CustomDashboardListToolbar.test.tsx b/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/tests/CustomDashboardListToolbar.test.tsx index 6af988bdf8..f89d9361f4 100755 --- a/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/tests/CustomDashboardListToolbar.test.tsx +++ b/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/tests/CustomDashboardListToolbar.test.tsx @@ -46,6 +46,19 @@ describe('CustomDashboard list toolbar tests', () => { }); it('reset click', () => { + const applyFilter = jest.fn(); + render( + + ); + const resetButton = screen.getAllByText('Reset to default')[1]; + fireEvent.click(resetButton); + expect(applyFilter).toHaveBeenCalled(); + }); + it('refresh click', () => { const applyFilter = jest.fn(); render( { 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( - // - // ); - // act(() => { - // wrapper.find(Tooltip).find(Button).simulate('click'); - // }); - // expect(applyFilter).toHaveBeenCalled(); - // }); + it('enter clicked', () => { + const applyFilter = jest.fn(); + const { container } = render( + + ); + 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( + + ); - // it('enter clicked', () => { - // const applyFilter = jest.fn(); - // const wrapper = mount( - // - // ); - // 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( - // - // ); - // act(() => { - // wrapper - // .find(ToolbarFilter) - // .props() - // ['deleteChip']('Custom Dashboard name', 'dashboard'); - // }); - // expect(applyFilter).toHaveBeenCalled(); - // }); + expect(applyFilter).toHaveBeenCalled(); + }); }); diff --git a/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/tests/__snapshots__/CustomDashboardListToolbar.test.tsx.snap b/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/tests/__snapshots__/CustomDashboardListToolbar.test.tsx.snap index 190a9d7dd4..36ede83f27 100644 --- a/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/tests/__snapshots__/CustomDashboardListToolbar.test.tsx.snap +++ b/ui-packages/packages/custom-dashboard-list/src/envelope/components/CustomDashboardListToolbar/tests/__snapshots__/CustomDashboardListToolbar.test.tsx.snap @@ -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" @@ -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" > diff --git a/ui-packages/packages/custom-dashboard-list/src/envelope/tests/__snapshots__/CustomDashboardListEnvelopeView.test.tsx.snap b/ui-packages/packages/custom-dashboard-list/src/envelope/tests/__snapshots__/CustomDashboardListEnvelopeView.test.tsx.snap index 39dbdea7a2..3bcffbb1d0 100644 --- a/ui-packages/packages/custom-dashboard-list/src/envelope/tests/__snapshots__/CustomDashboardListEnvelopeView.test.tsx.snap +++ b/ui-packages/packages/custom-dashboard-list/src/envelope/tests/__snapshots__/CustomDashboardListEnvelopeView.test.tsx.snap @@ -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" @@ -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" > diff --git a/ui-packages/packages/runtime-tools-dev-ui-webapp/src/components/DevUI/DevUILayout/tests/__snapshots__/DevUILayout.test.tsx.snap b/ui-packages/packages/runtime-tools-dev-ui-webapp/src/components/DevUI/DevUILayout/tests/__snapshots__/DevUILayout.test.tsx.snap index 4dd125da19..defa4d53c9 100644 --- a/ui-packages/packages/runtime-tools-dev-ui-webapp/src/components/DevUI/DevUILayout/tests/__snapshots__/DevUILayout.test.tsx.snap +++ b/ui-packages/packages/runtime-tools-dev-ui-webapp/src/components/DevUI/DevUILayout/tests/__snapshots__/DevUILayout.test.tsx.snap @@ -28,6 +28,7 @@ exports[`DevUILayout tests Snapshot test with Processing disabled 1`] = ` sidebar={