Skip to content

Commit

Permalink
update cypress testing for notebooks (#2255)
Browse files Browse the repository at this point in the history
Signed-off-by: Ritvi Bhatt <[email protected]>
Co-authored-by: Ritvi Bhatt <[email protected]>
(cherry picked from commit 6917d77)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and Ritvi Bhatt committed Nov 19, 2024
1 parent 9982eae commit f295f75
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
48 changes: 19 additions & 29 deletions .cypress/integration/notebooks_test/notebooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ describe('Adding sample data and visualization', () => {

it('Add sample observability data', () => {
moveToEventsHome();
cy.get('button[data-test-subj="eventHomeAction"]').trigger('mouseover').click();
cy.get('button[data-test-subj="eventHomeAction__addSamples"]').trigger('mouseover').click();
cy.get('button[data-test-subj="actionAddSamples"]').trigger('mouseover').click();
cy.get('.euiModalHeader__title[data-test-subj="confirmModalTitleText"]')
.contains('Add samples')
.should('exist');
Expand Down Expand Up @@ -116,8 +115,7 @@ describe('Testing notebooks table', () => {

it('Deletes all notebooks', () => {
cy.get('input[data-test-subj="checkboxSelectAll"]').click();
cy.get('button[data-test-subj="notebookTableActionBtn"]').click();
cy.get('button[data-test-subj="deleteNotebookBtn"]').click();
cy.get('button[data-test-subj="deleteSelectedNotebooks"]').click();
cy.get('button[data-test-subj="delete-notebook-modal-delete-button"]').should('be.disabled');
cy.get('input[data-test-subj="delete-notebook-modal-input"]').focus().type('delete');
cy.get('button[data-test-subj="delete-notebook-modal-delete-button"]').should(
Expand All @@ -135,7 +133,7 @@ describe('Testing paragraphs', () => {
cy.get('a[data-test-subj="createNotebookPrimaryBtn"]').click();
cy.get('input[data-test-subj="custom-input-modal-input"]').focus().type(TEST_NOTEBOOK);
cy.get('button[data-test-subj="custom-input-modal-confirm-button"]').click();
cy.get('h3[data-test-subj="notebookTableTitle"]').contains(TEST_NOTEBOOK).should('exist');
cy.get('h3[data-test-subj="notebookTitle"]').contains(TEST_NOTEBOOK).should('exist');
});

beforeEach(() => {
Expand Down Expand Up @@ -166,7 +164,7 @@ describe('Testing paragraphs', () => {

it('Has working breadcrumbs', () => {
cy.get('a[data-test-subj="breadcrumb last"]').contains(TEST_NOTEBOOK).click();
cy.get('h3[data-test-subj="notebookTableTitle"]').contains(TEST_NOTEBOOK).should('exist');
cy.get('h3[data-test-subj="notebookTitle"]').contains(TEST_NOTEBOOK).should('exist');
cy.get('a[data-test-subj="breadcrumb"]').contains('Notebooks').click();
cy.get('h3[data-test-subj="notebookTableTitle"]').should('exist');
cy.get('a[data-test-subj="breadcrumb first"]').contains('Observability').click();
Expand Down Expand Up @@ -298,6 +296,7 @@ describe('Testing paragraphs', () => {
});

it('Adds an observability visualization paragraph', () => {
cy.get('h3[data-test-subj="notebookTitle"]').contains(TEST_NOTEBOOK).should('exist');
cy.get('button[data-test-subj="notebook-paragraph-actions-button"]').click();
cy.get('span.euiContextMenuItem__text').contains('To top').click();
cy.get('button.euiContextMenuItem').contains('Visualization').click();
Expand All @@ -309,9 +308,8 @@ describe('Testing paragraphs', () => {
cy.get('div[data-test-subj="comboBoxInput"]').click();
cy.get('input[data-test-subj="comboBoxSearchInput"]')
.focus()
.type('[Logs] Count total requests by tags');

cy.get('.euiComboBoxOption__content').contains('[Logs] Count total requests by tags').click();
.type('[Logs] Count total requests by t');
cy.get('.euiComboBoxOption__content').contains('[Logs] Count total requests by tags').click({ force: true });

Check warning on line 312 in .cypress/integration/notebooks_test/notebooks.spec.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
cy.get('button[data-test-subj="runRefreshBtn-0"]').click();
cy.get('h5').contains('[Logs] Count total requests by tags').should('exist');
});
Expand All @@ -335,18 +333,15 @@ describe('Testing paragraphs', () => {

it('Clears outputs', () => {
cy.get('h3[data-test-subj="notebookTitle"]').contains(TEST_NOTEBOOK).should('exist');
cy.get('[data-test-subj="notebook-paragraph-actions-button"]').should('exist');
cy.get('[data-test-subj="notebook-paragraph-actions-button"]').click();
cy.get('.euiContextMenuItem__text').contains('Clear all outputs').click();
cy.get('.euiButton__text').contains('Clear all outputs').click();
cy.get('button[data-test-subj="confirmModalConfirmButton"]').click();

cy.get(`a[href="${SAMPLE_URL}"]`).should('not.exist');
});

it('Runs all paragraphs', () => {
cy.get('h3[data-test-subj="notebookTitle"]').contains(TEST_NOTEBOOK).should('exist');
cy.get('[data-test-subj="notebook-paragraph-actions-button"]').click();
cy.get('.euiContextMenuItem__text').contains('Run all paragraphs').click();
cy.get('.euiButton__text').contains('Run all paragraphs').click();

cy.get(`a[href="${SAMPLE_URL}"]`).should('exist');
});
Expand All @@ -365,11 +360,11 @@ describe('Testing paragraphs', () => {
cy.get('h3[data-test-subj="notebookTitle"]').contains(TEST_NOTEBOOK).should('exist');

cy.get('button[data-test-subj="notebook-paragraph-actions-button"]').click();
cy.get('span.euiContextMenuItem__text').contains('To To bottom').click();
cy.get('span.euiContextMenuItem__text').contains('To bottom').click();
cy.get('button.euiContextMenuItem').contains('Code block').click();

cy.get('.euiText').contains('[4] Visualization').should('exist');
cy.get('.euiText').contains('[5] Code block').should('exist');
cy.get('.euiText').contains('[6] Visualization').should('exist');
cy.get('.euiText').contains('[7] Code block').should('exist');
});

it('Moves paragraphs', () => {
Expand All @@ -378,39 +373,35 @@ describe('Testing paragraphs', () => {
cy.get('.euiContextMenuItem-isDisabled').should('have.length.gte', 2);
cy.get('.euiContextMenuItem__text').contains('Move to bottom').click();

cy.get('.euiText').contains('[3] Visualization').should('exist');
cy.get('.euiText').contains('[5] Visualization').should('exist');
});

it('Duplicates and renames the notebook', () => {
cy.get('h3[data-test-subj="notebookTitle"]').contains(TEST_NOTEBOOK).should('exist');
cy.get('[data-test-subj="notebook-notebook-actions-button"]').click();
cy.get('.euiContextMenuItem__text').contains('Duplicate notebook').click();
cy.get('[data-test-subj="notebook-duplicate-icon"]').click();
cy.get('.euiButton__text').contains('Duplicate').click();

cy.get('[data-test-subj="notebook-notebook-actions-button"]').click();
cy.get('.euiContextMenuItem__text').contains('Rename notebook').click();
cy.get('[data-test-subj="notebook-edit-icon"]').click();
cy.get('input.euiFieldText[data-autofocus="true"]').focus().type(' (rename)');
cy.get('.euiButton__text').last().contains('Rename').click();
cy.reload();

cy.get('.euiText')
cy.get('h3[data-test-subj="notebookTitle"]')
.contains(TEST_NOTEBOOK + ' (rename)')
.should('exist');
cy.get(`a[href="${SAMPLE_URL}"]`).should('have.length.gte', 2);
});

it('Deletes paragraphs', () => {
cy.get('h3[data-test-subj="notebookTitle"]').contains(TEST_NOTEBOOK).should('exist');
cy.get('[data-test-subj="notebook-paragraph-actions-button"]').click();
cy.get('.euiContextMenuItem__text').contains('Delete all paragraphs').click();
cy.get('.euiButton__text').contains('Delete all paragraphs').click();
cy.get('button[data-test-subj="confirmModalConfirmButton"]').click();

cy.get('button[data-test-subj="emptyNotebookAddCodeBlockBtn"]').should('exist');
});

it('Deletes notebook', () => {
cy.get('[data-test-subj="notebook-notebook-actions-button"]').click();
cy.get('.euiContextMenuItem__text').contains('Delete notebook').click();
cy.get('[data-test-subj="notebook-delete-icon"]').click();
cy.get('button[data-test-subj="delete-notebook-modal-delete-button"]').should('be.disabled');

cy.get('input[data-test-subj="delete-notebook-modal-input"]').focus().type('delete');
Expand All @@ -426,8 +417,7 @@ describe('clean up all test data', () => {
it('Cleans up test notebooks', () => {
moveToNotebookHome();
cy.get('input[data-test-subj="checkboxSelectAll"]').click();
cy.get('button[data-test-subj="notebookTableActionBtn"]').click();
cy.get('button[data-test-subj="deleteNotebookBtn"]').click();
cy.get('button[data-test-subj="deleteSelectedNotebooks"]').click();
cy.get('button[data-test-subj="delete-notebook-modal-delete-button"]').should('be.disabled');
cy.get('input[data-test-subj="delete-notebook-modal-input"]').focus().type('delete');
cy.get('button[data-test-subj="delete-notebook-modal-delete-button"]').should(
Expand Down
2 changes: 1 addition & 1 deletion .cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const TEST_INTEGRATION_INSTANCE = 'nginx-test';
export const TEST_SAMPLE_INSTANCE = 'nginx-sample';
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.';
'Use Notebooks to interactively and collaboratively develop rich reports backed by live data. Common use cases for notebooks include 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 f295f75

Please sign in to comment.