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
import { Labels, LabelStudio, Relations, Sidebar } from "@humansignal/frontend-test/helpers/LSF";
import { FF_DEV_3873 } from "../../../../src/utils/feature-flags";
import {
  labelStudio_settings,
  panelState,
  resultWithRelations,
  simpleConfig,
  simpleData,
} from "../../data/outliner/region-index";
import { RichText } from "@humansignal/frontend-test/helpers/LSF/RichText";
import { Hotkeys } from "@humansignal/frontend-test/helpers/LSF/Hotkeys";
 
describe("Region Index", () => {
  beforeEach(() => {
    LabelStudio.addFeatureFlagsOnPageLoad({
      [FF_DEV_3873]: true,
    });
  });
  it("should be visible at the outliner", () => {
    LabelStudio.params().config(simpleConfig).data(simpleData).withResult(resultWithRelations).init();
    LabelStudio.waitForObjectsReady();
 
    Sidebar.findByRegionIndex(1).should("contain", "Label 1");
    Sidebar.findByRegionIndex(3).should("contain", "Label 3");
  });
 
  it("should depends on the order of the regions", () => {
    LabelStudio.params().config(simpleConfig).data(simpleData).withResult(resultWithRelations).init();
    LabelStudio.waitForObjectsReady();
 
    Sidebar.toggleOrderByTime();
    Sidebar.findByRegionIndex(1).should("contain", "Label 3");
    Sidebar.findByRegionIndex(3).should("contain", "Label 1");
  });
 
  it("should affect the labels on region on changing order", () => {
    LabelStudio.params()
      .config(simpleConfig)
      .data(simpleData)
      .withResult(resultWithRelations)
      .withLocalStorageItem("labelStudio:settings", labelStudio_settings)
      .init();
 
    LabelStudio.waitForObjectsReady();
 
    Sidebar.toggleOrderByTime();
 
    RichText.hasRegionWithLabel("1:Label 3");
    RichText.hasRegionWithLabel("2:Label 2");
    RichText.hasRegionWithLabel("3:Label 1");
  });
 
  it("should be displayed in region's label", () => {
    LabelStudio.params()
      .config(simpleConfig)
      .data(simpleData)
      .withResult(resultWithRelations)
      .localStorageItems({
        "labelStudio:settings": labelStudio_settings,
      })
      .init();
 
    RichText.hasRegionWithLabel("1:Label 1");
    RichText.hasRegionWithLabel("2:Label 2");
    RichText.hasRegionWithLabel("3:Label 3");
  });
 
  it("should not depend on the visibility of the region panel", () => {
    LabelStudio.params()
      .config(simpleConfig)
      .data(simpleData)
      .withResult(resultWithRelations)
      .localStorageItems({
        panelState,
        "labelStudio:settings": labelStudio_settings,
      })
      .init();
    LabelStudio.waitForObjectsReady();
 
    RichText.hasRegionWithLabel("1:Label 1");
    RichText.hasRegionWithLabel("2:Label 2");
    RichText.hasRegionWithLabel("3:Label 3");
  });
 
  it("should be displayed on relations panel", () => {
    LabelStudio.params()
      .config(simpleConfig)
      .data(simpleData)
      .withResult(resultWithRelations)
      .localStorageItems({
        panelState,
        "labelStudio:settings": labelStudio_settings,
      })
      .init();
    LabelStudio.waitForObjectsReady();
 
    Relations.relationRegions.eq(0).contains(".lsf-detailed-region__index", "1").should("exist");
    Relations.relationRegions.eq(1).contains(".lsf-detailed-region__index", "3").should("exist");
  });
 
  it("should be consistent on region delete / create", () => {
    LabelStudio.params()
      .config(simpleConfig)
      .data(simpleData)
      .withResult(resultWithRelations)
      .localStorageItems({
        panelState,
        "labelStudio:settings": labelStudio_settings,
      })
      .init();
    LabelStudio.waitForObjectsReady();
 
    RichText.hasRegionWithLabel("1:Label 1");
    RichText.hasRegionWithLabel("2:Label 2");
    RichText.hasRegionWithLabel("3:Label 3");
 
    RichText.findRegionWithLabel("2:Label 2").trigger("click");
    Hotkeys.deleteRegion();
    RichText.hasRegionWithLabel("1:Label 1");
    RichText.hasRegionWithLabel("2:Label 3");
 
    Labels.select("Label 2");
    RichText.selectText("is");
    RichText.hasRegionWithLabel("3:Label 2");
  });
 
  it("should be consistent on region delete / create with full list affected by change", () => {
    LabelStudio.params()
      .config(simpleConfig)
      .data(simpleData)
      .withResult(resultWithRelations)
      .localStorageItems({
        panelState,
        "labelStudio:settings": labelStudio_settings,
        "outliner:sort": "date",
        "outliner:sort-direction": "desc",
      })
      .init();
    LabelStudio.waitForObjectsReady();
 
    RichText.hasRegionWithLabel("3:Label 1");
    RichText.hasRegionWithLabel("2:Label 2");
    RichText.hasRegionWithLabel("1:Label 3");
 
    RichText.findRegionWithLabel("2:Label 2").trigger("click");
    Hotkeys.deleteRegion();
    RichText.hasRegionWithLabel("2:Label 1");
    RichText.hasRegionWithLabel("1:Label 3");
 
    Labels.select("Label 2");
    RichText.selectText("is");
 
    RichText.hasRegionWithLabel("3:Label 1");
    RichText.hasRegionWithLabel("2:Label 3");
    RichText.hasRegionWithLabel("1:Label 2");
  });
 
  it("should work with history traveling", () => {
    LabelStudio.params()
      .config(simpleConfig)
      .data(simpleData)
      .withResult(resultWithRelations)
      .localStorageItems({
        "labelStudio:settings": labelStudio_settings,
      })
      .init();
    LabelStudio.waitForObjectsReady();
 
    RichText.findRegionWithLabel("2:Label 2").trigger("click");
    Hotkeys.deleteRegion();
 
    cy.wait(1);
    Hotkeys.undo();
    cy.wait(1);
    Hotkeys.redo();
  });
});