Skip to content

Commit

Permalink
fixing panels tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Li <lnse@amazon.com>
  • Loading branch information
sejli committed Jan 23, 2024
1 parent 8b79722 commit 5952206
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
/// <reference types="cypress" />

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', () => {
Expand All @@ -22,31 +22,33 @@ 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,
});
cy.get('.euiButton__text')
.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')
Expand All @@ -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);
});
});
4 changes: 2 additions & 2 deletions cypress/utils/plugins/observability-dashboards/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,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 = [
Expand Down Expand Up @@ -237,6 +236,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#`);
Expand Down

0 comments on commit 5952206

Please sign in to comment.