Skip to content

Commit

Permalink
Cypress automation for Notebooks application (#809)
Browse files Browse the repository at this point in the history
* Added test cases for Notebooks application

Signed-off-by: Pratibha Pandey <pratibha_pandey@persistent.com>

* Added test cases for empty state of Notebooks table

Signed-off-by: Pratibha Pandey <pratibha_pandey@persistent.com>
  • Loading branch information
pratibhapandey16 authored Jun 16, 2022
1 parent 1c09555 commit ccee0d3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
34 changes: 34 additions & 0 deletions dashboards-observability/.cypress/integration/2_notebooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
SAMPLE_URL,
SQL_QUERY_TEXT,
PPL_QUERY_TEXT,
NOTEBOOK_TEXT,
OPENSEARCH_URL,
} from '../utils/constants';

import { SAMPLE_PANEL } from '../utils/panel_constants';
Expand Down Expand Up @@ -63,6 +65,13 @@ describe('Testing notebooks table', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/notebooks`);
});

it('Notebooks table empty state', () => {
cy.get('#notebookArea').contains('Notebooks (0)').should('exist');
cy.get('.euiTextAlign.euiTextAlign--center').contains('No notebooks');
cy.get('.euiButton__text').eq(2).contains('Create notebook');
cy.get('.euiButton__text').eq(3).contains('Add samples');
});

it('Displays error toast for invalid notebook name', () => {
cy.get('.euiButton__text').contains('Create notebook').click();
cy.wait(delay);
Expand Down Expand Up @@ -125,6 +134,21 @@ describe('Testing notebooks table', () => {
.should('exist');
});

it('Notebooks table columns headers and pagination', () => {
cy.get('.euiTitle.euiTitle--small').contains('Notebooks').should('exist');
cy.get('.euiTableCellContent__text[title="Name"]').should('exist');
cy.get('.euiTableCellContent__text[title="Last updated"]').should('exist');
cy.get('.euiTableCellContent__text[title="Created"]').should('exist');
cy.get('[data-test-subj="tablePaginationPopoverButton"]').should('exist');
});

it('"Learn more" link under Notebooks header', () => {
cy.get('.euiTitle.euiTitle--small').contains('Notebooks');
cy.get('.euiTextColor.euiTextColor--subdued').contains(NOTEBOOK_TEXT);
cy.get('a.euiLink.euiLink--primary').contains('Learn more').click();
cy.get(`a[href="${OPENSEARCH_URL}"]`).should('exist');
});

it('Deletes notebooks', () => {
cy.get('.euiCheckbox__input[data-test-subj="checkboxSelectAll"]').click();
cy.wait(delay);
Expand Down Expand Up @@ -231,6 +255,16 @@ describe('Testing paragraphs', () => {
cy.get('.euiTitle').contains('Event analytics').should('exist');
});

it('Paragraph actions layout', () => {
cy.get('button[data-test-subj="notebook-paragraph-actions-button"]').should('exist').click();
cy.get('.euiContextMenuPanelTitle').contains('Actions');
cy.get('.euiContextMenuItem__text').eq(0).contains('Add paragraph to top');
cy.get('.euiContextMenuItem__text').eq(1).contains('Add paragraph to bottom');
cy.get('.euiContextMenuItem__text').eq(2).contains('Run all paragraphs');
cy.get('.euiContextMenuItem__text').eq(3).contains('Clear all outputs');
cy.get('.euiContextMenuItem__text').eq(4).contains('Delete all paragraphs');
});

it('Renders markdown', () => {
cy.get('.euiTextArea').should('not.exist');
cy.get(`a[href="${SAMPLE_URL}"]`).should('exist');
Expand Down
2 changes: 2 additions & 0 deletions dashboards-observability/.cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export const setTimeFilter = (setEndTime = false, refresh = true) => {
// notebooks
export const TEST_NOTEBOOK = 'Test Notebook';
export const SAMPLE_URL = 'https://github.com/opensearch-project/sql/tree/main/sql-jdbc';
export const NOTEBOOK_TEXT = 'Use Notebooks to interactively and collaboratively develop rich reports backed by live data. Common use cases for notebooks includes creating postmortem reports, designing run books, building live infrastructure reports, or even documentation.';
export const OPENSEARCH_URL = 'https://opensearch.org/docs/latest/observability-plugin/notebooks/';
export const MARKDOWN_TEXT = `%md
# Heading 1
Expand Down

0 comments on commit ccee0d3

Please sign in to comment.