Skip to content

Commit

Permalink
Fix Flaky Dashboards Visualization Tests (#1187)
Browse files Browse the repository at this point in the history
* fixing gantt chart flaky tests

Signed-off-by: Sean Li <[email protected]>

* removing comments

Signed-off-by: Sean Li <[email protected]>

* try global tenant

Signed-off-by: Sean Li <[email protected]>

* try global tenant in before hook

Signed-off-by: Sean Li <[email protected]>

---------

Signed-off-by: Sean Li <[email protected]>
  • Loading branch information
sejli authored Mar 29, 2024
1 parent 4912034 commit 4faa0c9
Showing 1 changed file with 107 additions and 102 deletions.
209 changes: 107 additions & 102 deletions cypress/integration/plugins/gantt-chart-dashboards/gantt_ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import customParseFormat from 'dayjs/plugin/customParseFormat';
import dayjs from 'dayjs';
import { BASE_PATH } from '../../../utils/constants';
import { CURRENT_TENANT } from '../../../utils/commands';

dayjs.extend(customParseFormat);

const delay = 5000;
const GANTT_VIS_NAME =
'A test gantt chart ' + Math.random().toString(36).substring(2);
const Y_LABEL = 'A unique label for Y-axis';
Expand All @@ -20,6 +20,7 @@ const DEFAULT_SIZE = 10;

describe('Dump test data', () => {
it('Indexes test data for gantt chart', () => {
CURRENT_TENANT.newTenant = 'global';
const dumpDataSet = (ndjson, index) =>
cy.request({
method: 'POST',
Expand Down Expand Up @@ -54,103 +55,99 @@ describe('Dump test data', () => {
});
});

describe('Save a gantt chart', () => {
describe('Save a gantt chart', { defaultCommandTimeout: 20000 }, () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
});
beforeEach(() => {
cy.visit(`${BASE_PATH}/app/visualize#`);
cy.wait(delay);
});

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');
});
});

describe('Render and configure a gantt chart', () => {
beforeEach(() => {
cy.wait(delay);
cy.visit(`${BASE_PATH}/app/visualize#`);
cy.contains(GANTT_VIS_NAME).click({ force: true });
cy.wait(delay);
});

it('Renders no data message', () => {
cy.contains('No data').should('exist');
});
describe(
'Render and configure a gantt chart',
{ defaultCommandTimeout: 20000 },
() => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
});
beforeEach(() => {
cy.visit(`${BASE_PATH}/app/visualize#`);
cy.get('.euiFieldSearch').focus().type(GANTT_VIS_NAME);
cy.contains(GANTT_VIS_NAME).click({ force: true });
});

it('Renders the chart', () => {
cy.get('button.euiSuperSelectControl').eq(0).click({ force: true });
cy.wait(delay);
cy.get('.euiContextMenuItem__text')
.contains(/^spanID$/)
.click({ force: true });
cy.wait(delay);
cy.get('button.euiSuperSelectControl').eq(1).click({ force: true });
cy.wait(delay);
cy.get('.euiContextMenuItem__text')
.contains(/^startTime$/)
.click({ force: true });
cy.wait(delay);
cy.get('button.euiSuperSelectControl').eq(2).click({ force: true });
cy.wait(delay);
cy.get('.euiContextMenuItem__text')
.contains(/^duration$/)
.click({ force: true });
cy.wait(delay);
cy.get('.euiButton__text').contains('Update').click({ force: true });
cy.wait(delay);
it('Renders no data message', () => {
cy.contains('No data').should('exist');
});

cy.get('.traces').should('have.length', DEFAULT_SIZE);
cy.wait(delay);
cy.get('.euiButton__text').contains('Save').click({ force: true });
cy.wait(delay);
cy.get('button[data-test-subj="confirmSaveSavedObjectButton"]').click({
force: true,
it('Renders the chart', () => {
cy.get('button.euiSuperSelectControl').eq(0).click({ force: true });
cy.get('.euiContextMenuItem__text')
.contains(/^spanID$/)
.click({ force: true });
// Click away so the dropdown closes
cy.get('.euiTitle').eq(1).click();
cy.get('button.euiSuperSelectControl').eq(1).click({ force: true });
cy.get('.euiContextMenuItem__text')
.contains(/^startTime$/)
.click({ force: true });
// Click away so the dropdown closes
cy.get('.euiTitle').eq(1).click();
cy.get('button.euiSuperSelectControl').eq(2).click({ force: true });
cy.get('.euiContextMenuItem__text')
.contains(/^duration$/)
.click({ force: true });
cy.get('.euiButton__text').contains('Update').click({ force: true });

cy.get('.traces').should('have.length', DEFAULT_SIZE);
cy.get('.euiButton__text').contains('Save').click({ force: true });
cy.get('button[data-test-subj="confirmSaveSavedObjectButton"]').click({
force: true,
});
});
});
});
}
);

describe('Configure panel settings', () => {
describe('Configure panel settings', { defaultCommandTimeout: 20000 }, () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
});
beforeEach(() => {
cy.visit(`${BASE_PATH}/app/visualize#`);
cy.get('.euiFieldSearch').focus().type(GANTT_VIS_NAME);
cy.contains(GANTT_VIS_NAME).click({ force: true });
cy.contains('Panel settings').click({ force: true });
cy.wait(delay);
});

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');
});
Expand All @@ -160,106 +157,114 @@ describe('Configure panel settings', () => {
.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('**').as('timeRequest');
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('@timeRequest');
cy.get('.xtick')
.eq(0)
.invoke('text')
.then((text) => {
expect(dayjs(text, 'MM/DD hh:mm:ss A', true).isValid()).to.be.true;
.should((element) => {
if (element) {
const text = element.text();
cy.log(text);
expect(dayjs(text, 'MM/DD hh:mm:ss A', true).isValid()).to.be.true;
}
});

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('@timeRequest');
cy.get('.xtick')
.eq(0)
.invoke('text')
.then((text) => {
expect(dayjs(text, 'MM/DD/YY hh:mm A', true).isValid()).to.be.true;
.should((element) => {
if (element) {
const text = element.text();
cy.log(text);
expect(dayjs(text, 'MM/DD/YY hh:mm A', true).isValid()).to.be.true;
}
});

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('@timeRequest');
cy.get('.xtick')
.eq(0)
.invoke('text')
.then((text) => {
expect(dayjs(text, 'HH:mm:ss.SSS', true).isValid()).to.be.true;
.should((element) => {
if (element) {
const text = element.text();
cy.log(text);
expect(dayjs(text, 'HH:mm:ss.SSS', true).isValid()).to.be.true;
}
});

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('@timeRequest');
cy.get('.xtick')
.eq(0)
.invoke('text')
.then((text) => {
expect(dayjs(text, 'MM/DD HH:mm:ss', true).isValid()).to.be.true;
.should((element) => {
if (element) {
const text = element.text();
cy.log(text);
expect(dayjs(text, 'MM/DD HH:mm:ss', true).isValid()).to.be.true;
}
});

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('@timeRequest');
cy.get('.xtick')
.eq(0)
.invoke('text')
.then((text) => {
expect(dayjs(text, 'MM/DD/YY HH:mm', true).isValid()).to.be.true;
.should((element) => {
if (element) {
const text = element.text();
cy.log(text);
expect(dayjs(text, 'MM/DD/YY HH:mm', true).isValid()).to.be.true;
}
});
});

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');
});
});

describe('Add gantt chart to dashboard', () => {
it('Adds gantt chart to dashboard', () => {
cy.visit(`${BASE_PATH}/app/dashboards#/create`);
cy.wait(delay);
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,
describe(
'Add gantt chart to dashboard',
{ defaultCommandTimeout: 20000 },
() => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
});
cy.wait(delay);
it('Adds gantt chart to dashboard', () => {
cy.visit(`${BASE_PATH}/app/dashboards#/create`);
cy.contains('Add an existing').click({ force: true });
cy.get('input[data-test-subj="savedObjectFinderSearchInput"]')
.focus()
.type(GANTT_VIS_NAME);
cy.get(`.euiListGroupItem__label[title="${GANTT_VIS_NAME}"]`).click({
force: true,
});

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

0 comments on commit 4faa0c9

Please sign in to comment.