Skip to content

Commit

Permalink
[Osquery] Fix select 3 platforms. (#131727)
Browse files Browse the repository at this point in the history
Fix select all 3 platforms issue
  • Loading branch information
tomsonpl authored May 9, 2022
1 parent 4170673 commit 9e05c08
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"id": "Saved-Query-Id",
"interval": "3600",
"query": "select * from uptime;",
"platform": "linux,darwin",
"updated_at": "2021-12-21T08:54:38.648Z",
"updated_by": "elastic"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { login } from '../../tasks/login';
import { ArchiverMethod, runKbnArchiverScript } from '../../tasks/archiver';
import { ROLES } from '../../test';

describe('ALL - Delete ECS Mappings', () => {
describe('ALL - Edit saved query', () => {
const SAVED_QUERY_ID = 'Saved-Query-Id';

before(() => {
Expand All @@ -25,7 +25,7 @@ describe('ALL - Delete ECS Mappings', () => {
runKbnArchiverScript(ArchiverMethod.UNLOAD, 'saved_query');
});

it('to click the edit button and edit pack', () => {
it('by changing ecs mappings and platforms', () => {
cy.react('CustomItemAction', {
props: { index: 1, item: { attributes: { id: SAVED_QUERY_ID } } },
}).click();
Expand All @@ -35,13 +35,61 @@ describe('ALL - Delete ECS Mappings', () => {
.parents('[data-test-subj="ECSMappingEditorForm"]')
.react('EuiButtonIcon', { props: { iconType: 'trash' } })
.click();

cy.react('PlatformCheckBoxGroupField').within(() => {
cy.react('EuiCheckbox', {
props: {
id: 'linux',
checked: true,
},
}).should('exist');
cy.react('EuiCheckbox', {
props: {
id: 'darwin',
checked: true,
},
}).should('exist');

cy.react('EuiCheckbox', {
props: {
id: 'windows',
checked: false,
},
}).should('exist');
});

cy.get('#windows').check({ force: true });

cy.react('EuiButton').contains('Update query').click();

cy.wait(5000);

cy.react('CustomItemAction', {
props: { index: 1, item: { attributes: { id: SAVED_QUERY_ID } } },
}).click();
cy.contains('Custom key/value pairs').should('not.exist');
cy.contains('Hours of uptime').should('not.exist');

cy.react('PlatformCheckBoxGroupField').within(() => {
cy.react('EuiCheckbox', {
props: {
id: 'linux',
checked: true,
},
}).should('exist');
cy.react('EuiCheckbox', {
props: {
id: 'darwin',
checked: true,
},
}).should('exist');

cy.react('EuiCheckbox', {
props: {
id: 'windows',
checked: true,
},
}).should('exist');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ export const useSavedQueryForm = ({ defaultValue, handleSubmit }: UseSavedQueryF
defaultValue,
serializer: (payload) =>
produce(payload, (draft) => {
// @ts-expect-error update types
if (draft.platform?.split(',').length === 3) {
// if all platforms are checked then use undefined
// @ts-expect-error update types
delete draft.platform;
}

if (isArray(draft.version)) {
if (!draft.version.length) {
// @ts-expect-error update types
Expand Down

0 comments on commit 9e05c08

Please sign in to comment.