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

[Cypress Updates] Notebooks updates #2255

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
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
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 @@

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 @@

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 @@
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 @@

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 All @@ -189,7 +187,7 @@

it('Renders input only mode', () => {
cy.get('input[data-test-subj="input_only"]').should('exist');
cy.get('input[data-test-subj="input_only"]').click({ force: true });

Check warning on line 190 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('div.markdown-body').should('not.exist');
cy.get('button[data-test-subj="viewBothLink"]').should('exist');
Expand All @@ -201,7 +199,7 @@

it('Renders output only mode', () => {
cy.get('input[data-test-subj="output_only"]').should('exist');
cy.get('input[data-test-subj="output_only"]').click({ force: true });

Check warning on line 202 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[aria-label="Open paragraph menu"]').should('not.exist');
cy.get('button[data-test-subj="paragraphToggleInputBtn"]').should('not.exist');
cy.get('code').contains('POST').should('exist');
Expand Down Expand Up @@ -298,6 +296,7 @@
});

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 @@
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 @@

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 @@
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 @@
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 @@
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 @@ -69,13 +69,13 @@
cy.get('.euiQuickSelect__applyButton').click();
cy.get('.euiSuperDatePicker__prettyFormatLink').click();
cy.get('.euiTab__content').contains('Absolute').click();
cy.get('input[data-test-subj="superDatePickerAbsoluteDateInput"]')

Check warning on line 72 in .cypress/utils/constants.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
.focus()
.type('{selectall}' + startTime, { force: true });
if (setEndTime) {
cy.get('button.euiDatePopoverButton--end[data-test-subj="superDatePickerendDatePopoverButton"]').click();
cy.get('.euiTab__content').contains('Absolute').click();
cy.get('input[data-test-subj="superDatePickerAbsoluteDateInput"]')

Check warning on line 78 in .cypress/utils/constants.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
.focus()
.type('{selectall}' + endTime, { force: true });
}
Expand All @@ -95,7 +95,7 @@
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
Loading