Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
Feature("MIG");
 
const assert = require("assert");
 
const rectConfig = `
  <View>
    <Image name="img" valueList="$images"/>
    <RectangleLabels name="tag" toName="img">
      <Label value="Planet"></Label>
      <Label value="Moonwalker" background="blue"></Label>
    </RectangleLabels>
  </View>
`;
 
const brushConfig = `
  <View>
    <Image name="img" valueList="$images"/>
    <BrushLabels name="tag" toName="img">
      <Label value="Planet"></Label>
      <Label value="Moonwalker" background="blue"></Label>
    </BrushLabels>
  </View>
`;
 
const data = {
  images: [
    "https://data.heartex.net/open-images/train_0/mini/0030019819f25b28.jpg",
    "https://data.heartex.net/open-images/train_0/mini/00155094b7acc33b.jpg",
    "https://data.heartex.net/open-images/train_0/mini/00133643bbf063a9.jpg",
    "https://data.heartex.net/open-images/train_0/mini/0061ec6e9576b520.jpg",
  ],
};
 
const result = [
  {
    original_width: 768,
    original_height: 576,
    image_rotation: 0,
    value: {
      x: 7.814060788954878,
      y: 42.05253910374108,
      width: 11.226011120078905,
      height: 10.491211550533542,
      rotation: 0,
      rectanglelabels: ["Planet"],
    },
    id: "SBHuSbuOoI",
    from_name: "tag",
    to_name: "img",
    type: "rectanglelabels",
    origin: "manual",
    item_index: 0,
  },
  {
    id: "spPCrj0omt",
    type: "rectanglelabels",
    value: {
      x: 40.237685381355924,
      y: 22.88135593220339,
      width: 7.878707627118645,
      height: 18.64406779661017,
      rotation: 0,
      rectanglelabels: ["Moonwalker"],
    },
    origin: "manual",
    to_name: "img",
    from_name: "tag",
    item_index: 1,
    image_rotation: 0,
    original_width: 768,
    original_height: 510,
  },
  {
    original_width: 768,
    original_height: 576,
    image_rotation: 0,
    value: {
      x: 37.190330463635505,
      y: 50.85521215886758,
      width: 15.008743610438549,
      height: 14.539802110423578,
      rotation: 0,
      rectanglelabels: ["Planet"],
    },
    id: "4SkI4GVN4u",
    from_name: "tag",
    to_name: "img",
    type: "rectanglelabels",
    origin: "manual",
    item_index: 0,
  },
];
 
Before(async ({ LabelStudio }) => {
  LabelStudio.setFeatureFlags({
    fflag_feat_front_lsdv_4583_multi_image_segmentation_short: true,
  });
});
 
Scenario("Image list rendering", async ({ I, LabelStudio, AtImageView }) => {
  const params = {
    config: rectConfig,
    data,
    annotations: [{ id: 1, result: [] }],
  };
 
  I.amOnPage("/");
  LabelStudio.init(params);
 
  LabelStudio.waitForObjectsReady();
  await AtImageView.lookForStage();
 
  I.seeElement(`img[src="${data.images[0]}"]`);
});
 
Scenario("Image list with page navigation", async ({ I, AtImageView, LabelStudio }) => {
  const params = {
    config: rectConfig,
    data,
    annotations: [{ id: 1, result: [] }],
  };
 
  const prevPageButton = locate(".lsf-pagination__btn.lsf-pagination__btn_arrow-left");
  const nextPageButton = locate(".lsf-pagination__btn.lsf-pagination__btn_arrow-right");
 
  I.amOnPage("/");
  LabelStudio.init(params);
 
  LabelStudio.waitForObjectsReady();
  await AtImageView.lookForStage();
 
  I.say("Loading first image");
  I.seeElement(`img[src="${data.images[0]}"]`);
 
  I.say("Pagination is visible");
  I.seeElement(".lsf-pagination");
 
  I.say("The number of pages is correct");
  I.see("1 of 4");
 
  I.say("Clicking on the next page");
  I.click(nextPageButton);
 
  I.say("Loading second image");
  I.seeElement(`img[src="${data.images[1]}"]`);
  I.see("2 of 4");
 
  I.say("Clicking on the previous page");
  I.click(prevPageButton);
  I.seeElement(`img[src="${data.images[0]}"]`);
  I.see("1 of 4");
});
 
Scenario("Image list with hotkey navigation", async ({ I, AtImageView, LabelStudio }) => {
  const params = {
    config: rectConfig,
    data,
    annotations: [{ id: 1, result: [] }],
  };
 
  I.amOnPage("/");
  LabelStudio.init(params);
 
  LabelStudio.waitForObjectsReady();
  await AtImageView.lookForStage();
 
  I.say("Loading first image");
  I.seeElement(`img[src="${data.images[0]}"]`);
 
  I.say("Pagination is visible");
  I.seeElement(".lsf-pagination");
 
  I.say("The number of pages is correct");
  I.see("1 of 4");
 
  await AtImageView.multiImageGoForwardWithHotkey();
 
  I.say("Loading second image");
  I.seeElement(`img[src="${data.images[1]}"]`);
  I.see("2 of 4");
 
  await AtImageView.multiImageGoBackwardWithHotkey();
  I.seeElement(`img[src="${data.images[0]}"]`);
  I.see("1 of 4");
});
 
