Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

ci: LEAP-753: e2e image problems no externals #1713

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
14 changes: 7 additions & 7 deletions e2e/examples/image-keypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const config = `
`;

const data = {
image: 'https://user.fm/files/v2-901310d5cb3fa90e0616ca10590bacb3/spacexmoon-800x501.jpg',
image: 'https://data.heartex.net/open-images/train_0/mini/0030019819f25b28.jpg',
};

const result = [
Expand All @@ -18,14 +18,14 @@ const result = [
from_name: 'tag',
to_name: 'img',
image_rotation: 0,
original_height: 501,
original_width: 800,
original_height: 576,
original_width: 768,
type: 'keypointlabels',
origin: 'manual',
value: {
x: 49.60000000000001,
y: 52.34042553191488,
width: 0.6471078324314267,
width: 0.6120428759942558,
keypointlabels: ['Hello'],
},
},
Expand All @@ -34,14 +34,14 @@ const result = [
from_name: 'tag',
to_name: 'img',
image_rotation: 0,
original_height: 501,
original_width: 800,
original_height: 576,
original_width: 768,
type: 'keypointlabels',
origin: 'manual',
value: {
x: 47.73333333333334,
y: 52.765957446808514,
width: 0.6666666666666666,
width: 0.6305418719211823,
keypointlabels: ['World'],
},
},
Expand Down
6 changes: 6 additions & 0 deletions e2e/fragments/AtImageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ module.exports = {
I.waitForVisible('canvas', 5);
},

async getNaturalSize() {
const sizes = await I.executeScript(Helpers.getNaturalSize);

return sizes;
},

async getCanvasSize() {
const sizes = await I.executeScript(Helpers.getCanvasSize);

Expand Down
11 changes: 10 additions & 1 deletion e2e/tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ const convertToFixed = (data, fractionDigits = 2) => {
if (['string', 'number'].includes(typeof data)) {
const n = Number(data);

return Number.isNaN(n) ? data : Number.isInteger(n) ? n : +Number(n).toFixed(fractionDigits);
return Number.isNaN(n) ? data : Number.isInteger(n) ? n : +n.toFixed(fractionDigits);
}
if (Array.isArray(data)) {
return data.map(n => convertToFixed(n, fractionDigits));
Expand Down Expand Up @@ -533,6 +533,14 @@ async function generateImageUrl({ width, height }) {
return canvas.toDataURL();
}

const getNaturalSize = () => {
const imageObject = window.Htx.annotationStore.selected.objects.find(o => o.type === 'image');

return {
width: imageObject.naturalWidth,
height: imageObject.naturalHeight,
};
};
const getCanvasSize = () => {
const imageObject = window.Htx.annotationStore.selected.objects.find(o => o.type === 'image');

Expand Down Expand Up @@ -859,6 +867,7 @@ module.exports = {
areEqualRGB,
hasKonvaPixelColorAtPoint,
getKonvaPixelColorFromPoint,
getNaturalSize,
getCanvasSize,
getImageSize,
getImageFrameSize,
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/history.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature('Time traveling');

const IMAGE = 'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/images/nick-owuor-astro-nic-visuals-wDifg5xc9Z4-unsplash.jpg';
const IMAGE = 'https://data.heartex.net/open-images/train_0/mini/0030019819f25b28.jpg';

Scenario('Travel through history with the selected brush region', async function({ I, LabelStudio, AtImageView, AtSidebar }) {
I.amOnPage('/');
Expand Down
3 changes: 1 addition & 2 deletions e2e/tests/image-labels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ const { toKebabCase } = require('strman');

Feature('Images\' labels type matching');

const IMAGE =
'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/images/nick-owuor-astro-nic-visuals-wDifg5xc9Z4-unsplash.jpg';
const IMAGE = 'https://data.heartex.net/open-images/train_0/mini/0030019819f25b28.jpg';

const createConfig = ({ shapes = ['Rectangle'], props } = {}) => {
return `<View>
Expand Down
7 changes: 3 additions & 4 deletions e2e/tests/image.gestures.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const DEFAULT_DIMENSIONS = {

Feature('Creating regions with gesture');

const IMAGE =
'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/images/nick-owuor-astro-nic-visuals-wDifg5xc9Z4-unsplash.jpg';
const IMAGE = 'https://data.heartex.net/open-images/train_0/mini/0030019819f25b28.jpg';

const BLUEVIOLET = {
color: '#8A2BE2',
Expand All @@ -36,7 +35,7 @@ const createShape = {
byMultipleClicks(x, y, radius, opts = {}) {
const points = [];

for (let i = 5; i--; ) {
for (let i = 5; i--;) {
points.push([x + Math.sin(((2 * Math.PI) / 5) * i) * radius, y - Math.cos(((2 * Math.PI) / 5) * i) * radius]);
points.push([
x + (Math.sin(((2 * Math.PI) / 5) * (i - 0.5)) * radius) / 3,
Expand Down Expand Up @@ -209,7 +208,7 @@ Scenario('Creating regions by various gestures', async function({ I, AtImageView
for (const [idx, region] of Object.entries(regions)) {
I.pressKey(region.hotKey);
AtImageView[region.action](...region.params);
AtSidebar.seeRegions(+idx+1);
AtSidebar.seeRegions(+idx + 1);
}
const result = await I.executeScript(serialize);

Expand Down
1 change: 0 additions & 1 deletion e2e/tests/image.magic-wand.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const {
hasKonvaPixelColorAtPoint,
setKonvaLayersOpacity,
serialize,
waitForImage,
} = require('./helpers');
const assert = require('assert');

Expand Down
3 changes: 1 addition & 2 deletions e2e/tests/image.shapes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const getConfigWithShape = (shape, props = '') => `
<${shape} ${props} name="tag" toName="img" />
</View>`;

const IMAGE =
'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/images/nick-owuor-astro-nic-visuals-wDifg5xc9Z4-unsplash.jpg';
const IMAGE = 'https://data.heartex.net/open-images/train_0/mini/0030019819f25b28.jpg';

// precalculated image size on the screen; may change because of different reasons
const WIDTH = 706;
Expand Down
7 changes: 3 additions & 4 deletions e2e/tests/image.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ const annotationWithPerRegion = {
result: [annotationMoonwalker.result[0], createRegion('answer', 'textarea', { text: ['blah'] })],
};

const image =
'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/images/nick-owuor-astro-nic-visuals-wDifg5xc9Z4-unsplash.jpg';
const image = 'https://data.heartex.net/open-images/train_0/mini/0030019819f25b28.jpg';

Scenario('Check Rect region for Image', async function({ I, AtImageView, AtSidebar }) {
const params = {
Expand Down Expand Up @@ -148,10 +147,10 @@ Scenario('Image with perRegion tags', async function({ I, AtImageView, AtSidebar
assert.deepStrictEqual(result[0].value.rectanglelabels, ['Moonwalker']);
});

const outOfBoundsFFs = new DataTable(['FF_DEV_3793'])
const outOfBoundsFFs = new DataTable(['FF_DEV_3793']);

outOfBoundsFFs.add([true]);
outOfBoundsFFs.add([false])
outOfBoundsFFs.add([false]);

Data(outOfBoundsFFs)
.Scenario('Can\'t create rectangles outside of canvas', async ({
Expand Down
Loading