From 5ca8006d38569063a2838ca0d3fa679af58bd3f7 Mon Sep 17 00:00:00 2001 From: Sean Li Date: Sat, 3 Feb 2024 22:39:38 -0800 Subject: [PATCH] fixing panels tests (#1006) Signed-off-by: Sean Li (cherry picked from commit abb5701777f3e500ff069174cf15a5173b77d7e3) --- .../observability-dashboards/4_panels.spec.js | 23 +++++++++++-------- .../observability-dashboards/constants.js | 4 ++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cypress/integration/plugins/observability-dashboards/4_panels.spec.js b/cypress/integration/plugins/observability-dashboards/4_panels.spec.js index de7d458d8..ef76d26ee 100644 --- a/cypress/integration/plugins/observability-dashboards/4_panels.spec.js +++ b/cypress/integration/plugins/observability-dashboards/4_panels.spec.js @@ -6,14 +6,14 @@ /// import { - PANEL_DELAY as delay, TEST_PANEL, + TEST_PANEL_COPY, BASE_PATH, + PANELS_TIMEOUT, } from '../../../utils/constants'; const moveToPanelHome = () => { cy.visit(`${BASE_PATH}/app/observability-dashboards#`); - cy.wait(delay * 3); }; describe('Testing panels table', () => { @@ -22,11 +22,12 @@ describe('Testing panels table', () => { }); it('Creates a panel and redirects to the panel', () => { - cy.get('.euiButton__text') + // Extending timeout so page completely loads + cy.get('.euiButton__text', { timeout: PANELS_TIMEOUT }) .contains('Create Dashboard') .trigger('mouseover') .click(); - cy.wait(delay); + cy.location('href').should('include', 'create'); cy.get('input.euiFieldText').focus().type(TEST_PANEL, { delay: 50, }); @@ -34,19 +35,20 @@ describe('Testing panels table', () => { .contains(/^Create$/) .trigger('mouseover') .click(); - cy.wait(delay); + cy.intercept('POST', '/api/saved_objects/*').as('createDashboard'); + cy.wait('@createDashboard'); cy.contains(TEST_PANEL).should('exist'); }); it('Duplicates a panel', () => { - cy.get('.euiCheckbox__input[title="Select this row"]') + cy.get('.euiCheckbox__input[title="Select this row"]', { + timeout: PANELS_TIMEOUT, + }) .eq(0) .trigger('mouseover') .click(); - cy.wait(delay); cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click(); - cy.wait(delay); cy.get('.euiContextMenuItem__text') .contains('Duplicate') .trigger('mouseover') @@ -55,6 +57,9 @@ describe('Testing panels table', () => { .contains('Duplicate') .trigger('mouseover') .click(); - cy.wait(delay); + cy.intercept('POST', '/api/saved_objects/*').as('createDashboard'); + cy.wait('@createDashboard'); + + cy.contains(TEST_PANEL_COPY); }); }); diff --git a/cypress/utils/plugins/observability-dashboards/constants.js b/cypress/utils/plugins/observability-dashboards/constants.js index 402c68d42..5b54ce95a 100644 --- a/cypress/utils/plugins/observability-dashboards/constants.js +++ b/cypress/utils/plugins/observability-dashboards/constants.js @@ -202,9 +202,8 @@ export const landOnPanels = () => { * Panel Constants */ -export const PANEL_DELAY = 100; - export const TEST_PANEL = 'Test Panel'; +export const TEST_PANEL_COPY = 'Test Panel (copy)'; export const SAMPLE_PANEL = '[Logs] Web traffic Panel'; export const SAMPLE_VISUALIZATIONS_NAMES = [ @@ -241,6 +240,7 @@ export const PPL_FILTER = export const TYPING_DELAY = 1500; export const TIMEOUT_DELAY = Cypress.env('SECURITY_ENABLED') ? 60000 : 30000; +export const PANELS_TIMEOUT = 120000; export const moveToHomePage = () => { cy.visit(`${BASE_PATH}/app/observability-applications#`);