Commit 48973120 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'update-image-diff-note-no-floats' into 'master'

Ensure an annotation's position is of type Int

See merge request gitlab-org/gitlab!29556
parents 0d4e1ad3 b1404dd5
...@@ -201,10 +201,10 @@ export default { ...@@ -201,10 +201,10 @@ export default {
const { x, y } = coordinates; const { x, y } = coordinates;
const { width, height } = this.overlayDimensions; const { width, height } = this.overlayDimensions;
return { return {
x, x: Math.round(x),
y, y: Math.round(y),
width, width: Math.round(width),
height, height: Math.round(height),
}; };
}, },
openCommentForm(coordinates) { openCommentForm(coordinates) {
......
...@@ -443,6 +443,23 @@ describe('Design management design presentation component', () => { ...@@ -443,6 +443,23 @@ describe('Design management design presentation component', () => {
}); });
}); });
describe('getAnnotationPositon', () => {
it.each`
coordinates | overlayDimensions | position
${{ x: 100, y: 100 }} | ${{ width: 50, height: 50 }} | ${{ x: 100, y: 100, width: 50, height: 50 }}
${{ x: 100.2, y: 100.5 }} | ${{ width: 50.6, height: 50.0 }} | ${{ x: 100, y: 101, width: 51, height: 50 }}
`('returns correct annotation position', ({ coordinates, overlayDimensions, position }) => {
createComponent(undefined, {
overlayDimensions: {
width: overlayDimensions.width,
height: overlayDimensions.height,
},
});
expect(wrapper.vm.getAnnotationPositon(coordinates)).toStrictEqual(position);
});
});
describe('when design is overflowing', () => { describe('when design is overflowing', () => {
beforeEach(() => { beforeEach(() => {
createComponent( createComponent(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment