Skip to content

Commit

Permalink
remove cypress delay and wait calls
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <[email protected]>
  • Loading branch information
ps48 committed Jan 10, 2024
1 parent abbda41 commit 87162c7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 55 deletions.
78 changes: 24 additions & 54 deletions gantt-chart/.cypress/integration/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import customParseFormat from 'dayjs/plugin/customParseFormat';
import dayjs from 'dayjs';
import { delay, GANTT_VIS_NAME, Y_LABEL, X_LABEL, DEFAULT_SIZE } from '../utils/constants';
import { GANTT_VIS_NAME, Y_LABEL, X_LABEL, DEFAULT_SIZE } from '../utils/constants';
dayjs.extend(customParseFormat);

describe('Dump test data', () => {
Expand Down Expand Up @@ -51,19 +51,13 @@ describe('Save a gantt chart', () => {

it('Creates and saves a gantt chart', () => {
cy.get('.euiButton__text').contains('Create ').click({ force: true });
cy.wait(delay);
cy.get('[data-test-subj="visTypeTitle"]').contains('Gantt Chart').click({ force: true });
cy.wait(delay);
cy.contains(/^jaeger$/).click({ force: true });
cy.wait(delay);
cy.contains('Save').click({ force: true });
cy.wait(delay);
cy.get('input[data-test-subj="savedObjectTitle"]').type(GANTT_VIS_NAME);
cy.wait(delay);
cy.get('button[data-test-subj="confirmSaveSavedObjectButton"]').click({
force: true,
});
cy.wait(delay);

cy.contains('Saved').should('exist');
});
Expand All @@ -80,31 +74,23 @@ describe('Render and configure a gantt chart', () => {
});

it('Renders the chart', () => {
cy.get('button.euiSuperSelectControl').eq(0).click({ force: true });
cy.wait(delay);
cy.get('button[data-test-subj="gantt-chart-editor-label-field"]').click();
cy.get('.euiContextMenuItem__text')
.contains(/^spanID$/)
.click({ force: true });
cy.wait(delay);
cy.get('button.euiSuperSelectControl').eq(1).click({ force: true });
cy.wait(delay);
.click();
cy.get('button[data-test-subj="gantt-chart-editor-start-time-field"]').click();
cy.get('.euiContextMenuItem__text')
.contains(/^startTime$/)
.click({ force: true });
cy.wait(delay);
cy.get('button.euiSuperSelectControl').eq(2).click({ force: true });
cy.wait(delay);
.click();
cy.get('button[data-test-subj="gantt-chart-editor-duration-field"]').click();
cy.get('.euiContextMenuItem__text')
.contains(/^duration$/)
.click({ force: true });
cy.wait(delay);
.click();
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(delay);

cy.get('.traces').should('have.length', DEFAULT_SIZE);

cy.get('.euiButton__text').contains('Save').click({ force: true });
cy.wait(delay);
cy.get('button[data-test-subj="confirmSaveSavedObjectButton"]').click({
force: true,
});
Expand All @@ -120,100 +106,87 @@ describe('Configure panel settings', () => {

it('Changes y-axis label', () => {
cy.get('input.euiFieldText[placeholder="Label"]').eq(0).focus().type(Y_LABEL);
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(delay);

cy.get('text.ytitle').contains(Y_LABEL).should('exist');

cy.get('.euiSwitch__label').contains('Show Y-axis label').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(delay);

cy.get('text.ytitle').should('not.exist');
});

it('Changes x-axis label', () => {
cy.get('input.euiFieldText[placeholder="Label"]').eq(1).focus().type(X_LABEL);
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(delay);

cy.get('text.xtitle').contains(X_LABEL).should('exist');

cy.get('.euiSwitch__label').contains('Show X-axis label').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(delay);

cy.get('text.xtitle').should('not.exist');
});

it('Changes time formats', () => {
cy.intercept({ method: 'POST', url: '**/api/gantt_vis/query' }).as('timeUpdateRequest');

cy.get('select').eq(3).select('MM/DD hh:mm:ss A');
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(1000);
cy.wait('@timeUpdateRequest');
cy.get('.xtick')
.eq(0)
.invoke('text')
.then((text) => {
expect(dayjs(text, 'MM/DD hh:mm:ss A', true).isValid()).to.be.true;
.should('satisfy', (text) => {
return dayjs(text, 'MM/DD hh:mm:ss A', true).isValid();
});

cy.get('select').eq(3).select('MM/DD/YY hh:mm A');
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(1000);
cy.wait('@timeUpdateRequest');
cy.get('.xtick')
.eq(0)
.invoke('text')
.then((text) => {
expect(dayjs(text, 'MM/DD/YY hh:mm A', true).isValid()).to.be.true;
.should('satisfy', (text) => {
return dayjs(text, 'MM/DD/YY hh:mm A', true).isValid();
});

cy.get('select').eq(3).select('HH:mm:ss.SSS');
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(1000);
cy.wait('@timeUpdateRequest');
cy.get('.xtick')
.eq(0)
.invoke('text')
.then((text) => {
expect(dayjs(text, 'HH:mm:ss.SSS', true).isValid()).to.be.true;
.should('satisfy', (text) => {
return dayjs(text, 'HH:mm:ss.SSS', true).isValid();
});

cy.get('select').eq(3).select('MM/DD HH:mm:ss');
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(1000);
cy.wait('@timeUpdateRequest');
cy.get('.xtick')
.eq(0)
.invoke('text')
.then((text) => {
expect(dayjs(text, 'MM/DD HH:mm:ss', true).isValid()).to.be.true;
.should('satisfy', (text) => {
return dayjs(text, 'MM/DD HH:mm:ss', true).isValid();
});

cy.get('select').eq(3).select('MM/DD/YY HH:mm');
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(1000);
cy.wait('@timeUpdateRequest');
cy.get('.xtick')
.eq(0)
.invoke('text')
.then((text) => {
expect(dayjs(text, 'MM/DD/YY HH:mm', true).isValid()).to.be.true;
.should('satisfy', (text) => {
return dayjs(text, 'MM/DD/YY HH:mm', true).isValid();
});
});

it('Hides legends', () => {
cy.get('g.traces').should('have.length', DEFAULT_SIZE);

cy.get('.euiSwitch__label').contains('Show legend').click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(delay);

cy.get('g.traces').should('not.exist');
});
Expand All @@ -224,13 +197,10 @@ describe('Add gantt chart to dashboard', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/dashboards#/create`);

cy.contains('Add an existing').click({ force: true });
cy.wait(delay);
cy.get('input[data-test-subj="savedObjectFinderSearchInput"]').focus().type(GANTT_VIS_NAME);
cy.wait(delay);
cy.get(`.euiListGroupItem__label[title="${GANTT_VIS_NAME}"]`).click({
force: true,
});
cy.wait(delay);

cy.get('g.traces').should('have.length', DEFAULT_SIZE);
});
Expand Down
1 change: 0 additions & 1 deletion gantt-chart/.cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

export const delay = 100;
export const GANTT_VIS_NAME = 'A test gantt chart ' + Math.random().toString(36).substring(2);
export const Y_LABEL = 'A unique label for Y-axis';
export const X_LABEL = 'A unique label for X-axis';
Expand Down

0 comments on commit 87162c7

Please sign in to comment.