[EDR Workflows] fix Osquery test - SavedQueryDropdown flakiness (#170952)

This commit is contained in:
Tomasz Ciecierski 2023-11-10 15:46:38 +01:00 committed by GitHub
parent 2b60d3a6ec
commit 2720e4f42d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 31 additions and 16 deletions

View file

@ -5,10 +5,12 @@
* 2.0.
*/
import { LIVE_QUERY_EDITOR } from '../../screens/live_query';
import {
ADD_PACK_HEADER_BUTTON,
ADD_QUERY_BUTTON,
formFieldInputSelector,
SAVED_QUERY_DROPDOWN_SELECT,
TABLE_ROWS,
} from '../../screens/packs';
import {
@ -178,11 +180,15 @@ describe('ALL - Add Integration', { tags: ['@ess', '@serverless'] }, () => {
navigateTo('app/osquery/packs');
cy.getBySel(ADD_PACK_HEADER_BUTTON).click();
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.get(formFieldInputSelector('name')).type(`${packName}{downArrow}{enter}`);
cy.getBySel('policyIdsComboBox').type(`${policyName} {downArrow}{enter}`);
cy.getBySel(ADD_QUERY_BUTTON).click();
cy.getBySel('savedQuerySelect').click().type('{downArrow}{enter}');
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel(LIVE_QUERY_EDITOR).should('exist');
cy.getBySel(SAVED_QUERY_DROPDOWN_SELECT).click().type('{downArrow}{enter}');
cy.contains(/^Save$/).click();
cy.contains(/^Save pack$/).click();
cy.contains(`Successfully created "${packName}" pack`).click();

View file

@ -71,6 +71,7 @@ describe('Alert Event Details - Cases', { tags: ['@ess', '@serverless'] }, () =>
cy.contains(/^\d+ agen(t|ts) selected/);
cy.contains('Run a set of queries in a pack').click();
cy.get(OSQUERY_FLYOUT_BODY_EDITOR).should('not.exist');
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel('select-live-pack').click().type(`${packName}{downArrow}{enter}`);
submitQuery();
cy.get('[aria-label="Add to Case"]').first().click();

View file

@ -67,22 +67,22 @@ describe('ALL - Live Query', { tags: ['@ess', '@serverless'] }, () => {
"where pos.remote_port !='0' {shift+enter}" +
'limit 1000;';
cy.contains('New live query').click();
cy.get(LIVE_QUERY_EDITOR).invoke('height').and('be.gt', 99).and('be.lt', 110);
cy.get(LIVE_QUERY_EDITOR).click().invoke('val', multilineQuery);
cy.getBySel(LIVE_QUERY_EDITOR).invoke('height').and('be.gt', 99).and('be.lt', 110);
cy.getBySel(LIVE_QUERY_EDITOR).click().invoke('val', multilineQuery);
inputQuery(multilineQuery);
cy.get(LIVE_QUERY_EDITOR).invoke('height').should('be.gt', 220).and('be.lt', 300);
cy.getBySel(LIVE_QUERY_EDITOR).invoke('height').should('be.gt', 220).and('be.lt', 300);
selectAllAgents();
submitQuery();
cy.getBySel('osqueryResultsPanel');
// check if it get's bigger when we add more lines
cy.get(LIVE_QUERY_EDITOR).invoke('height').should('be.gt', 220).and('be.lt', 300);
cy.getBySel(LIVE_QUERY_EDITOR).invoke('height').should('be.gt', 220).and('be.lt', 300);
inputQuery(multilineQuery);
cy.get(LIVE_QUERY_EDITOR).invoke('height').should('be.gt', 350).and('be.lt', 600);
cy.getBySel(LIVE_QUERY_EDITOR).invoke('height').should('be.gt', 350).and('be.lt', 600);
inputQuery('{selectall}{backspace}{selectall}{backspace}');
// not sure if this is how it used to work when I implemented the functionality, but let's leave it like this for now
cy.get(LIVE_QUERY_EDITOR).invoke('height').should('be.gt', 200).and('be.lt', 400);
cy.getBySel(LIVE_QUERY_EDITOR).invoke('height').should('be.gt', 200).and('be.lt', 400);
});
});

View file

@ -67,7 +67,7 @@ describe('ALL - Live Query Packs', { tags: ['@ess', '@serverless'] }, () => {
it('should run live pack', () => {
cy.contains('New live query').click();
cy.contains('Run a set of queries in a pack.').click();
cy.get(LIVE_QUERY_EDITOR).should('not.exist');
cy.getBySel(LIVE_QUERY_EDITOR).should('not.exist');
cy.getBySel('select-live-pack').click().type(`${packName}{downArrow}{enter}`);
cy.contains('This table contains 3 rows.');
cy.contains('system_memory_linux_elastic');

View file

@ -99,7 +99,7 @@ describe('ALL - Live Query run custom and saved', { tags: ['@ess', '@serverless'
navigateTo('/app/osquery');
cy.get('[aria-label="Run query"]').first().should('be.visible').click();
cy.get(LIVE_QUERY_EDITOR).contains('select * from users;');
cy.getBySel(LIVE_QUERY_EDITOR).contains('select * from users;');
});
it('should open query details by clicking the details icon', () => {

View file

@ -33,7 +33,7 @@ import {
interceptPackId,
} from '../../tasks/integrations';
import { DEFAULT_POLICY } from '../../screens/fleet';
import { getIdFormField } from '../../screens/live_query';
import { getIdFormField, LIVE_QUERY_EDITOR } from '../../screens/live_query';
import { loadSavedQuery, cleanupSavedQuery, cleanupPack, loadPack } from '../../tasks/api_fixtures';
import { request } from '../../tasks/common';
import { ServerlessRoleName } from '../../support/roles';
@ -254,6 +254,8 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
cy.getBySel(ADD_QUERY_BUTTON).click();
cy.contains('Attach next query');
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel(LIVE_QUERY_EDITOR).should('exist');
cy.getBySel(SAVED_QUERY_DROPDOWN_SELECT).type(`${savedQueryName}{downArrow}{enter}`);
cy.getBySel('osquery-interval-field').click().clear().type('5');
cy.getBySel(FLYOUT_SAVED_QUERY_SAVE_BUTTON).click();
@ -367,6 +369,8 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
cy.getBySel(ADD_QUERY_BUTTON).click();
cy.contains('Attach next query');
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel(LIVE_QUERY_EDITOR).should('exist');
cy.contains('ID must be unique').should('not.exist');
cy.getBySel(SAVED_QUERY_DROPDOWN_SELECT).type(`${savedQueryName}{downArrow}{enter}`);
cy.getBySel(FLYOUT_SAVED_QUERY_SAVE_BUTTON).click();
@ -671,6 +675,8 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
cy.getBySel(ADD_QUERY_BUTTON).click();
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel(LIVE_QUERY_EDITOR).should('exist');
cy.getBySel(SAVED_QUERY_DROPDOWN_SELECT).type(
`${multipleMappingsSavedQueryName} {downArrow} {enter}`
);

View file

@ -162,7 +162,7 @@ describe('ALL - Packs', { tags: ['@ess', '@serverless'] }, () => {
navigateTo('/app/osquery/live_queries');
cy.contains('New live query').click();
cy.contains('Run a set of queries in a pack.').click();
cy.get(LIVE_QUERY_EDITOR).should('not.exist');
cy.getBySel(LIVE_QUERY_EDITOR).should('not.exist');
cy.getBySel('select-live-pack').click().type('osquery-monitoring{downArrow}{enter}');
selectAllAgents();
submitQuery();

View file

@ -5,6 +5,7 @@
* 2.0.
*/
import { LIVE_QUERY_EDITOR } from '../../screens/live_query';
import {
ADD_QUERY_BUTTON,
customActionEditSavedQuerySelector,
@ -142,7 +143,8 @@ describe('ALL - Saved queries', { tags: ['@ess', '@serverless'] }, () => {
cy.getBySel(ADD_QUERY_BUTTON).click();
cy.contains('Attach next query');
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel(LIVE_QUERY_EDITOR).should('exist');
cy.getBySel(SAVED_QUERY_DROPDOWN_SELECT).click().type('users_elastic{downArrow} {enter}');
inputQuery('where name=1');
cy.getBySel('resultsTypeField').click();

View file

@ -113,7 +113,7 @@ describe(`T1 and T2 analysts`, { tags: ['@ess', '@serverless'] }, () => {
cy.contains('New live query').click();
selectAllAgents();
cy.get(LIVE_QUERY_EDITOR).should('not.exist');
cy.getBySel(LIVE_QUERY_EDITOR).should('not.exist');
submitQuery();
cy.contains('Query is a required field');
});

View file

@ -7,7 +7,7 @@
export const AGENT_FIELD = '[data-test-subj="comboBoxInput"]';
export const ALL_AGENTS_OPTION = '[title="All agents"]';
export const LIVE_QUERY_EDITOR = '.kibanaCodeEditor';
export const LIVE_QUERY_EDITOR = 'kibanaCodeEditor';
export const OSQUERY_FLYOUT_BODY_EDITOR =
'[data-test-subj="flyout-body-osquery"] .kibanaCodeEditor';
export const SUBMIT_BUTTON = '#submit-button';

View file

@ -25,10 +25,10 @@ export const selectAllAgents = () => {
};
export const clearInputQuery = () =>
cy.get(LIVE_QUERY_EDITOR).click().type(`{selectall}{backspace}`);
cy.getBySel(LIVE_QUERY_EDITOR).click().type(`{selectall}{backspace}`);
export const inputQuery = (query: string, options?: { parseSpecialCharSequences: boolean }) =>
cy.get(LIVE_QUERY_EDITOR).type(query, options);
cy.getBySel(LIVE_QUERY_EDITOR).type(query, options);
export const inputQueryInFlyout = (
query: string,