Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SecuritySolution] Move manual test cases to Cypress #100730

Merged
merged 43 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
24e01c9
add scenarios 1-3
angorayc May 26, 2021
781fbe3
add tests for toggle full screen
angorayc May 27, 2021
97f4984
add tests for timeline pagination
angorayc May 28, 2021
90b0313
add tests for timeline correlation tab
angorayc May 28, 2021
e0ce263
fix cypress tests
angorayc Jun 1, 2021
2047147
add data-test-subj for timeline tabs content
angorayc Jun 4, 2021
5c42624
Merge branch 'master' of github.com:elastic/kibana into manual-to-cyp…
angorayc Jun 4, 2021
442fb21
fix up
angorayc Jun 4, 2021
e468000
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 7, 2021
8c63178
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 7, 2021
56dc71e
fix flaky tests
angorayc Jun 7, 2021
0db53d3
Merge branch 'manual-to-cypress' of github.com:angorayc/kibana into m…
angorayc Jun 7, 2021
d33c6f6
fix mark as favorite scenario
angorayc Jun 7, 2021
a2b346e
fix flaky test
angorayc Jun 8, 2021
d164c84
fix flaky test
angorayc Jun 9, 2021
8cfdca1
fix flaky test
angorayc Jun 9, 2021
83048f8
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 9, 2021
2c486fa
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 9, 2021
13f77dc
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 14, 2021
e5cbee7
refactors 'can be marked as favourite' test
MadameSheema Jun 14, 2021
1a3dbbd
Merge pull request #3 from MadameSheema/manual-to-cypress-refactor
angorayc Jun 14, 2021
593f6a9
fixes test
MadameSheema Jun 14, 2021
43ea05d
fixes typecheck issue
MadameSheema Jun 14, 2021
128041b
refactors the pipe
MadameSheema Jun 15, 2021
9e22baa
Merge branch 'manual-to-cypress' of https://github.com/angorayc/kiban…
MadameSheema Jun 15, 2021
d393113
little fix
MadameSheema Jun 15, 2021
d450f48
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 15, 2021
14909c6
mark as favourite refactor
MadameSheema Jun 15, 2021
278c21a
Merge branch 'manual-to-cypress' of https://github.com/angorayc/kiban…
MadameSheema Jun 15, 2021
644d5ba
removes code that causes the flakiness
MadameSheema Jun 16, 2021
7bc1a3e
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 16, 2021
b4ccd48
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 16, 2021
c960fb3
apply the fix for 7.13 branch
angorayc Jun 16, 2021
844d74f
fix timeline api call
angorayc Jun 17, 2021
4daf83a
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 17, 2021
94078b1
fix timeline api call
angorayc Jun 17, 2021
5e01268
Merge branch 'manual-to-cypress' of github.com:angorayc/kibana into m…
angorayc Jun 17, 2021
c7515f7
fix timeline api call
angorayc Jun 18, 2021
55f1af8
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 21, 2021
477be5a
fix syntax
angorayc Jun 21, 2021
48f24e5
Merge branch 'manual-to-cypress' of github.com:angorayc/kibana into m…
angorayc Jun 21, 2021
d0054e0
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 21, 2021
7f95cf3
Merge branch 'master' into manual-to-cypress
kibanamachine Jun 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import { createTimeline } from '../../tasks/api_calls/timelines';
import { cleanKibana } from '../../tasks/common';
import { createCase } from '../../tasks/api_calls/cases';

