Skip to content

Commit

Permalink
cypress review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
logeekal committed Feb 21, 2023
1 parent fd288eb commit ad000e9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ import { waitForAlertsToPopulate } from '../../tasks/create_new_rule';
import { createField } from '../../tasks/create_runtime_field';
import { openAlertsFieldBrowser } from '../../tasks/alerts';
import { deleteRuntimeField } from '../../tasks/sourcerer';
import { GET_DATA_GRID_HEADER } from '../../screens/common/data_grid';
import { GET_TIMELINE_HEADER } from '../../screens/timeline';

const alertRunTimeField = 'field.name.alert.page';
const timelineRuntimeField = 'field.name.timeline';

describe('Create DataView runtime field', () => {
before(() => {
login();
});

before(() => {
deleteRuntimeField('security-solution-default', alertRunTimeField);
deleteRuntimeField('security-solution-default', timelineRuntimeField);
login();
});

it('adds field to alert table', () => {
Expand All @@ -39,9 +38,8 @@ describe('Create DataView runtime field', () => {
refreshPage();
waitForAlertsToPopulate();
openAlertsFieldBrowser();

createField(alertRunTimeField);
cy.get(`[data-test-subj="dataGridHeaderCell-${alertRunTimeField}"]`).should('exist');
cy.get(GET_DATA_GRID_HEADER(alertRunTimeField)).should('exist');
});

it('adds field to timeline', () => {
Expand All @@ -51,8 +49,6 @@ describe('Create DataView runtime field', () => {
openTimelineFieldsBrowser();

createField(timelineRuntimeField);
cy.get(
`[data-test-subj="timeline"] [data-test-subj="header-text-${timelineRuntimeField}"]`
).should('exist');
cy.get(GET_TIMELINE_HEADER(timelineRuntimeField)).should('exist');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export const GET_DATA_GRID_HEADER = (fieldName: string) => {
return `[data-test-subj="dataGridHeaderCell-${fieldName}"]`;
};
4 changes: 4 additions & 0 deletions x-pack/plugins/security_solution/cypress/screens/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,7 @@ export const HOVER_ACTIONS = {
COPY: '[data-test-subj="clipboard"]',
SHOW_TOP: 'show-top-field',
};

export const GET_TIMELINE_HEADER = (fieldName: string) => {
return `[data-test-subj="timeline"] [data-test-subj="header-text-${fieldName}"]`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ import { ruleFields } from '../data/detection_engine';
import { BACK_TO_RULES_TABLE } from '../screens/rule_details';
import { waitForAlerts } from './alerts';
import { refreshPage } from './security_header';
import { EMPTY_ALERT_TABLE } from '../screens/alerts';

export const createAndEnableRule = () => {
cy.get(CREATE_AND_ENABLE_BTN).click({ force: true });
Expand Down Expand Up @@ -675,7 +676,7 @@ export const waitForAlertsToPopulate = async (alertCountThreshold = 1) => {
cy.log('Waiting for alerts to appear');
refreshPage();
return cy.root().then(($el) => {
const emptyTableState = $el.find('[data-test-subj="alertsStateTableEmptyState"]');
const emptyTableState = $el.find(EMPTY_ALERT_TABLE);
if (emptyTableState.length > 0) {
cy.log('Table is empty', emptyTableState.length);
return false;
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/security_solution/cypress/tasks/timelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import { LOADING_INDICATOR } from '../screens/security_header';
import {
TIMELINE_CHECKBOX,
BULK_ACTIONS,
Expand Down Expand Up @@ -47,6 +46,5 @@ export const openTimeline = (id?: string) => {
};

export const waitForTimelinesPanelToBeLoaded = () => {
cy.get(LOADING_INDICATOR).should('not.exist');
cy.get(TIMELINES_TABLE).should('exist');
};

0 comments on commit ad000e9

Please sign in to comment.