Fixed unstable test (#11583)

This commit is contained in:
adam-stasiak-polidea 2020-11-09 02:53:43 +01:00 committed by GitHub
parent ea0abbffb4
commit 24ba5301d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 17 deletions

View File

@ -60,13 +60,23 @@ describe('Visualization > Bubble', () => {
// Number of circles are pretty unstable when there are a lot of circles
// Since main functionality is already covered in fitler test below,
// skip this test untill we find a solution.
it.skip('should work', () => {
verify(BUBBLE_FORM_DATA);
// number of circles = 214 rows
cy.get('.chart-container svg .nv-point-clips circle').should(
'have.length',
214,
);
it('should work', () => {
cy.visitChartByParams(JSON.stringify(BUBBLE_FORM_DATA)).then(() => {
cy.wait('@getJson').then(xhr => {
let expectedBubblesNumber = 0;
xhr.responseBody.data.forEach(element => {
expectedBubblesNumber += element.values.length;
});
cy.get('[data-test="chart-container"]')
.should('be.visible', { timeout: 15000 })
.within(() => {
cy.get('svg')
.should('exist')
.find('.nv-point-clips circle')
.should('have.length', expectedBubblesNumber);
});
});
});
});
it('should work with filter', () => {
@ -84,8 +94,11 @@ describe('Visualization > Bubble', () => {
},
],
});
cy.get('.chart-container svg .nv-point-clips circle')
.should('have.length', 8)
cy.get('[data-test="chart-container"]')
.should('be.visible')
.within(() => {
cy.get('svg').find('.nv-point-clips circle').should('have.length', 8);
})
.then(nodeList => {
// Check that all circles have same color.
const color = nodeList[0].getAttribute('fill');

View File

@ -61,14 +61,18 @@ Cypress.Commands.add('verifyResponseCodes', (xhr: XMLHttpRequest, callback) => {
Cypress.Commands.add('verifySliceContainer', chartSelector => {
// After a wait response check for valid slice container
cy.get('.slice_container').within(() => {
if (chartSelector) {
cy.get(chartSelector).then(chart => {
expect(chart[0].clientWidth).greaterThan(0);
expect(chart[0].clientHeight).greaterThan(0);
});
}
});
cy.get('.slice_container')
.should('be.visible')
.within(() => {
if (chartSelector) {
cy.get(chartSelector)
.should('be.visible')
.then(chart => {
expect(chart[0].clientWidth).greaterThan(0);
expect(chart[0].clientHeight).greaterThan(0);
});
}
});
return cy;
});