Skip to content

Commit 2561d8d

Browse files
committed
Added a tolerance for an assertion
1 parent 0bd0d9d commit 2561d8d

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

cypress/integration/rendering/xychart/xyChart.spec.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,10 @@ describe('XY Chart', () => {
647647
expect(textProps.x).to.be.greaterThan(barProps.x);
648648
expect(textProps.x + textProps.width).to.be.lessThan(barProps.x + barProps.width);
649649

650-
expect(textProps.y).to.be.greaterThan(barProps.y);
651-
expect(textProps.y + textProps.height).to.be.lessThan(barProps.y + barProps.height);
650+
// Allow 1px tolerance: getBBox() height can be 1.2-1.45x the nominal font size,
651+
// so the rendered text may marginally overflow the bar edge by a fraction of a pixel.
652+
expect(textProps.y).to.be.greaterThan(barProps.y - 1);
653+
expect(textProps.y + textProps.height).to.be.lessThan(barProps.y + barProps.height + 1);
652654
expect(textProps.y + textProps.height / 2).to.be.closeTo(
653655
barProps.y + barProps.height / 2,
654656
5
@@ -758,8 +760,10 @@ describe('XY Chart', () => {
758760
expect(textProps.x).to.be.greaterThan(barProps.x);
759761
expect(textProps.x + textProps.width).to.be.lessThan(barProps.x + barProps.width);
760762

761-
expect(textProps.y).to.be.greaterThan(barProps.y);
762-
expect(textProps.y + textProps.height).to.be.lessThan(barProps.y + barProps.height);
763+
// Allow 1px tolerance: getBBox() height can be 1.2-1.45x the nominal font size,
764+
// so the rendered text may marginally overflow the bar edge by a fraction of a pixel.
765+
expect(textProps.y).to.be.greaterThan(barProps.y - 1);
766+
expect(textProps.y + textProps.height).to.be.lessThan(barProps.y + barProps.height + 1);
763767
expect(textProps.y + textProps.height / 2).to.be.closeTo(
764768
barProps.y + barProps.height / 2,
765769
5

0 commit comments

Comments
 (0)