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
import { ImageView, LabelStudio, Sidebar } from "@humansignal/frontend-test/helpers/LSF";
import { image, imageToolsConfig } from "../../data/image_segmentation/ctrl";
 
describe("Image Segmentation - Drawing with ctrl pressed", () => {
  it("should add region to selection when something selected - Rectangle", () => {
    LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init();
 
    ImageView.waitForImage();
    ImageView.selectRectangleToolByButton();
    cy.log("Prepare 2 rectangles");
    ImageView.drawRectRelative(0.1, 0.1, 0.4, 0.8);
    ImageView.drawRectRelative(0.55, 0.1, 0.4, 0.8);
    cy.log("Select first rectangle");
    ImageView.clickAtRelative(0.3, 0.3);
    cy.log("Add second rectangle to selection with ctrl pressed");
    ImageView.clickAtRelative(0.7, 0.3, { metaKey: true });
    Sidebar.hasSelectedRegions(2);
  });
 
  it("should add region to selection when something selected - Ellipse", () => {
    LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init();
 
    ImageView.waitForImage();
    ImageView.selectEllipseToolByButton();
    cy.log("Prepare 2 ellipses");
    ImageView.drawRectRelative(0.25, 0.5, 0.2, 0.4);
    ImageView.drawRectRelative(0.75, 0.5, 0.2, 0.4);
    cy.log("Select first ellipse");
    ImageView.clickAtRelative(0.25, 0.5);
    cy.log("Add second ellipse to selection with ctrl pressed");
    ImageView.clickAtRelative(0.75, 0.5, { metaKey: true });
    Sidebar.hasSelectedRegions(2);
  });
 
  it("should add region to selection when something selected - Polygon", () => {
    LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init();
 
    ImageView.waitForImage();
    ImageView.selectPolygonToolByButton();
    cy.log("Prepare 2 polygons");
    ImageView.drawPolygonRelative(
      [
        [0.1, 0.1],
        [0.4, 0.1],
        [0.25, 0.9],
      ],
      true,
    );
    ImageView.drawPolygonRelative(
      [
        [0.6, 0.1],
        [0.9, 0.1],
        [0.75, 0.9],
      ],
      true,
    );
    cy.log("Select first polygon");
    ImageView.clickAtRelative(0.25, 0.5);
    cy.log("Add second polygon to selection with ctrl pressed");
    ImageView.clickAtRelative(0.75, 0.5, { metaKey: true });
    Sidebar.hasSelectedRegions(2);
  });
 
  it("should draw region through other region - Rectangle", () => {
    LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init();
 
    ImageView.waitForImage();
    ImageView.selectRectangleToolByButton();
    cy.log("Prepare 2 rectangles");
    ImageView.drawRectRelative(0.1, 0.1, 0.4, 0.8);
    ImageView.drawRectRelative(0.55, 0.1, 0.4, 0.8);
    cy.log("Draw rectangle through other rectangle with ctrl pressed");
    ImageView.drawRectRelative(0.3, 0.3, 0.4, 0.4, { metaKey: true });
    Sidebar.hasSelectedRegions(0);
    Sidebar.hasRegions(3);
  });
 
  it("should draw region through other region - Ellipse", () => {
    LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init();
 
    ImageView.waitForImage();
    ImageView.selectEllipseToolByButton();
    cy.log("Prepare 2 ellipses");
    ImageView.drawRectRelative(0.25, 0.5, 0.2, 0.4);
    ImageView.drawRectRelative(0.75, 0.5, 0.2, 0.4);
    cy.log("Draw ellipse through other ellipse with ctrl pressed");
    ImageView.drawRectRelative(0.25, 0.5, 0.4, 0.4, { metaKey: true });
    Sidebar.hasSelectedRegions(0);
    Sidebar.hasRegions(3);
  });
 
  it("should draw region through other region - Polygon", () => {
    LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init();
 
    ImageView.waitForImage();
    ImageView.selectPolygonToolByButton();
    cy.log("Prepare 2 polygons");
    ImageView.drawPolygonRelative(
      [
        [0.1, 0.1],
        [0.4, 0.1],
        [0.25, 0.9],
      ],
      true,
    );
    ImageView.drawPolygonRelative(
      [
        [0.6, 0.1],
        [0.9, 0.1],
        [0.75, 0.9],
      ],
      true,
    );
    cy.log("Draw polygon through other polygon with ctrl pressed");
    ImageView.drawPolygonRelative(
      [
        [0.25, 0.2],
        [0.75, 0.2],
        [0.75, 0.3],
        [0.25, 0.3],
      ],
      true,
      { metaKey: true },
    );
    Sidebar.hasSelectedRegions(0);
    Sidebar.hasRegions(3);
  });
 
  it("should add region to selection when something selected - MoveTool", () => {
    LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init();
 
    ImageView.waitForImage();
    ImageView.selectRectangleToolByButton();
    cy.log("Prepare 2 rectangles");
    ImageView.drawRectRelative(0.1, 0.1, 0.4, 0.8);
    ImageView.drawRectRelative(0.55, 0.1, 0.4, 0.8);
    cy.log("Switch to MoveTool");
    ImageView.selectMoveToolByButton();
    cy.log("Select first rectangle");
    ImageView.clickAtRelative(0.3, 0.3);
    cy.log("Add second rectangle to selection with ctrl pressed");
    ImageView.clickAtRelative(0.7, 0.3, { metaKey: true });
    Sidebar.hasSelectedRegions(2);
  });
 
  it("should add region to selection from scratch - MoveTool", () => {
    LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init();
 
    ImageView.waitForImage();
    ImageView.selectRectangleToolByButton();
    cy.log("Prepare 2 rectangles");
    ImageView.drawRectRelative(0.1, 0.1, 0.4, 0.8);
    ImageView.drawRectRelative(0.55, 0.1, 0.4, 0.8);
    cy.log("Switch to MoveTool");
    ImageView.selectMoveToolByButton();
    cy.log("Select first rectangle");
    ImageView.clickAtRelative(0.3, 0.3, { metaKey: true });
    cy.log("Add second rectangle to selection with ctrl pressed");
    ImageView.clickAtRelative(0.7, 0.3, { metaKey: true });
    Sidebar.hasSelectedRegions(2);
  });
});