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

Commit 7b58096

Browse files
fix: DEV-3820: Universal readonly (#1053)
* Universal readonly * Tests * Cover every image example * Cover readonly annotations with tests (pt. 1) * Organize tests * Organize tests * Fix keypoints * Readonly regions tests * Audio and NER readonly results test * Roll back unnecessary change * Timeseries readonly region test * Fix brush region readonly * Fix region lock button * Remove excess logging * Fix detail lock button * Cleanup * Replace readonly mixin, remove excess attributes * Cleanup * fix e2e * fix e2e tests * fix e2e tests * fix e2e * fix e2e tests * fix e2e tests * fix e2e audio tests * fix e2e tests * Fix annotation become readonly when there's a readonly result * Fix selection tests failing * Remove unnecessary FF * Fix shortcut tests * Fix LabelStudio#init * Fix taxonomy tests --------- Co-authored-by: Julio Sgarbi <[email protected]>
1 parent 8044b18 commit 7b58096

File tree

158 files changed

+1903
-548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+1903
-548
lines changed

.eslintignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
webpack.*
2-
eslintrc.js
3-
*.styl
2+
*.styl

e2e/.eslintrc.js

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ module.exports = {
22
plugins: [
33
'codeceptjs',
44
],
5+
globals: {
6+
Htx: true,
7+
Feature: true,
8+
Scenario: true,
9+
Data: true,
10+
DataTable: true,
11+
locate: true,
12+
actor: true,
13+
inject: true,
14+
session: true,
15+
pause: true,
16+
},
517
rules: {
618
'codeceptjs/no-exclusive-tests': 'error',
719
'codeceptjs/no-skipped-tests': 'warn',

e2e/codecept.conf.js

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ module.exports.config = {
9090
screenshotOnFail: {
9191
enabled: true,
9292
},
93+
pauseOnFail: {},
9394
},
9495
require: ['ts-node/register'],
9596
};

e2e/examples/audio-regions.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ const data = {
2323
};
2424

2525
const result = [
26-
{
27-
from_name: 'choice',
28-
id: 'hIj6zg57SY',
29-
to_name: 'audio',
30-
type: 'choices',
31-
origin: 'manual',
32-
value: {
33-
choices: ['Lo-Fi'],
34-
},
35-
},
3626
{
3727
from_name: 'label',
3828
id: 'SsGrpVgy_C',
@@ -61,6 +51,16 @@ const result = [
6151
start: 55.747572792986325,
6252
},
6353
},
54+
{
55+
from_name: 'choice',
56+
id: 'hIj6zg57SY',
57+
to_name: 'audio',
58+
type: 'choices',
59+
origin: 'manual',
60+
value: {
61+
choices: ['Lo-Fi'],
62+
},
63+
},
6464
];
6565

6666
const title = 'Audio regions';

e2e/examples/classification.js

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
const config = `
2+
<View>
3+
<Text name="text" value="Hello"></Text>
4+
5+
<Number name="num" toName="text" min="1" max="10"/>
6+
<DateTime name="dt" toName="text" showDate="true" showTime="true"/>
7+
<TextArea name="txt" toName="text" editable="true"/>
8+
9+
<Choices name="choices" toName="text">
10+
<Choice value="Choice 1" background="#5b5"/>
11+
<Choice value="Choice 2" background="#55f"/>
12+
</Choices>
13+
14+
<Taxonomy name="taxonomy" toName="text">
15+
<Choice value="Choice 1" background="#5b5"/>
16+
<Choice value="Choice 2" background="#55f">
17+
<Choice value="Choice 2.1" background="#5b5"/>
18+
<Choice value="Choice 2.2" background="#55f"/>
19+
</Choice>
20+
</Taxonomy>
21+
</View>
22+
23+
`;
24+
25+
const data = {
26+
url: 'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/audio/barradeen-emotional.mp3',
27+
};
28+
29+
const result = [
30+
{
31+
'value': {
32+
'number': 2,
33+
},
34+
'id': 'W7wMwaYoa9',
35+
'from_name': 'num',
36+
'to_name': 'text',
37+
'type': 'number',
38+
'origin': 'manual',
39+
},
40+
{
41+
'value': {
42+
'datetime': '1991-05-22T09:17',
43+
},
44+
'id': 'xMvgTyP6e4',
45+
'from_name': 'dt',
46+
'to_name': 'text',
47+
'type': 'datetime',
48+
'origin': 'manual',
49+
},
50+
{
51+
'value': {
52+
'text': [
53+
'Hello',
54+
'World',
55+
],
56+
},
57+
'id': '0yMHFegGSK',
58+
'from_name': 'txt',
59+
'to_name': 'text',
60+
'type': 'textarea',
61+
'origin': 'manual',
62+
},
63+
{
64+
'value': {
65+
'choices': [
66+
'Choice 1',
67+
],
68+
},
69+
'id': 'dZyZ7Dx3uS',
70+
'from_name': 'choices',
71+
'to_name': 'text',
72+
'type': 'choices',
73+
'origin': 'manual',
74+
},
75+
{
76+
'value': {
77+
'taxonomy': [
78+
[
79+
'Choice 2',
80+
'Choice 2.1',
81+
],
82+
],
83+
},
84+
'id': '4IHbGrfa-P',
85+
'from_name': 'taxonomy',
86+
'to_name': 'text',
87+
'type': 'taxonomy',
88+
'origin': 'manual',
89+
},
90+
];
91+
92+
const title = 'Classification Mixed';
93+
94+
module.exports = { config, data, result, title };

e2e/examples/image-bboxes.js

+22-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const config = `
22
<View>
33
<Image name="img" value="$image"></Image>
44
<RectangleLabels name="tag" toName="img" fillOpacity="0.5" strokeWidth="5">
5-
<Label value="Planet"></Label>
6-
<Label value="Moonwalker" background="blue"></Label>
5+
<Label value="Hello"></Label>
6+
<Label value="World" background="blue"></Label>
77
</RectangleLabels>
88
</View>
99
`;
@@ -25,11 +25,29 @@ const result = [
2525
origin: 'manual',
2626
value: {
2727
height: 10.458911419423693,
28-
rectanglelabels: ['Moonwalker'],
28+
rectanglelabels: ['Hello'],
2929
rotation: 0,
3030
width: 12.4,
3131
x: 50.8,
32-
y: 5.869797225186766,
32+
y: 5.86979722518676,
33+
},
34+
},
35+
{
36+
from_name: 'tag',
37+
id: 'Dx_aB92ISN',
38+
image_rotation: 0,
39+
original_height: 2802,
40+
original_width: 2242,
41+
to_name: 'img',
42+
type: 'rectanglelabels',
43+
origin: 'manual',
44+
value: {
45+
height: 10.458911419423693,
46+
rectanglelabels: ['World'],
47+
rotation: 0,
48+
width: 12.4,
49+
x: 55.8,
50+
y: 15.86979722518676,
3351
},
3452
},
3553
];

e2e/examples/image-ellipses.js

+21-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const config = `
22
<View>
33
<Image name="img" value="$image"></Image>
44
<EllipseLabels name="tag" toName="img" fillOpacity="0.5" strokeWidth="3">
5-
<Label value="Planet" background="yellow"></Label>
6-
<Label value="Moonwalker" background="red"></Label>
5+
<Label value="Hello" background="yellow"></Label>
6+
<Label value="World" background="red"></Label>
77
</EllipseLabels>
88
<Choices name="choice" toName="img">
99
<Choice value="Space" />
@@ -30,12 +30,30 @@ const result = [
3030
value: {
3131
x: 50.4,
3232
y: 50.76307363927427,
33-
ellipselabels: ['Planet'],
33+
ellipselabels: ['Hello'],
3434
rotation: 0,
3535
radiusY: 10.672358591248665,
3636
radiusX: 13.333333333333334,
3737
},
3838
},
39+
{
40+
from_name: 'tag',
41+
id: 'CPnIaS1e8v',
42+
image_rotation: 0,
43+
original_height: 2802,
44+
original_width: 2242,
45+
to_name: 'img',
46+
type: 'ellipselabels',
47+
origin: 'manual',
48+
value: {
49+
x: 80,
50+
y: 80,
51+
ellipselabels: ['World'],
52+
rotation: 0,
53+
radiusY: 5,
54+
radiusX: 7,
55+
},
56+
},
3957
{
4058
from_name: 'choice',
4159
id: 'CkRNBWbSiK',

e2e/examples/image-keypoints.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ const result = [
2323
type: 'keypointlabels',
2424
origin: 'manual',
2525
value: {
26-
x: 49.6,
27-
y: 52.34042553191489,
28-
width: 0.6666666666666666,
26+
x: 49.60000000000001,
27+
y: 52.34042553191488,
28+
width: 0.6471078324314267,
2929
keypointlabels: ['Hello'],
3030
},
3131
},

e2e/examples/image-polygons.js

+30-7
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,42 @@ const result = [
1717
id: 'XSMXwwsaTa',
1818
from_name: 'tag',
1919
to_name: 'img',
20-
image_rotation: 0,
21-
original_height: 4542,
22-
original_width: 10109,
2320
type: 'polygonlabels',
2421
origin: 'manual',
22+
original_width: 10109,
23+
original_height: 4542,
24+
image_rotation: 0,
2525
value: {
2626
points: [
27-
[27.2, 41.24629080118693],
28-
[25.733333333333327, 70.62314540059347],
29-
[48.13333333333333, 62.61127596439168],
27+
[27.199999999999996, 41.246290801186944],
28+
[25.73333333333333, 70.62314540059347],
29+
[48.13333333333333, 62.61127596439169],
3030
[48.13333333333333, 32.93768545994065],
3131
],
32-
polygonlabels: ['Hello'],
32+
polygonlabels: [
33+
'Hello',
34+
],
35+
},
36+
},
37+
{
38+
id: 'DSm8iGlaA8',
39+
from_name: 'tag',
40+
to_name: 'img',
41+
type: 'polygonlabels',
42+
origin: 'manual',
43+
original_width: 10109,
44+
original_height: 4542,
45+
image_rotation: 0,
46+
value: {
47+
points: [
48+
[60.788381742738586, 76.21247113163972],
49+
[65.87136929460583, 52.19399538106235],
50+
[88.69294605809128, 60.508083140877595],
51+
[87.75933609958506, 87.06697459584295],
52+
],
53+
polygonlabels: [
54+
'World',
55+
],
3356
},
3457
},
3558
];

e2e/fragments/AtAudioView.js

+47-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* global inject */
21
const { I } = inject();
32
const assert = require('assert');
43

@@ -38,6 +37,7 @@ module.exports = {
3837
await I.executeScript(Helpers.waitForAudio);
3938
I.waitForInvisible(this._progressBarSelector);
4039
},
40+
4141
getCurrentAudioTime() {
4242
return I.executeScript(Helpers.getCurrentAudioTime);
4343
},
@@ -73,6 +73,52 @@ module.exports = {
7373
I.wait(1); // We gotta wait here because clicks on the canvas are not processed immediately
7474
},
7575

76+
async createRegion(tagName, start, length) {
77+
const { x, y, height } = await this.getWrapperPosition(tagName);
78+
79+
return I.dragAndDropMouse({
80+
x: x + start,
81+
y: y + height / 2,
82+
}, {
83+
x: x + start + length,
84+
y: y + height / 2,
85+
});
86+
},
87+
88+
async getWrapperPosition(tagName) {
89+
const wrapperPosition = await I.executeScript((tagName) => {
90+
const wrapper = Htx.annotationStore.selected.names.get(tagName)._ws.container;
91+
const bbox = wrapper.getBoundingClientRect();
92+
93+
return {
94+
x: bbox.x,
95+
y: bbox.y,
96+
width: bbox.width,
97+
height: bbox.height,
98+
};
99+
}, tagName);
100+
101+
return wrapperPosition;
102+
},
103+
104+
async moveRegion(regionId, offset = 30) {
105+
const regionPosition = await I.executeScript((regionId) => {
106+
const region = Htx.annotationStore.selected.regions.find(r => r.cleanId === regionId);
107+
const element = region.getRegionElement();
108+
const rect = element.getBoundingClientRect();
109+
110+
return {
111+
x: rect.x + rect.width / 2,
112+
y: rect.y + rect.height / 2,
113+
};
114+
}, regionId);
115+
116+
return I.dragAndDropMouse(regionPosition, {
117+
x: regionPosition.x + offset,
118+
y: regionPosition.y,
119+
});
120+
},
121+
76122
/**
77123
* Toggle the audio control menu. This houses the volume slider and mute button.
78124
*/

e2e/fragments/AtDetails.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* global inject, locate */
21
const { I } = inject();
32

43
module.exports = {

0 commit comments

Comments
 (0)