Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.
Open
Prev Previous commit
Next Next commit
Fix line endings
  • Loading branch information
hlomzik committed Mar 4, 2024
commit ca32461c0c45e9470c42372967ddfc881ba8f343
2,538 changes: 1,269 additions & 1,269 deletions e2e/tests/image.transformer.test.js

Large diffs are not rendered by default.

680 changes: 340 additions & 340 deletions e2e/tests/maxUsage.test.js

Large diffs are not rendered by default.

1,200 changes: 600 additions & 600 deletions e2e/tests/paragraphs-filter.test.js

Large diffs are not rendered by default.

206 changes: 103 additions & 103 deletions e2e/tests/regression-tests/brush-relations.test.js
Original file line number Diff line number Diff line change
@@ -1,103 +1,103 @@
Feature('Brush relations').tag('@regress');
const IMAGE = 'https://data.heartex.net/open-images/train_0/mini/0030019819f25b28.jpg';
const config = `<View>
<Image name="img" value="$image"></Image>
<BrushLabels name="tag" toName="img">
<Label value="Test" background="orange"></Label>
</BrushLabels>
</View>`;
function getPointAtSpiral(t, v , w) {
return { x: v * t * Math.cos(w * t), y: v * t * Math.sin(w * t) };
}
function generateSpiralPoints(x0, y0, R, v , w) {
let t = 1, x, y;
const points = [];
do {
({ x, y } = getPointAtSpiral(t++, v, w));
points.push([x + x0, y + y0]);
} while (x ** 2 + y ** 2 < R ** 2);
return points;
}
Scenario('Brush relations shouldn\'t crash everything', async ({ I, LabelStudio, AtImageView, AtSidebar }) => {
const params = {
config,
data: { image: IMAGE },
};
I.amOnPage('/');
LabelStudio.init(params);
AtImageView.waitForImage();
AtSidebar.seeRegions(0);
await AtImageView.lookForStage();
const canvasSize = await AtImageView.getCanvasSize();
const regionsCentralPoints = [];
// create 4 brush regions
for (let i = 0; i < 4; i++) {
// find start position
const x = canvasSize.width / 4 * ((i % 2) * 2 + 1);
const y = canvasSize.height / 4 * ((Math.floor(i / 2) % 2) * 2 + 1);
// generate points in a spiral
const points = generateSpiralPoints(x, y, Math.min(canvasSize.width / 6, canvasSize.height / 6), .4, Math.PI / 18);
// select the brush label
I.pressKey('1');
// draw a brush region
AtImageView.drawThroughPoints(points);
AtSidebar.seeRegions(i + 1);
// unselect the region
I.pressKey('u');
// save the central point
regionsCentralPoints.push({ x, y });
}
// Check that we can create a relation between the brush regions
{
// switch to the move tool for easy region selecting
I.pressKey('v');
// select the first region
AtImageView.clickAt(regionsCentralPoints[0].x, regionsCentralPoints[0].y);
// create relation to the second region
I.pressKey(['alt', 'r']);
AtImageView.clickAt(regionsCentralPoints[1].x, regionsCentralPoints[1].y);
// check that the relation has been created
AtSidebar.seeRelations(1);
}
// Check that relations work fine on a brush restoration (from rle)
{
// export annotation
const annotation = await LabelStudio.serialize();
// reload LS with that datalabel studio logo
LabelStudio.init({
...params,
annotations: [{ id: 'imported', result: annotation }],
});
AtImageView.waitForImage();
// Check that relation still exist
AtSidebar.seeRelations(1);
// Try to create new relation with restored regions
{
// switch to the move tool for easy region selecting
I.pressKey('v');
// select the third region
AtImageView.clickAt(regionsCentralPoints[2].x, regionsCentralPoints[2].y);
// create relation to the fourth region
I.pressKey(['alt', 'r']);
AtImageView.clickAt(regionsCentralPoints[3].x, regionsCentralPoints[3].y);
// check that the relation has been created
AtSidebar.seeRelations(2);
}
/// The potential errors should be caught by `errorsCollector` plugin
}
});
Feature('Brush relations').tag('@regress');

const IMAGE = 'https://data.heartex.net/open-images/train_0/mini/0030019819f25b28.jpg';

const config = `<View>
<Image name="img" value="$image"></Image>
<BrushLabels name="tag" toName="img">
<Label value="Test" background="orange"></Label>
</BrushLabels>
</View>`;

function getPointAtSpiral(t, v , w) {
return { x: v * t * Math.cos(w * t), y: v * t * Math.sin(w * t) };
}

function generateSpiralPoints(x0, y0, R, v , w) {
let t = 1, x, y;
const points = [];

do {
({ x, y } = getPointAtSpiral(t++, v, w));
points.push([x + x0, y + y0]);
} while (x ** 2 + y ** 2 < R ** 2);
return points;
}

