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
const assert = require("assert");
 
Feature("Preselected choices");
 
Scenario("Make a duplicate of annotation with preselected choices", async ({ I, LabelStudio, AtTopbar }) => {
  const params = {
    config: `
<View>
  <Text name="text" value="$text"></Text>
  <Choices name="choices" toName="text">
    <Choice value="Option 1" selected="true"/>
    <Choice value="Option 2" />
  </Choices>
</View>`,
    data: {
      text: "Some text",
    },
    annotations: [
      {
        id: "test",
        result: [
          {
            from_name: "choices",
            id: "mDp7Hpbw6_",
            origin: "manual",
            to_name: "text",
            type: "choices",
            value: {
              choices: ["Option 2"],
            },
          },
        ],
      },
    ],
  };
 
  I.amOnPage("/");
  LabelStudio.init(params);
  // Try to create copy of current annotation
  AtTopbar.click('[aria-label="Copy Annotation"]');
  const duplicateResult = await LabelStudio.serialize();
 
  // Make sure there are no results other than the copied ones
  assert.deepStrictEqual(duplicateResult.length, 1);
  assert.deepStrictEqual(duplicateResult[0].value.choices, ["Option 2"]);
 
  // Create new annotation
  I.click('[aria-label="Annotations List Toggle"]');
  I.click('[aria-label="Create Annotation"]');
  const annotationWithPresetValues = await LabelStudio.serialize();
 
  // Check that there is only the result come from selecting by default
  assert.deepStrictEqual(annotationWithPresetValues.length, 1);
  assert.deepStrictEqual(annotationWithPresetValues[0].value.choices, ["Option 1"]);
});
 
Scenario("Make a duplicate of empty annotation with preselected choices", async ({ I, LabelStudio, AtTopbar }) => {
  const params = {
    config: `
<View>
  <Text name="text" value="$text"></Text>
  <Choices name="choices" toName="text">
    <Choice value="Option 1" selected="true"/>
    <Choice value="Option 2" />
  </Choices>
</View>`,
    data: {
      text: "Some text",
    },
    annotations: [
      {
        id: "test",
        result: [],
      },
    ],
  };
 
  I.amOnPage("/");
  LabelStudio.init(params);
  // Try to create copy of current annotation
  AtTopbar.click('[aria-label="Copy Annotation"]');
  const duplicateResult = await LabelStudio.serialize();
 
  // Make sure there are no preselected results
  assert.deepStrictEqual(duplicateResult.length, 0);
 
  // Create new annotation
  I.click('[aria-label="Annotations List Toggle"]');
  I.click('[aria-label="Create Annotation"]');
  const annotationWithPresetValues = await LabelStudio.serialize();
 
  // Check that there is only the result come from selecting by default
  assert.deepStrictEqual(annotationWithPresetValues.length, 1);
  assert.deepStrictEqual(annotationWithPresetValues[0].value.choices, ["Option 1"]);
});