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
Feature("Repeater paginate and scroll");
 
const data = {
  images: [
    {
      url: "https://htx-pub.s3.amazonaws.com/demo/images/demo_stock_purchase_agreement/0001.jpg",
    },
    {
      url: "https://htx-pub.s3.amazonaws.com/demo/images/demo_stock_purchase_agreement/0002.jpg",
    },
    {
      url: "https://htx-pub.s3.amazonaws.com/demo/images/demo_stock_purchase_agreement/0003.jpg",
    },
  ],
};
 
const configPagination = `
  <View>
    <Repeater on="$images" indexFlag="{{idx}}" mode="pagination" >
      <Image name="page_{{idx}}" value="$images[{{idx}}].url"/>
      <RectangleLabels name="labels_{{idx}}" toName="page_{{idx}}">
        <Label value="Document Title" />
        <Label value="Document Date" />
        <Label value="Document Author" background="yellow"/>
      </RectangleLabels>
    </Repeater>
  </View>
`;
 
const configScroll = `
  <View>
    <Repeater on="$images" indexFlag="{{idx}}" >
      <Image name="page_{{idx}}" value="$images[{{idx}}].url"/>
      <RectangleLabels name="labels_{{idx}}" toName="page_{{idx}}">
        <Label value="Document Title" />
        <Label value="Document Date" />
        <Label value="Document Author" background="yellow"/>
      </RectangleLabels>
    </Repeater>
  </View>
`;
 
const annotations = [
  {
    id: 38,
    result: [
      {
        id: "Eg3_P8-ZRu",
        type: "rectanglelabels",
        value: {
          x: 8.247422680412368,
          y: 54.22647527910686,
          width: 75.46391752577318,
          height: 9.090909090909092,
          rotation: 0,
          rectanglelabels: ["Document Date"],
        },
        page: 1,
        origin: "manual",
        to_name: "page_0",
        from_name: "labels_0",
        image_rotation: 0,
        original_width: 800,
        original_height: 1035,
      },
      {
        id: "yd33DCnE52",
        type: "rectanglelabels",
        value: {
          x: 22.379603399433428,
          y: 70.31044654069684,
          width: 20.396600566572232,
          height: 22.560672877544462,
          rotation: 0,
          rectanglelabels: ["Document Title"],
        },
        page: 3,
        origin: "manual",
        to_name: "page_2",
        from_name: "labels_2",
        image_rotation: 0,
        original_width: 600,
        original_height: 776,
      },
      {
        id: "7qxBZWOXXG",
        type: "rectanglelabels",
        value: {
          x: 33.711048158640224,
          y: 60.01577056744838,
          width: 23.229461756373937,
          height: 7.447212406179728,
          rotation: 0,
          rectanglelabels: ["Document Author"],
        },
        page: 2,
        origin: "manual",
        to_name: "page_1",
        from_name: "labels_1",
        image_rotation: 0,
        original_width: 600,
        original_height: 776,
      },
    ],
  },
];
 
const checkScrollToSelectedPersists = (I, label, outliner) => {
  I.click(locate(`.lsf-${outliner ? "outliner" : "region"}-item__title *`).withText(label));
  I.waitForVisible(locate(".lsf-label_selected").withText(label));
};
 
const checkPaginateToSelectedPersists = (I, label, page, outliner) => {
  checkScrollToSelectedPersists(I, label, outliner);
  I.seeElement(locate(".lsf-pagination__page-indicator").withText(`${page}`));
};
 
const checkPaginationButtons = (I) => {
  I.click(locate(".lsf-pagination__btn_arrow-left-double"));
  I.seeElement(locate(".lsf-pagination__page-indicator").withText("1"));
 
  I.click(locate(".lsf-pagination__btn_arrow-right"));
  I.seeElement(locate(".lsf-pagination__page-indicator").withText("2"));
 
  I.click(locate(".lsf-pagination__btn_arrow-right"));
  I.seeElement(locate(".lsf-pagination__page-indicator").withText("3"));
};
 
const checkSubmit = (I) => {
  I.click('[aria-label="Annotations List Toggle"]');
  I.click('[aria-label="Create Annotation"]');
  I.submitAnnotation();
  I.seeAnnotationSubmitted();
};
 
Scenario("Outliner Regions will paginate view window on region click and page advance", async ({ I, LabelStudio }) => {
  const params = { config: configPagination, annotations, data };
 
  I.amOnPage("/");
  LabelStudio.init(params);
 
  annotations[0].result.forEach((result) => {
    const label = result.value?.rectanglelabels[0];
 
    checkPaginateToSelectedPersists(I, label, result.page, true);
  });
 
  checkPaginationButtons(I);
  checkSubmit(I);
});
 
Scenario("Outliner Regions will scroll view window on region click", async ({ I, LabelStudio }) => {
  const params = { config: configScroll, annotations, data };
 
  I.amOnPage("/");
  LabelStudio.init(params);
 
  annotations[0].result.forEach((result) => {
    const label = result.value?.rectanglelabels[0];
 
    checkScrollToSelectedPersists(I, label, true);
  });
  checkSubmit(I);
});