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
import { LabelStudio, Sidebar, useTaxonomy } from "@humansignal/frontend-test/helpers/LSF";
import { RichText } from "@humansignal/frontend-test/helpers/LSF/RichText";
import { FF_TAXONOMY_LABELING } from "../../../../src/utils/feature-flags";
import { textWithDualTaxonomyConfig, simpleTextData } from "../../data/control_tags/text-with-dual-taxonomy";
 
describe("Control Tags - Text with Dual Taxonomy", () => {
  it("should select options from two taxonomies and create text region", () => {
    LabelStudio.addFeatureFlagsOnPageLoad({
      [FF_TAXONOMY_LABELING]: true,
    });
 
    cy.log("Initialize LabelStudio with text and dual taxonomy configuration");
    LabelStudio.params().config(textWithDualTaxonomyConfig).data(simpleTextData).withResult([]).init();
 
    LabelStudio.waitForObjectsReady();
    Sidebar.hasNoRegions();
 
    // Create taxonomy helpers for each taxonomy by index (first taxonomy, second taxonomy)
    const categoryTaxonomy = useTaxonomy("&:eq(0)");
    const sentimentTaxonomy = useTaxonomy("&:eq(1)");
 
    cy.log("Select first taxonomy option - Organization from category taxonomy");
    categoryTaxonomy.open();
    categoryTaxonomy.findItem("Organization").click();
    categoryTaxonomy.close();
 
    cy.log("Select second taxonomy option - Positive from sentiment taxonomy");
    sentimentTaxonomy.open();
    sentimentTaxonomy.findItem("Positive").click();
    sentimentTaxonomy.close();
 
    cy.log("Create text region with selected taxonomies");
    RichText.selectText("Apple Inc.");
 
    cy.log("Verify region was created");
    Sidebar.hasRegions(1);
    RichText.hasRegionWithText("Apple Inc.");
 
    cy.log("Verify serialization contains taxonomy results");
    LabelStudio.serialize().then((results: any[]) => {
      expect(results).to.have.length(2);
 
      // Check category taxonomy result
      const categoryResult = results.find((r: any) => r.from_name === "category");
      expect(categoryResult).to.exist;
      expect(categoryResult.type).to.eq("taxonomy");
      expect(categoryResult.value.taxonomy).to.deep.eq([["Organization"]]);
 
      // Check sentiment taxonomy result
      const sentimentResult = results.find((r: any) => r.from_name === "sentiment");
      expect(sentimentResult).to.exist;
      expect(sentimentResult.type).to.eq("taxonomy");
      expect(sentimentResult.value.taxonomy).to.deep.eq([["Positive"]]);
    });
  });
});