kettanaito/sentinel-dom

Wrong dimensions comparison (rounding)

Closed this issue · 2 comments

What

There is a wrong calculation of delta width computed in the snapshot.

Steps to reproduce

Target area:

bottom: 608
height: 410
left: 25.9951171875
right: 953.3857421875
top: 198
width: 927.390625 // notice the width

Snapshot options:

thresholdX: 100,
thresholdY: 80

Delta area:

bottom: 612
height: 410
left: 26
right: 953.3857421875
top: 202
width: 927.3857421875 // delta's area width should be the same, but it's not

Comparison:

Expects 927.3857421875 (HD) >= 927.390625 (expectedWidth)

How

This may be related to the rounding of numbers during the calculations. In that case, any rounding should be explicitly prevented to guarantee stable dimensions comparison.

Math.floor was added to coordinates calculations of Area instance.

This should supposedly fix the issue with coordinates mismatch. This bug should be covered in tests to ensure it's not reproducible.

Update

A dedicated bugfix test is provided for this issue under 49db4f3. Confirmed as not reproducible. Closing.