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

Updated notebook cypress tests #637

Merged
merged 1 commit into from
Apr 11, 2022
Merged
Changes from all commits
Commits
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
83 changes: 71 additions & 12 deletions dashboards-observability/.cypress/integration/notebooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ import { SAMPLE_PANEL } from '../utils/panel_constants';

import { skipOn } from '@cypress/skip-test';

const moveToEventsHome = () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/event_analytics/`);
cy.wait(delay * 3);
};

const moveToPanelHome = () => {
cy.visit(
`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/operational_panels/`
);
cy.wait(delay * 3);
};

describe('Adding sample data and visualization', () => {
it('Adds sample flights data for visualization paragraph', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/home#/tutorial_directory/sampleData`);
Expand All @@ -27,17 +39,22 @@ describe('Adding sample data and visualization', () => {
});

it('Add sample observability data', () => {
cy.visit(
`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/operational_panels/`
);
cy.get('.euiButton__text').contains('Actions').click();
cy.get('.euiContextMenuItem__text').contains('Add samples').click();
moveToPanelHome();
cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click();
cy.wait(100);
cy.get('.euiContextMenuItem__text').contains('Add samples').trigger('mouseover').click();
cy.wait(100 * 3);
cy.get('.euiModalHeader__title[data-test-subj="confirmModalTitleText"]')
.contains('Add samples')
.should('exist');
cy.get('.euiButton__text').contains('Yes').click();
cy.wait(delay * 5);
cy.get('.euiTableCellContent').contains(SAMPLE_PANEL).should('exist');
cy.wait(100);
cy.get('.euiButton__text').contains('Yes').trigger('mouseover').click();
cy.wait(100 * 5);
cy.route2('POST', '/addSamplePanels').as('addSamples');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to load sample observability data. The data is used to add a sample observability visualization in notebooks.

cy.wait('@addSamples').then(() => {
cy.get('.euiTableCellContent').contains(SAMPLE_PANEL).should('exist');
});
cy.wait(100);
});
});

Expand Down Expand Up @@ -235,7 +252,7 @@ describe('Testing paragraphs', () => {
});

it('Renders input only mode', () => {
cy.get('.euiToggle__input[title="Input only"]').click();
cy.get('.euiButton__text[title="Input only"]').click();
cy.wait(delay);

cy.get('div.markdown-body').should('not.exist');
Expand All @@ -248,7 +265,7 @@ describe('Testing paragraphs', () => {
});

it('Renders output only mode', () => {
cy.get('.euiToggle__input[title="Output only"]').click();
cy.get('.euiButton__text[title="Output only"]').click();
cy.wait(delay);

cy.get('button[aria-label="Open paragraph menu"]').should('not.exist');
Expand Down Expand Up @@ -279,7 +296,9 @@ describe('Testing paragraphs', () => {

cy.get('.euiButton__text').contains('Browse').click();
cy.wait(delay);
cy.get('.euiFieldSearch').focus().type('[Flights] Flight Count and Average Ticket Price{enter}');
cy.get('.euiFieldSearch')
.focus()
.type('[Flights] Flight Count and Average Ticket Price{enter}');
cy.wait(delay);
cy.get('.euiButton__text').contains('Select').click();
cy.wait(delay);
Expand Down Expand Up @@ -444,7 +463,7 @@ describe('Testing paragraphs', () => {

cy.get('.euiButton__text').contains('Create notebook').should('exist');
});

it('Cleans up test notebooks', () => {
cy.get('[data-test-subj="notebook-notebook-actions-button"]').click();
cy.wait(delay);
Expand All @@ -461,3 +480,43 @@ 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(delay);
cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click();
cy.wait(delay);
cy.get('.euiContextMenuItem__text').contains('Delete').trigger('mouseover').click();
cy.wait(delay);
cy.get('button.euiButton--danger').should('be.disabled');
cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', {
delay: 50,
});
cy.get('button.euiButton--danger').should('not.be.disabled');
cy.get('.euiButton__text').contains('Delete').trigger('mouseover').click();
cy.wait(delay);
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(delay);
cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click();
cy.wait(delay);
cy.get('.euiContextMenuItem__text').contains('Delete').trigger('mouseover').click();
cy.wait(delay);
cy.get('button.euiButton--danger').should('be.disabled');
cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', {
delay: 50,
});
cy.get('button.euiButton--danger').should('not.be.disabled');
cy.get('.euiButton__text').contains('Delete').trigger('mouseover').click();

cy.get('.euiTextAlign').contains('No Operational Panels').should('exist');
});
});