Scenario("View All disables MIG pagination", async ({ I, AtImageView, LabelStudio }) => {
  const params = {
    config: rectConfig,
    data,
    annotations: [
      { id: 1, result: [] },
      { id: 2, result: [] },
    ],
    additionalInterfaces: ["annotations:view-all"],
  };
 
  const prevSelector = ".lsf-pagination__btn_arrow-left";
  const nextSelector = ".lsf-pagination__btn_arrow-right";
 
  // FFs for a proper interface with View All button
  LabelStudio.setFeatureFlags({
    fflag_feat_front_dev_3873_labeling_ui_improvements_short: true,
  });
 
  I.amOnPage("/");
  LabelStudio.init(params);
 
  LabelStudio.waitForObjectsReady();
  await AtImageView.lookForStage();
 
  I.say("Move to next page to have a changed state");
  I.click(locate(nextSelector));
  I.seeElement(`img[src="${data.images[1]}"]`);
  I.see("2 of 4");
 
  I.say("Enable View All mode");
  I.click('[aria-label="Compare all annotations"]');
 
  I.say("Navigation buttons should be disabled");
  I.seeElement(locate(`${nextSelector}[class$=disabled]`));
  I.seeElement(locate(`${prevSelector}[class$=disabled]`));
  I.see("2 of 4");
 
  I.say("Hotkeys for navigation should not work");
  await AtImageView.multiImageGoForwardWithHotkey();
  I.seeElement(`img[src="${data.images[1]}"]`);
  I.see("2 of 4");
 
  await AtImageView.multiImageGoBackwardWithHotkey();
  I.seeElement(`img[src="${data.images[1]}"]`);
  I.see("2 of 4");
});
 
Scenario(
  "Ensure that results are the same when exporting existing regions",
  async ({ I, AtImageView, LabelStudio }) => {
    const params = {
      config: rectConfig,
      data,
      annotations: [{ id: 1, result }],
    };
 
    I.amOnPage("/");
    LabelStudio.init(params);
 
    LabelStudio.waitForObjectsReady();
    await AtImageView.lookForStage();
 
    I.say("Result must be exactly the same as we're not modifying anything");
    await LabelStudio.resultsNotChanged(result);
  },
);
 
Scenario("Image list exports correct data", async ({ I, LabelStudio, AtImageView }) => {
  const params = {
    config: rectConfig,
    data,
    annotations: [{ id: 1, result }],
  };
 
  I.amOnPage("/");
  LabelStudio.init(params);
 
  LabelStudio.waitForObjectsReady();
  await AtImageView.lookForStage();
 
  AtImageView.multiImageGoForwardWithHotkey();
 
  LabelStudio.waitForObjectsReady();
  await AtImageView.lookForStage();
  I.seeElement(`img[src="${data.images[1]}"]`);
 
  await LabelStudio.resultsNotChanged(result);
});
 
Scenario("Regions are not changes when duplicating an annotation", async ({ I, LabelStudio, AtImageView }) => {
  const params = {
    config: rectConfig,
    data,
    annotations: [{ id: 1, result }],
  };
 
  I.amOnPage("/");
  LabelStudio.init(params);
 
  LabelStudio.waitForObjectsReady();
  await AtImageView.lookForStage();
 
  I.say("Attempting to duplicate an annotaion");
  I.click('[aria-label="Copy Annotation"]');
 
  LabelStudio.waitForObjectsReady();
  await AtImageView.lookForStage();
 
  I.say("Confirm that result is not changed");
  await LabelStudio.resultsNotChanged(result);
});
 
Scenario("No errors during brush export in MIG", async ({ I, LabelStudio, AtImageView, AtLabels, AtPanels }) => {
  const params = {
    config: brushConfig,
    data,
    annotations: [{ id: 1, result: [] }],
  };
 
  const brushRegionPoints = [
    [20, 20],
    [20, 40],
    [40, 40],
    [40, 20],
    [20, 20],
  ];
  const AtDetailsPanel = AtPanels.usePanel(AtPanels.PANEL.DETAILS);
 
  I.amOnPage("/");
  LabelStudio.init(params);
  AtDetailsPanel.collapsePanel();
 
  LabelStudio.waitForObjectsReady();
  await AtImageView.lookForStage();
 
  I.say("Create brush regions on the first image");
  AtLabels.clickLabel("Moonwalker");
  AtImageView.drawThroughPoints(brushRegionPoints);
 
  // @todo: We cannot use these hotkeys due to duplicating regions action used the same hotkey
  // await AtImageView.multiImageGoForwardWithHotkey();
  await AtImageView.multiImageGoForward();
 
  I.pressKey("u");
  I.say("Create brush regions on the second image");
  AtLabels.clickLabel("Planet");
  AtImageView.drawThroughPoints(brushRegionPoints);
 
  // Brush might not have a chance to finish whatewer it's
  // doing, so it's safer to wait a little before exporting it
  I.wait(2);
 
  const result = await LabelStudio.serialize();
 
  assert.equal(result.length, 2);
});