Fix off-by-one errors in the "FreeText must move several annotations" integration test
The x/y-coordinates are floats instead of integers like one might expect. The current approach rounds both the old and the new coordinates in order to do integer comparison. However, rounding each coordinate individually causes too much loss of precision because, depending on the decimal value, they are either rounded up or down which causes intermittent off-by-one errors. This commit fixes the problem by comparing coordinate differences instead of the coordinates themselves. The precision loss is avoided by subtracting the old from the new coordinate as-is and only rounding the final result.
This commit is contained in:
parent
e37e7b6f39
commit
306cca930f
@ -2254,12 +2254,12 @@ describe("FreeText Editor", () => {
|
||||
return { x, y };
|
||||
});
|
||||
const oldPos = allPositions[i];
|
||||
expect(Math.round(pos.x))
|
||||
expect(Math.round(pos.x - oldPos.x))
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual(Math.round(oldPos.x + 39));
|
||||
expect(Math.round(pos.y))
|
||||
.toEqual(39);
|
||||
expect(Math.round(pos.y - oldPos.y))
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual(Math.round(oldPos.y + 74));
|
||||
.toEqual(74);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user