// TODO: enable once attach timeline to cases is re-enabled
describe.skip('attach timeline to case', () => {
describe('attach timeline to case', () => {
context('without cases created', () => {
beforeEach(() => {
cleanKibana();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { OVERVIEW_URL } from '../../urls/navigation';
import overviewFixture from '../../fixtures/overview_search_strategy.json';
import emptyInstance from '../../fixtures/empty_instance.json';
import { cleanKibana } from '../../tasks/common';
import { createTimeline, favoriteTimeline } from '../../tasks/api_calls/timelines';
import { timeline } from '../../objects/timeline';

describe('Overview Page', () => {
before(() => {
Expand Down Expand Up @@ -48,4 +50,21 @@ describe('Overview Page', () => {
cy.get(OVERVIEW_EMPTY_PAGE).should('be.visible');
});
});

describe('Favorite Timelines', () => {
it('should appear on overview page', () => {
angorayc marked this conversation as resolved.
Show resolved Hide resolved
createTimeline(timeline)
.then((response) => response.body.data.persistTimeline.timeline.savedObjectId)
.then((timelineId: string) => {
favoriteTimeline({ timelineId, timelineType: 'default' }).then(() => {
cy.stubSearchStrategyApi(overviewFixture, 'overviewNetwork');
loginAndWaitForPage(OVERVIEW_URL);
cy.get('[data-test-subj="overview-recent-timelines"]').should(
angorayc marked this conversation as resolved.
Show resolved Hide resolved
'contain',
timeline.title
);
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
NOTES_TEXT_AREA,
PIN_EVENT,
TIMELINE_DESCRIPTION,
TIMELINE_FLYOUT_WRAPPER,
TIMELINE_QUERY,
TIMELINE_TITLE,
} from '../../screens/timeline';
Expand All @@ -25,34 +26,38 @@ import {
TIMELINES_NOTES_COUNT,
TIMELINES_FAVORITE,
} from '../../screens/timelines';
import { createTimeline } from '../../tasks/api_calls/timelines';
import { cleanKibana } from '../../tasks/common';

import { loginAndWaitForPage } from '../../tasks/login';
import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login';
import { openTimelineUsingToggle } from '../../tasks/security_main';
import {
addDescriptionToTimeline,
addFilter,
addNameToTimeline,
addNotesToTimeline,
clickingOnCreateTemplateFromTimelineBtn,
closeTimeline,
createNewTimelineTemplate,
expandEventAction,
markAsFavorite,
openTimelineTemplateFromSettings,
populateTimeline,
waitForTimelineChanges,
} from '../../tasks/timeline';
import { openTimeline } from '../../tasks/timelines';
import { openTimeline, waitForTimelinesPanelToBeLoaded } from '../../tasks/timelines';

import { OVERVIEW_URL } from '../../urls/navigation';
import { TIMELINES_URL } from '../../urls/navigation';

describe('Timeline Templates', () => {
beforeEach(() => {
cleanKibana();
loginAndWaitForPageWithoutDateRange(TIMELINES_URL);

cy.intercept('PATCH', '/api/timeline').as('timeline');
});

it('Creates a timeline template', async () => {
loginAndWaitForPage(OVERVIEW_URL);
openTimelineUsingToggle();
createNewTimelineTemplate();
populateTimeline();
Expand Down Expand Up @@ -97,4 +102,22 @@ describe('Timeline Templates', () => {
cy.get(NOTES).should('have.text', timeline.notes);
});
});

it('Create template from timeline', () => {
waitForTimelinesPanelToBeLoaded();

createTimeline(timeline).then(() => {
expandEventAction();
clickingOnCreateTemplateFromTimelineBtn();
cy.wait('@timeline', { timeout: 100000 }).then(({ request }) => {
expect(request.body.timeline).to.haveOwnProperty('templateTimelineId');
expect(request.body.timeline).to.haveOwnProperty('description', timeline.description);
expect(request.body.timeline.kqlQuery.filterQuery.kuery).to.haveOwnProperty(
'expression',
timeline.query
);
cy.get(TIMELINE_FLYOUT_WRAPPER).should('have.css', 'visibility', 'visible');
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,37 @@
import { timeline } from '../../objects/timeline';

import {
FAVORITE_TIMELINE,
LOCKED_ICON,
NOTES_TEXT,
PIN_EVENT,
SERVER_SIDE_EVENT_COUNT,
TIMELINE_FILTER,
TIMELINE_FLYOUT_WRAPPER,
TIMELINE_PANEL,
TIMELINE_TAB_CONTENT_EQL,
} from '../../screens/timeline';
import { createTimelineTemplate } from '../../tasks/api_calls/timelines';

import { cleanKibana } from '../../tasks/common';

import { loginAndWaitForPage } from '../../tasks/login';
import { loginAndWaitForPage, loginAndWaitForPageWithoutDateRange } from '../../tasks/login';
import { openTimelineUsingToggle } from '../../tasks/security_main';
import {
addEqlToTimeline,
addFilter,
addNameAndDescriptionToTimeline,
addNotesToTimeline,
clickingOnCreateTimelineFormTemplateBtn,
closeTimeline,
createNewTimeline,
expandEventAction,
goToQueryTab,
markAsFavorite,
pinFirstEvent,
populateTimeline,
waitForTimelineChanges,
} from '../../tasks/timeline';

import { OVERVIEW_URL } from '../../urls/navigation';
import { OVERVIEW_URL, TIMELINE_TEMPLATES_URL } from '../../urls/navigation';
import { waitForTimelinesPanelToBeLoaded } from '../../tasks/timelines';

describe('Timelines', (): void => {
before(() => {
Expand Down Expand Up @@ -88,10 +93,44 @@ describe('Timelines', (): void => {
cy.get(NOTES_TEXT).should('have.text', timeline.notes);
});

it('can be marked as favorite', () => {
markAsFavorite();
waitForTimelineChanges();
cy.get(FAVORITE_TIMELINE).should('have.text', 'Remove from favorites');
it('should update timeline after adding eql', () => {
cy.intercept('PATCH', '/api/timeline').as('updateTimeline');
const eql = 'any where process.name == "which"';
addEqlToTimeline(eql);

cy.wait('@updateTimeline', { timeout: 10000 }).its('response.statusCode').should('eq', 200);

cy.get(`${TIMELINE_TAB_CONTENT_EQL} ${SERVER_SIDE_EVENT_COUNT}`)
.invoke('text')
.then(parseInt)
.should('be.gt', 0);
});
});
});

describe('Create a timeline from a template', () => {
before(() => {
cleanKibana();
loginAndWaitForPageWithoutDateRange(TIMELINE_TEMPLATES_URL);
waitForTimelinesPanelToBeLoaded();
});

it('Should have the same query and open the timeline modal', () => {
createTimelineTemplate(timeline).then(() => {
expandEventAction();
cy.intercept('/api/timeline').as('timeline');

clickingOnCreateTimelineFormTemplateBtn();
cy.wait('@timeline', { timeout: 100000 }).then(({ request }) => {
if (request.body && request.body.timeline) {
expect(request.body.timeline).to.haveOwnProperty('description', timeline.description);
expect(request.body.timeline.kqlQuery.filterQuery.kuery).to.haveOwnProperty(
'expression',
timeline.query
);
cy.get(TIMELINE_FLYOUT_WRAPPER).should('have.css', 'visibility', 'visible');
}
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ describe('timeline flyout button', () => {

it('the `(+)` button popover menu owns focus', () => {
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').click({ force: true });
cy.get(CREATE_NEW_TIMELINE).should('have.focus');
cy.get('body').type('{esc}');
cy.get(`${CREATE_NEW_TIMELINE}`)
.pipe(($el) => $el.trigger('focus'))
.should('have.focus');
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').type('{esc}');
cy.get(CREATE_NEW_TIMELINE).should('not.be.visible');
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.
*/

import { TIMELINE_HEADER, TIMELINE_TABS } from '../../screens/timeline';
import { cleanKibana } from '../../tasks/common';

import { loginAndWaitForPage } from '../../tasks/login';
import {
openTimelineUsingToggle,
enterFullScreenMode,
exitFullScreenMode,
} from '../../tasks/security_main';
import { populateTimeline } from '../../tasks/timeline';

import { HOSTS_URL } from '../../urls/navigation';

describe('Toggle full screen', () => {
before(() => {
cleanKibana();
loginAndWaitForPage(HOSTS_URL);
openTimelineUsingToggle();
populateTimeline();
});

it('Should hide timeline header and tab list area', () => {
enterFullScreenMode();

angorayc marked this conversation as resolved.
Show resolved Hide resolved
cy.get(TIMELINE_TABS).should('not.exist');
cy.get(TIMELINE_HEADER).should('not.be.visible');
});

it('Should show timeline header and tab list area', () => {
exitFullScreenMode();
cy.get(TIMELINE_TABS).should('exist');
cy.get(TIMELINE_HEADER).should('be.visible');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

import { timelineNonValidQuery } from '../../objects/timeline';

import { NOTES_TEXT, NOTES_TEXT_AREA } from '../../screens/timeline';
import {
NOTES_AUTHOR,
NOTES_CODE_BLOCK,
NOTES_LINK,
NOTES_TEXT,
NOTES_TEXT_AREA,
} from '../../screens/timeline';
import { createTimeline } from '../../tasks/api_calls/timelines';

import { cleanKibana } from '../../tasks/common';
Expand All @@ -16,15 +22,19 @@ import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login';
import {
addNotesToTimeline,
closeTimeline,
goToNotesTab,
openTimelineById,
refreshTimelinesUntilTimeLinePresent,
} from '../../tasks/timeline';
import { waitForTimelinesPanelToBeLoaded } from '../../tasks/timelines';

import { TIMELINES_URL } from '../../urls/navigation';

const text = 'elastic';
const link = 'https://www.elastic.co/';

describe('Timeline notes tab', () => {
before(() => {
beforeEach(() => {
cleanKibana();
loginAndWaitForPageWithoutDateRange(TIMELINES_URL);
waitForTimelinesPanelToBeLoaded();
Expand All @@ -37,19 +47,62 @@ describe('Timeline notes tab', () => {
// request responses and indeterminism since on clicks to activates URL's.
.then(() => cy.wait(1000))
.then(() => openTimelineById(timelineId))
.then(() => addNotesToTimeline(timelineNonValidQuery.notes))
.then(() => goToNotesTab())
);
});

after(() => {
closeTimeline();
});
it('should render mockdown', () => {
cy.intercept('/api/note').as(`updateNote`);
addNotesToTimeline(timelineNonValidQuery.notes);
cy.wait('@updateNote').its('response.statusCode').should('eq', 200);
cy.get(NOTES_TEXT_AREA).should('exist');
});

it('should contain notes', () => {
cy.get(NOTES_TEXT).should('have.text', timelineNonValidQuery.notes);
cy.intercept('/api/note').as(`updateNote`);
addNotesToTimeline(timelineNonValidQuery.notes);
cy.wait('@updateNote').its('response.statusCode').should('eq', 200);
cy.get(NOTES_TEXT).first().should('have.text', timelineNonValidQuery.notes);
});

it('should render mockdown', () => {
cy.get(NOTES_TEXT_AREA).should('exist');
it('should be able to render font in bold', () => {
cy.intercept('/api/note').as(`updateNote`);
addNotesToTimeline(`**bold**`);
cy.wait('@updateNote').its('response.statusCode').should('eq', 200);
cy.get(`${NOTES_TEXT} strong`).last().should('have.text', `bold`);
});

it('should be able to render font in italics', () => {
cy.intercept('/api/note').as(`updateNote`);
addNotesToTimeline(`_italics_`);
cy.wait('@updateNote').its('response.statusCode').should('eq', 200);
cy.get(`${NOTES_TEXT} em`).last().should('have.text', `italics`);
});

it('should be able to render code blocks', () => {
cy.intercept('/api/note').as(`updateNote`);
addNotesToTimeline(`\`code\``);
cy.wait('@updateNote').its('response.statusCode').should('eq', 200);
cy.get(NOTES_CODE_BLOCK).should('exist');
});

it('should render the right author', () => {
cy.intercept('/api/note').as(`updateNote`);
addNotesToTimeline(timelineNonValidQuery.notes);
cy.wait('@updateNote').its('response.statusCode').should('eq', 200);
cy.get(NOTES_AUTHOR).first().should('have.text', text);
});

it('should be able to render a link', () => {
cy.intercept('/api/note').as(`updateNote`);
cy.intercept(link).as(`link`);
addNotesToTimeline(`[${text}](${link})`);
cy.wait('@updateNote').its('response.statusCode').should('eq', 200);
cy.get(NOTES_LINK).last().should('have.text', `${text}(opens in a new tab or window)`);
cy.get(NOTES_LINK).last().click();
cy.wait('@link').its('response.statusCode').should('eq', 200);
});
});
Loading