Skip to content

Commit

Permalink
Update notebooks and traces tests with dynamic wait (#1693)
Browse files Browse the repository at this point in the history
* Fix flaky notebook, traces tests

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* waits for reporting panel to appear

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* wait for paragraph to run

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* update reporting context menu interaction

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* wait for all notebooks to be loaded

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

---------

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
(cherry picked from commit 68eb31f)
  • Loading branch information
ps48 authored and github-actions[bot] committed Feb 5, 2025
1 parent 028e8d8 commit 2012f29
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
SERVICE_NAME,
setTimeFilter,
delayTime,
TIMEOUT_DELAY,
} from '../../../utils/constants';

describe('Testing services table', () => {
Expand All @@ -32,6 +31,7 @@ describe('Testing services table', () => {
});

it('Opens service flyout', () => {
cy.contains('6.42').should('exist');
cy.get('button[data-test-subj^="service-flyout-action-btn"]')
.first()
.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,46 @@ const makePopulatedParagraph = () => {
cy.get('textarea[data-test-subj="editorArea-0"]').focus();
cy.get('textarea[data-test-subj="editorArea-0"]').type(MARKDOWN_TEXT);
cy.get('button[data-test-subj="runRefreshBtn-0"]').click();
cy.get('textarea[data-test-subj="editorArea-0"]').should('not.exist');
cy.get(`a[href="${SAMPLE_URL}"]`).should('exist');
cy.get('code').contains('POST').should('exist');
};

const deleteNotebook = (notebookName) => {
moveToNotebookHome();
const deleteNotebook = () => {
cy.get('button[data-test-subj="notebook-delete-icon"]').click();
cy.get('input[data-test-subj="delete-notebook-modal-input"]').type('delete');
cy.get('button[data-test-subj="delete-notebook-modal-delete-button"]').should(
'not.be.disabled'
);
cy.get(
'button[data-test-subj="delete-notebook-modal-delete-button"]'
).click();
};

cy.contains('.euiTableRow', notebookName)
.find('input[type="checkbox"]')
.check();
const deleteAllNotebooks = () => {
cy.intercept(
'DELETE',
'/api/observability/notebooks/note/savedNotebook/*'
).as('deleteNotebook');
moveToNotebookHome();

cy.get('[data-test-subj="deleteSelectedNotebooks"]').click();
cy.get('[data-test-subj="globalLoadingIndicator"]').should('not.exist');

cy.get('input[data-test-subj="delete-notebook-modal-input"]').focus();
cy.get('input[data-test-subj="checkboxSelectAll"]').should('exist');
cy.get('input[data-test-subj="checkboxSelectAll"]').click();
cy.get('button[data-test-subj="deleteSelectedNotebooks"]')
.contains('Delete 4 notebooks')
.should('exist');
cy.get('button[data-test-subj="deleteSelectedNotebooks"]').click();
cy.get('input[data-test-subj="delete-notebook-modal-input"]').type('delete');
cy.get('button[data-test-subj="delete-notebook-modal-delete-button"]').should(
'not.be.disabled'
);
cy.get(
'button[data-test-subj="delete-notebook-modal-delete-button"]'
).click();
moveToNotebookHome();

cy.contains('.euiTableRow', notebookName).should('not.exist');
cy.wait('@deleteNotebook').its('response.statusCode').should('eq', 200);
};

describe('Testing notebook actions', () => {
Expand All @@ -83,9 +101,7 @@ describe('Testing notebook actions', () => {
});

afterEach(() => {
cy.get('@notebook').then((notebook) => {
deleteNotebook(notebook.name);
});
deleteNotebook();
});

it('Creates a code paragraph', () => {
Expand All @@ -99,9 +115,6 @@ describe('Testing notebook actions', () => {

it('Renders markdown', () => {
makePopulatedParagraph();
cy.get('textarea[data-test-subj="editorArea-0"]').should('not.exist');
cy.get(`a[href="${SAMPLE_URL}"]`).should('exist');
cy.get('code').contains('POST').should('exist');
cy.get('td').contains('b2').should('exist');
});
});
Expand All @@ -114,35 +127,39 @@ describe('Test reporting integration if plugin installed', () => {
skipOn($body.find('#reportingActionsButton').length <= 0);
});
makePopulatedParagraph();
cy.get('.euiContextMenuPanel').should('not.exist');
cy.get('button[data-test-subj="reporting-actions-button"]').should(
'be.visible'
);
cy.get('button[data-test-subj="reporting-actions-button"]').click();
});

afterEach(() => {
cy.get('@notebook').then((notebook) => {
deleteNotebook(notebook.name);
});
after(() => {
deleteAllNotebooks();
});

it('Create in-context PDF report from notebook', () => {
cy.get('#reportingActionsButton').click();
cy.get('button.euiContextMenuItem:nth-child(1)')
.contains('Download PDF')
.click();
cy.get('body').contains('Please continue report generation in the new tab');
.click({ force: true });
cy.get('body')
.contains('Please continue report generation in the new tab')
.should('exist');
});

it('Create in-context PNG report from notebook', () => {
cy.get('#reportingActionsButton').click();
cy.get('button.euiContextMenuItem:nth-child(2)')
.contains('Download PNG')
.click();
cy.get('body').contains('Please continue report generation in the new tab');
.click({ force: true });
cy.get('body')
.contains('Please continue report generation in the new tab')
.should('exist');
});

it('Create on-demand report definition from context menu', () => {
cy.get('#reportingActionsButton').click();
cy.get('button.euiContextMenuItem:nth-child(3)')
.contains('Create report definition')
.click();
.click({ force: true });
cy.location('pathname', { timeout: delayTime * 3 }).should(
'include',
'/reports-dashboards'
Expand All @@ -152,10 +169,9 @@ describe('Test reporting integration if plugin installed', () => {
});

it('View reports homepage from context menu', () => {
cy.get('#reportingActionsButton').click();
cy.get('button.euiContextMenuItem:nth-child(4)')
.contains('View reports')
.click();
.click({ force: true });
cy.location('pathname', { timeout: delayTime * 3 }).should(
'include',
'/reports-dashboards'
Expand Down

0 comments on commit 2012f29

Please sign in to comment.