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
const assert = require("assert");
 
Feature("Dynamic choices").tag("@regress");
 
Scenario("Hotkeys for dynamic choices", async ({ I, LabelStudio }) => {
  const params = {
    config: `
<View>
  <Text name="text" value="$text"></Text>
  <Choices name="choices" toName="text" allownested="true" choice="multiple"  value="$choices">
    <Choice value="Static option" hotkey="s" />
  </Choices>
</View>`,
    data: {
      text: "Some text",
      choices: [
        {
          value: "Header 1",
          children: [
            {
              value: "Option 1.1",
            },
            {
              value: "Option 1.2",
            },
          ],
        },
        {
          value: "Header 2",
          children: [
            {
              value: "Option 2.1",
            },
            {
              value: "Option 2.2",
            },
            {
              value: "Option 2.3",
              hotkey: "q",
            },
          ],
        },
      ],
    },
    annotations: [
      {
        id: "test",
        result: [],
      },
    ],
  };
 
  I.amOnPage("/");
 
  LabelStudio.init(params);
 
  I.see("Header 1");
  I.see("Option 1.1");
  I.see("Header 2");
  I.see("Option 2.2");
 
  I.say("Select some choices by pressing hotkeys");
 
  I.pressKey("1");
  I.pressKey("q");
  I.pressKey("s");
 
  I.say("Check the result");
 
  I.seeElement(".ant-checkbox-checked [name='Header 1']");
  I.seeElement(".ant-checkbox-indeterminate [name='Header 2']");
  I.seeElement(".ant-checkbox-checked [name='Option 1.1']");
  I.seeElement(".ant-checkbox-checked [name='Option 1.2']");
  I.seeElement(".ant-checkbox-checked [name='Option 2.3']");
  I.seeElement(".ant-checkbox-checked [name='Static option']");
 
  const result = await LabelStudio.serialize();
 
  assert.deepStrictEqual(result.length, 1);
  assert.deepStrictEqual(result[0].value.choices, [
    ["Static option"],
    ["Header 1"],
    ["Header 1", "Option 1.1"],
    ["Header 1", "Option 1.2"],
    ["Header 2", "Option 2.3"],
  ]);
});