Scenario('Brush relations shouldn\'t crash everything', async ({ I, LabelStudio, AtImageView, AtSidebar }) => {
const params = {
config,
data: { image: IMAGE },
};

I.amOnPage('/');
LabelStudio.init(params);
AtImageView.waitForImage();
AtSidebar.seeRegions(0);
await AtImageView.lookForStage();
const canvasSize = await AtImageView.getCanvasSize();
const regionsCentralPoints = [];

// create 4 brush regions
for (let i = 0; i < 4; i++) {
// find start position
const x = canvasSize.width / 4 * ((i % 2) * 2 + 1);
const y = canvasSize.height / 4 * ((Math.floor(i / 2) % 2) * 2 + 1);
// generate points in a spiral
const points = generateSpiralPoints(x, y, Math.min(canvasSize.width / 6, canvasSize.height / 6), .4, Math.PI / 18);

// select the brush label
I.pressKey('1');
// draw a brush region
AtImageView.drawThroughPoints(points);
AtSidebar.seeRegions(i + 1);
// unselect the region
I.pressKey('u');
// save the central point
regionsCentralPoints.push({ x, y });
}

// Check that we can create a relation between the brush regions
{
// switch to the move tool for easy region selecting
I.pressKey('v');
// select the first region
AtImageView.clickAt(regionsCentralPoints[0].x, regionsCentralPoints[0].y);
// create relation to the second region
I.pressKey(['alt', 'r']);
AtImageView.clickAt(regionsCentralPoints[1].x, regionsCentralPoints[1].y);
// check that the relation has been created
AtSidebar.seeRelations(1);
}

// Check that relations work fine on a brush restoration (from rle)
{
// export annotation
const annotation = await LabelStudio.serialize();

// reload LS with that datalabel studio logo
LabelStudio.init({
...params,
annotations: [{ id: 'imported', result: annotation }],
});

AtImageView.waitForImage();
// Check that relation still exist
AtSidebar.seeRelations(1);

// Try to create new relation with restored regions
{
// switch to the move tool for easy region selecting
I.pressKey('v');
// select the third region
AtImageView.clickAt(regionsCentralPoints[2].x, regionsCentralPoints[2].y);
// create relation to the fourth region
I.pressKey(['alt', 'r']);
AtImageView.clickAt(regionsCentralPoints[3].x, regionsCentralPoints[3].y);
// check that the relation has been created
AtSidebar.seeRelations(2);
}

/// The potential errors should be caught by `errorsCollector` plugin
}
});
160 changes: 80 additions & 80 deletions e2e/tests/regression-tests/dynamic-choices.test.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
const assert = require('assert');
Feature('Dynamic choices').tag('@regress');
Scenario('Hotkeys for dynamic choices', async ({ I, LabelStudio }) => {
const params = {
config: `
<View>
<Text name="text" value="$text"></Text>
<Choices name="choices" toName="text" allownested="true" choice="multiple" value="$choices">
<Choice value="Static option" hotkey="s" />
</Choices>
</View>`,
data: {
text: 'Some text',
choices: [
{
value: 'Header 1',
children: [
{
value: 'Option 1.1',
},
{
value: 'Option 1.2',
},
],
},
{
value: 'Header 2',
children: [
{
value: 'Option 2.1',
},
{
value: 'Option 2.2',
},
{
value: 'Option 2.3',
hotkey: 'q',
},
],
},
],
},
annotations: [{
id: 'test',
result: [],
}],
};
I.amOnPage('/');
LabelStudio.init(params);
I.see('Header 1');
I.see('Option 1.1');
I.see('Header 2');
I.see('Option 2.2');
I.say('Select some choices by pressing hotkeys');
I.pressKey('1');
I.pressKey('q');
I.pressKey('s');
I.say('Check the result');
I.seeElement('.ant-checkbox-checked [name=\'Header 1\']');
I.seeElement('.ant-checkbox-indeterminate [name=\'Header 2\']');
I.seeElement('.ant-checkbox-checked [name=\'Option 1.1\']');
I.seeElement('.ant-checkbox-checked [name=\'Option 1.2\']');
I.seeElement('.ant-checkbox-checked [name=\'Option 2.3\']');
I.seeElement('.ant-checkbox-checked [name=\'Static option\']');
const result = await LabelStudio.serialize();
assert.deepStrictEqual(result.length, 1);
assert.deepStrictEqual(result[0].value.choices, [['Static option'], ['Header 1'], ['Header 1', 'Option 1.1'], ['Header 1', 'Option 1.2'], ['Header 2', 'Option 2.3']]);
});
const assert = require('assert');

Feature('Dynamic choices').tag('@regress');

Scenario('Hotkeys for dynamic choices', async ({ I, LabelStudio }) => {
const params = {
config: `
<View>
<Text name="text" value="$text"></Text>
<Choices name="choices" toName="text" allownested="true" choice="multiple" value="$choices">
<Choice value="Static option" hotkey="s" />
</Choices>
</View>`,
data: {
text: 'Some text',
choices: [
{
value: 'Header 1',
children: [
{
value: 'Option 1.1',
},
{
value: 'Option 1.2',
},
],
},
{
value: 'Header 2',
children: [
{
value: 'Option 2.1',
},
{
value: 'Option 2.2',
},
{
value: 'Option 2.3',
hotkey: 'q',
},
],
},
],
},
annotations: [{
id: 'test',
result: [],
}],
};

I.amOnPage('/');

LabelStudio.init(params);

I.see('Header 1');
I.see('Option 1.1');
I.see('Header 2');
I.see('Option 2.2');

I.say('Select some choices by pressing hotkeys');

I.pressKey('1');
I.pressKey('q');
I.pressKey('s');

I.say('Check the result');

I.seeElement('.ant-checkbox-checked [name=\'Header 1\']');
I.seeElement('.ant-checkbox-indeterminate [name=\'Header 2\']');
I.seeElement('.ant-checkbox-checked [name=\'Option 1.1\']');
I.seeElement('.ant-checkbox-checked [name=\'Option 1.2\']');
I.seeElement('.ant-checkbox-checked [name=\'Option 2.3\']');
I.seeElement('.ant-checkbox-checked [name=\'Static option\']');

const result = await LabelStudio.serialize();

assert.deepStrictEqual(result.length, 1);
assert.deepStrictEqual(result[0].value.choices, [['Static option'], ['Header 1'], ['Header 1', 'Option 1.1'], ['Header 1', 'Option 1.2'], ['Header 2', 'Option 2.3']]);

});
Loading