From f3a209badce539122ace155ab0b4c04a6d4eefec Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 7 Dec 2022 14:01:52 +0530 Subject: [PATCH] Remove hardcoded width in tests --- cypress/integration/rendering/gantt.spec.js | 4 ++-- cypress/integration/rendering/pie.spec.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/integration/rendering/gantt.spec.js b/cypress/integration/rendering/gantt.spec.js index 325cca065..e7cc60829 100644 --- a/cypress/integration/rendering/gantt.spec.js +++ b/cypress/integration/rendering/gantt.spec.js @@ -225,7 +225,7 @@ describe('Gantt diagram', () => { const style = svg.attr('style'); expect(style).to.match(/^max-width: [\d.]+px;$/); const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join('')); - expect(maxWidthValue).to.be.within(984 * 0.95, 984 * 1.05); + expect(maxWidthValue).to.be.within(cy.viewport.width * 0.95, cy.viewport.width * 1.05); }); }); @@ -269,7 +269,7 @@ describe('Gantt diagram', () => { const width = parseFloat(svg.attr('width')); // use within because the absolute value can be slightly different depending on the environment ±5% // expect(height).to.be.within(484 * 0.95, 484 * 1.05); - expect(width).to.be.within(984 * 0.95, 984 * 1.05); + expect(width).to.be.within(cy.viewport.width * 0.95, cy.viewport.width * 1.05); expect(svg).to.not.have.attr('style'); }); }); diff --git a/cypress/integration/rendering/pie.spec.js b/cypress/integration/rendering/pie.spec.js index 019fa41af..454a89057 100644 --- a/cypress/integration/rendering/pie.spec.js +++ b/cypress/integration/rendering/pie.spec.js @@ -54,7 +54,7 @@ describe('Pie Chart', () => { const style = svg.attr('style'); expect(style).to.match(/^max-width: [\d.]+px;$/); const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join('')); - expect(maxWidthValue).to.eq(984); + expect(maxWidthValue).to.be.within(cy.viewport.width * 0.95, cy.viewport.width * 1.05); }); }); it('should render a pie diagram when useMaxWidth is false', () => { @@ -71,7 +71,7 @@ describe('Pie Chart', () => { // const height = parseFloat(svg.attr('height')); const width = parseFloat(svg.attr('width')); // expect(height).to.eq(450); - expect(width).to.eq(984); + expect(width).to.be.within(cy.viewport.width * 0.95, cy.viewport.width * 1.05); expect(svg).to.not.have.attr('style'); }); });