completes unmapped field test (#99227)

This commit is contained in:
Gloria Hornero 2021-05-05 16:58:58 +02:00 committed by GitHub
parent aab29cdbb0
commit 0d7a5826a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 5 deletions

View file

@ -5,14 +5,14 @@
* 2.0.
*/
import { JSON_LINES } from '../../screens/alerts_details';
import { CELL_TEXT, JSON_LINES, TABLE_ROWS } from '../../screens/alerts_details';
import {
expandFirstAlert,
waitForAlertsIndexToBeCreated,
waitForAlertsPanelToBeLoaded,
} from '../../tasks/alerts';
import { openJsonView, scrollJsonViewToBottom } from '../../tasks/alerts_details';
import { openJsonView, openTable, scrollJsonViewToBottom } from '../../tasks/alerts_details';
import { createCustomRuleActivated } from '../../tasks/api_calls/rules';
import { cleanKibana } from '../../tasks/common';
import { esArchiverLoad } from '../../tasks/es_archiver';
@ -30,12 +30,11 @@ describe('Alert details with unmapped fields', () => {
waitForAlertsPanelToBeLoaded();
waitForAlertsIndexToBeCreated();
createCustomRuleActivated(unmappedRule);
});
beforeEach(() => {
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL);
waitForAlertsPanelToBeLoaded();
expandFirstAlert();
});
it('Displays the unmapped field on the JSON view', () => {
const expectedUnmappedField = { line: 2, text: ' "unmapped": "This is the unmapped field"' };
@ -49,4 +48,21 @@ describe('Alert details with unmapped fields', () => {
.should('have.text', expectedUnmappedField.text);
});
});
it('Displays the unmapped field on the table', () => {
const expectedUnmmappedField = {
row: 55,
field: 'unmapped',
text: 'This is the unmapped field',
};
openTable();
cy.get(TABLE_ROWS)
.eq(expectedUnmmappedField.row)
.within(() => {
cy.get(CELL_TEXT).eq(0).should('have.text', expectedUnmmappedField.field);
cy.get(CELL_TEXT).eq(1).should('have.text', expectedUnmmappedField.text);
});
});
});

View file

@ -5,8 +5,14 @@
* 2.0.
*/
export const CELL_TEXT = '.euiText';
export const JSON_CONTENT = '[data-test-subj="jsonView"]';
export const JSON_LINES = '.ace_line';
export const JSON_VIEW_TAB = '[data-test-subj="jsonViewTab"]';
export const TABLE_TAB = '[data-test-subj="tableTab"]';
export const TABLE_ROWS = '.euiTableRow';

View file

@ -5,12 +5,16 @@
* 2.0.
*/
import { JSON_CONTENT, JSON_VIEW_TAB } from '../screens/alerts_details';
import { JSON_CONTENT, JSON_VIEW_TAB, TABLE_TAB } from '../screens/alerts_details';
export const openJsonView = () => {
cy.get(JSON_VIEW_TAB).click();
};
export const openTable = () => {
cy.get(TABLE_TAB).click();
};
export const scrollJsonViewToBottom = () => {
cy.get(JSON_CONTENT).click({ force: true });
cy.get(JSON_CONTENT).type('{pagedown}{pagedown}{pagedown}');

View file

@ -146,6 +146,7 @@ const EventDetailsComponent: React.FC<Props> = ({
const tableTab = useMemo(
() => ({
id: EventsViewType.tableView,
'data-test-subj': 'tableTab',
name: i18n.TABLE,
content: (
<>