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
import {
  AudioView,
  Choices,
  LabelStudio,
  Textarea,
  Number,
  ImageView,
  Paragraphs,
  Labels,
  TimeSeries,
  DateTime,
  VideoView,
  Table,
  Taxonomy,
  Ranker,
  Collapse,
} from "@humansignal/frontend-test/helpers/LSF";
import { RichText } from "@humansignal/frontend-test/helpers/LSF/RichText";
import { FF_BULK_ANNOTATION, FF_DEV_3873, FF_LSDV_4583 } from "../../../../src/utils/feature-flags";
import {
  allTagsConfig,
  allTagsSampleData,
  dynamicConfig,
  dynamicData,
  perItemMIGConfig,
  perRegionConfig,
  simpleMIGData,
} from "../../data/bulk_mode/smoke";
 
beforeEach(() => {
  LabelStudio.addFeatureFlagsOnPageLoad({
    [FF_BULK_ANNOTATION]: true,
  });
});
 
for (const isFFDev3873 of [true, false]) {
  const ffModePostfix = isFFDev3873 ? "(new ui)" : "(old ui)";
  describe(`Bulk mode ${ffModePostfix}`, () => {
    beforeEach(() => {
      LabelStudio.addFeatureFlagsOnPageLoad({
        [FF_DEV_3873]: isFFDev3873,
      });
    });
    it("should show per object classifications", () => {
      LabelStudio.params()
        .config(allTagsConfig)
        .withInterface("annotation:bulk")
        .data(allTagsSampleData)
        .withResult([])
        .init();
 
      cy.log("Check that all tags visibility states are correct");
      AudioView.root.should("not.exist");
      Textarea.root.should("be.visible");
      Choices.root.should("be.visible");
      Choices.findChoice("choices_1").should("be.visible");
      Choices.findChoice("choices_2").should("be.visible");
      Number.root.should("be.visible");
      Labels.root.should("not.exist");
      ImageView.image.should("not.exist");
      Paragraphs.root.should("not.exist");
      RichText.root.should("not.exist");
      TimeSeries.root.should("not.exist");
      DateTime.root.should("be.visible");
      VideoView.root.should("not.exist");
      Table.root.should("not.exist");
      Taxonomy.root.should("be.visible");
      Ranker.root.should("not.exist");
 
      Collapse.root.should("be.visible");
      Collapse.findPanel("First panel").should("be.visible");
      Collapse.findPanel("Another panel").should("be.visible");
      // for now, it looks like that it's better to display all panels that have visible children
      Collapse.getPanelByIdx(2).should("be.visible");
      Collapse.getPanelByIdx(3).should("not.exist");
 
      cy.log("fill everything we can");
      Textarea.type("some text");
      Choices.findChoice("choices_1").click();
      Number.type("42");
      DateTime.type("2021-01-01");
      Taxonomy.open();
      Taxonomy.findItem("taxonomy_1").click();
      Taxonomy.close();
 
      cy.log("get serialized data");
      LabelStudio.serialize().then((results) => {
        expect(results[0]?.value.choices).to.be.deep.equal(["choices_1"]);
        expect(results[1]?.value.number).to.be.equal(42);
        expect(results[2]?.value.datetime).to.be.equal("2021-01-01T00:00");
        expect(results[3]?.value.taxonomy).to.be.deep.equal([["taxonomy_1"]]);
      });
    });
 
    it("should not show per-region classifications", () => {
      LabelStudio.params()
        .config(perRegionConfig)
        .withInterface("annotation:bulk")
        .data(allTagsSampleData)
        .withResult([])
        .init();
 
      cy.log("Check that there is nothing to render");
      cy.get(".lsf-main-view__annotation div:eq(0)").should("be.empty");
    });
 
    it("should not show per-item classifications", () => {
      LabelStudio.addFeatureFlagsOnPageLoad({
        [FF_LSDV_4583]: true,
      });
 
      LabelStudio.params()
        .config(perItemMIGConfig)
        .withInterface("annotation:bulk")
        .data(simpleMIGData)
        .withResult([])
        .init();
 
      cy.log("Check that there is nothing to render");
      cy.get(".lsf-main-view__annotation div:eq(0)").should("be.empty");
    });
 
    it("should not display dynamic things", () => {
      LabelStudio.params()
        .config(dynamicConfig)
        .withInterface("annotation:bulk")
        .data(dynamicData)
        .withResult([])
        .init();
 
      cy.log("Check that there is nothing to render");
      cy.get(".lsf-main-view__annotation div:eq(0)").should("be.empty");
    });
 
    it("should hide panels and buttons not related to the bulk mode", () => {
      LabelStudio.params().config("<View></View>").withInterface("annotation:bulk").data({}).withResult([]).init();
 
      cy.get(".lsf-sidepanels").should("not.exist");
      cy.get(".lsf-sidepanels__wrapper").should("not.exist");
 
      cy.get(".lsf-current-task").should("not.exist");
      cy.get(`[aria-label="Compare all annotations"]`).should("not.exist");
      cy.get(`[aria-label="Create an annotation"]`).should("not.exist");
      cy.get(".lsf-annotations-carousel").should("not.exist");
      cy.get(".lsf-ground-truth").should("not.exist");
    });
  });
}