Skip to content

Commit

Permalink
Fix observability event analytics and notebook failing tests (#949)
Browse files Browse the repository at this point in the history
* remove object saving tests
* fix observability tests failing issue

Signed-off-by: Eric <[email protected]>
  • Loading branch information
mengweieric authored Nov 6, 2023
1 parent 668a8b5 commit 3b7c9ad
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@
*/

/// <reference types="cypress" />
import {
delayTime,
TEST_QUERIES,
SAVE_QUERY1,
SAVE_QUERY2,
querySearch,
landOnEventHome,
landOnEventExplorer,
supressResizeObserverIssue,
clearText,
} from '../../../utils/constants';
import { delayTime, landOnEventHome } from '../../../utils/constants';

describe('Click actions', () => {
beforeEach(() => {
Expand All @@ -30,56 +20,6 @@ describe('Click actions', () => {
});
});

describe('Saves a query on explorer page', () => {
it('Saves a query on event tab of explorer page', () => {
landOnEventExplorer();
clearText('searchAutocompleteTextArea');
querySearch(TEST_QUERIES[0].query, TEST_QUERIES[0].dateRangeDOM);
cy.wait(delayTime);
cy.get('.tab-title').contains('Events').click();
cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').click();
cy.wait(delayTime);
cy.get('[data-test-subj="eventExplorer__querySaveName"]').type(SAVE_QUERY1);
cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').click();
cy.wait(delayTime * 2);

cy.get('.euiToastHeader__title').contains('successfully').should('exist');

landOnEventHome();

cy.get('[data-test-subj="eventHome__savedQueryTableName"]')
.first()
.contains(SAVE_QUERY1);
});

it('Saves a visualization on visualization tab of explorer page', () => {
landOnEventExplorer();
clearText('searchAutocompleteTextArea');
querySearch(TEST_QUERIES[1].query, TEST_QUERIES[1].dateRangeDOM);
cy.wait(delayTime);
supressResizeObserverIssue();
cy.get('button[id="main-content-vis"]').contains('Visualizations').click();
cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').click();
cy.wait(delayTime * 2);
cy.get(
'[data-test-subj="eventExplorer__querySaveComboBox"] [data-test-subj="comboBoxToggleListButton"]'
).click();
cy.get('[data-test-subj="eventExplorer__querySaveName"]')
.focus()
.type(SAVE_QUERY2, { force: true });
cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').click();
cy.wait(delayTime * 2);

cy.get('.euiToastHeader__title').contains('successfully').should('exist');

landOnEventHome();

cy.get('[data-test-subj="eventHome__savedQueryTableName"]')
.first()
.contains(SAVE_QUERY2);
});
});

describe('Delete saved objects', () => {
it('Delete visualizations/queries from event analytics', () => {
landOnEventHome();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@
import {
delayTime,
TEST_NOTEBOOK,
MARKDOWN_TEXT,
SAMPLE_URL,
SQL_QUERY_TEXT,
PPL_QUERY_TEXT,
BASE_PATH,
} from '../../../utils/constants';

const moveToEventsHome = () => {
cy.visit(`${BASE_PATH}/app/observability-logs#/`);
cy.wait(delayTime * 3);
};

const moveToPanelHome = () => {
cy.visit(`${BASE_PATH}/app/observability-dashboards#/`);
cy.wait(delayTime * 3);
};
const moveToTestNotebook = () => {
cy.visit(`${BASE_PATH}/app/observability-notebooks#/`, {
timeout: delayTime * 3,
Expand All @@ -25,11 +35,123 @@ const moveToTestNotebook = () => {
.click();
};

describe('Adding sample visualization', () => {
it('Add sample observability data', () => {
moveToEventsHome();
cy.get('button[data-test-subj="eventHomeAction"]')
.trigger('mouseover')
.click();
cy.wait(100);
cy.get('button[data-test-subj="eventHomeAction__addSamples"]')
.trigger('mouseover')
.click();
cy.wait(100 * 3);
cy.get('.euiModalHeader__title[data-test-subj="confirmModalTitleText"]')
.contains('Add samples')
.should('exist');
cy.wait(100);

cy.get('button[data-test-subj="confirmModalConfirmButton"]')
.trigger('mouseover')
.click();
cy.wait(100 * 5);
cy.get('.euiToastHeader__title', { timeout: delayTime * 3 }).should(
'contain',
'successfully'
);
cy.wait(100);
});
});

describe('Testing notebooks table', () => {
beforeEach(() => {
cy.visit(`${BASE_PATH}/app/observability-notebooks#/`);
});

it('Creates a notebook and redirects to the notebook', () => {
cy.get('.euiButton__text').contains('Create notebook').click();
cy.wait(delayTime);
cy.get('input.euiFieldText').type(TEST_NOTEBOOK);
cy.get('.euiButton__text')
.contains(/^Create$/)
.click();
cy.wait(delayTime);

cy.contains(TEST_NOTEBOOK).should('exist');
});

it('Duplicates and renames a notebook', () => {
cy.get('.euiCheckbox__input[title="Select this row"]').eq(0).click();
cy.wait(delayTime);
cy.get('.euiButton__text').contains('Actions').click();
cy.wait(delayTime);
cy.get('.euiContextMenuItem__text').contains('Duplicate').click();
cy.wait(delayTime);
cy.get('.euiButton__text').contains('Duplicate').click();
cy.wait(delayTime);

cy.get('.euiCheckbox__input[title="Select this row"]').eq(1).click();
cy.wait(delayTime);
cy.get('.euiCheckbox__input[title="Select this row"]').eq(0).click();
cy.wait(delayTime);
cy.get('.euiButton__text').contains('Actions').click();
cy.wait(delayTime);
cy.get('.euiContextMenuItem__text').contains('Rename').click();
cy.wait(delayTime);
cy.get('input.euiFieldText').type(' (rename)');
cy.get('.euiButton__text').contains('Rename').click();
cy.wait(delayTime);
});

it('Deletes notebooks', () => {
cy.get('.euiCheckbox__input[data-test-subj="checkboxSelectAll"]').click();
cy.wait(delayTime);
cy.get('.euiButton__text').contains('Actions').click();
cy.wait(delayTime);
cy.get('.euiContextMenuItem__text').contains('Delete').click();
cy.wait(delayTime);

cy.get('button.euiButton--danger').should('be.disabled');

cy.get('input.euiFieldText[placeholder="delete"]').type('delete');
cy.get('button.euiButton--danger').should('not.be.disabled');
cy.get('.euiButton__text').contains('Delete').click();

cy.get('.euiTextAlign').contains('No notebooks').should('exist');

// keep a notebook for testing
cy.get('.euiButton__text').contains('Create notebook').click();
cy.wait(delayTime);
cy.get('input.euiFieldText').type(TEST_NOTEBOOK);
cy.get('.euiButton__text')
.contains(/^Create$/)
.click();
cy.wait(delayTime * 2);
});
});

describe('Testing paragraphs', () => {
beforeEach(() => {
moveToTestNotebook();
});

it('Goes into a notebook and creates paragraphs', () => {
cy.get('.euiButton__text').contains('Add').click();
cy.wait(delayTime);

cy.get('.euiTextArea').should('exist');

cy.get('.euiButton__text').contains('Run').click();
cy.wait(delayTime);
cy.get('.euiTextColor').contains('Input is required.').should('exist');
cy.get('.euiTextArea').clear();
cy.get('.euiTextArea').type(MARKDOWN_TEXT);
cy.wait(delayTime);

cy.get('.euiButton__text').contains('Run').click();
cy.wait(delayTime);
});

it('Renders markdown', () => {
cy.get('.euiTextArea').should('not.exist');
cy.get(`a[href="${SAMPLE_URL}"]`).should('exist');
Expand Down Expand Up @@ -160,3 +282,58 @@ describe('Testing paragraphs', () => {
cy.get('.euiText').contains('No notebooks').should('exist');
});
});

describe('clean up all test data', () => {
it('Delete visualizations from event analytics', () => {
moveToEventsHome();
cy.get('[data-test-subj="tablePaginationPopoverButton"]')
.trigger('mouseover')
.click();
cy.get('.euiContextMenuItem__text')
.contains('50 rows')
.trigger('mouseover')
.click();
cy.get('.euiCheckbox__input[data-test-subj="checkboxSelectAll"]')
.trigger('mouseover')
.click();
cy.wait(delayTime);
cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click();
cy.wait(delayTime);
cy.get('.euiContextMenuItem__text')
.contains('Delete')
.trigger('mouseover')
.click();
cy.wait(delayTime);
cy.get('button.euiButton--danger').should('be.disabled');
cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', {
delayTime: 50,
});
cy.get('button.euiButton--danger').should('not.be.disabled');
cy.get('.euiButton__text').contains('Delete').trigger('mouseover').click();
cy.wait(delayTime);
cy.get('.euiTextAlign')
.contains('No Queries or Visualizations')
.should('exist');
});

it('Deletes test panel', () => {
moveToPanelHome();
cy.get('.euiCheckbox__input[data-test-subj="checkboxSelectAll"]')
.trigger('mouseover')
.click();
cy.wait(delayTime);
cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click();
cy.wait(delayTime);
cy.get('.euiContextMenuItem__text')
.contains('Delete')
.trigger('mouseover')
.click();
cy.wait(delayTime);
cy.get('button.euiButton--danger').should('be.disabled');
cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', {
delayTime: 50,
});
cy.get('button.euiButton--danger').should('not.be.disabled');
cy.get('.euiButton__text').contains('Delete').trigger('mouseover').click();
});
});

0 comments on commit 3b7c9ad

Please sign in to comment.