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
import { LabelStudio, Relations } from "@humansignal/frontend-test/helpers/LSF";
import { CREATE_RELATION_MODE, LINK_COMMENT_MODE } from "../../../../src/stores/Annotation/LinkingModes";
import { simpleTextConfig, simpleTextData, simpleTextResult } from "../../data/linked_modes/to_comments";
 
describe("Linking modes: To comments", () => {
  it("should link region to comments", () => {
    const comment = {
      setRegionLink: cy.stub().as("setRegionLink"),
    };
    LabelStudio.params().config(simpleTextConfig).data(simpleTextData).withResult(simpleTextResult).init();
    LabelStudio.waitForObjectsReady();
 
    // @todo: implement real world scenario after the feature is implemented
    cy.window().then((win) => {
      win.Htx.annotationStore.selected.startLinkingMode(LINK_COMMENT_MODE, comment);
      const region = win.Htx.annotationStore.selected.regionStore.regions[0];
      win.Htx.annotationStore.selected.addLinkedRegion(region);
      win.Htx.annotationStore.selected.stopLinkingMode();
      cy.get("@setRegionLink").should("be.calledWith", region);
    });
  });
 
  it("should activate only one mode at a time", () => {
    const comment = {
      setRegionLink: cy.stub().as("setRegionLink"),
    };
    LabelStudio.params().config(simpleTextConfig).data(simpleTextData).withResult(simpleTextResult).init();
    LabelStudio.waitForObjectsReady();
 
    // @todo: implement real world scenario after the feature is implemented
    cy.window().then((win) => {
      win.Htx.annotationStore.selected.startLinkingMode(CREATE_RELATION_MODE, comment);
      win.Htx.annotationStore.selected.startLinkingMode(LINK_COMMENT_MODE, comment);
      const region = win.Htx.annotationStore.selected.regionStore.regions[0];
      win.Htx.annotationStore.selected.addLinkedRegion(region);
      win.Htx.annotationStore.selected.stopLinkingMode();
      cy.get("@setRegionLink").should("be.calledOnce");
      Relations.hasRelations(0);
    });
  });
});