mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Reset checkedQueryIDs after queries are deleted (#1125)
This commit is contained in:
parent
cdc3d1bf3a
commit
9468fb3908
2 changed files with 40 additions and 2 deletions
|
|
@ -65,7 +65,7 @@ export class ManageQueriesPage extends Component {
|
|||
.then(() => {
|
||||
dispatch(renderFlash('success', 'Queries successfully deleted.'));
|
||||
|
||||
this.setState({ showModal: false });
|
||||
this.setState({ checkedQueryIDs: [], showModal: false });
|
||||
|
||||
return false;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React from 'react';
|
||||
import expect from 'expect';
|
||||
import { find } from 'lodash';
|
||||
import { find, noop } from 'lodash';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import ConnectedManageQueriesPage, { ManageQueriesPage } from 'pages/queries/ManageQueriesPage/ManageQueriesPage';
|
||||
|
|
@ -54,6 +54,44 @@ describe('ManageQueriesPage - component', () => {
|
|||
|
||||
expect(page.find('QueryDetailsSidePanel').length).toEqual(1);
|
||||
});
|
||||
|
||||
it('resets checkedQueryIDs after successfully deleting checked queries', (done) => {
|
||||
const fakeEvt = { preventDefault: noop };
|
||||
const props = {
|
||||
dispatch: () => Promise.resolve(),
|
||||
loadingQueries: false,
|
||||
queries: [queryStub],
|
||||
};
|
||||
const page = mount(<ManageQueriesPage {...props} />);
|
||||
|
||||
page.setState({ checkedQueryIDs: [queryStub.id], showModal: true });
|
||||
page.node.onDeleteQueries(fakeEvt)
|
||||
.then(() => {
|
||||
expect(page.state('showModal')).toEqual(false);
|
||||
expect(page.state('checkedQueryIDs')).toEqual([]);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('does not reset checkedQueryIDs if deleting a checked query is unsuccessful', (done) => {
|
||||
const fakeEvt = { preventDefault: noop };
|
||||
const props = {
|
||||
dispatch: () => Promise.reject(),
|
||||
loadingQueries: false,
|
||||
queries: [queryStub],
|
||||
};
|
||||
const page = mount(<ManageQueriesPage {...props} />);
|
||||
|
||||
page.setState({ checkedQueryIDs: [queryStub.id], showModal: true });
|
||||
page.node.onDeleteQueries(fakeEvt)
|
||||
.then(() => {
|
||||
expect(page.state('showModal')).toEqual(false);
|
||||
expect(page.state('checkedQueryIDs')).toEqual([queryStub.id]);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
});
|
||||
|
||||
it('filters the queries list', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue