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
Feature("Table");
 
const config = `
<View>
    <Header value="Table with {key: value} pairs"/>
    <Table name="table" value="$text"/>
    <Choices name="choice" toName="table">
        <Choice value="Correct"/>
        <Choice value="Incorrect"/>
    </Choices>
</View>
`;
 
const data = {
  text: {
    cTest: 2,
    aaTest: 1,
    bbbTest: 3,
    ATest: 4,
  },
};
 
const params = { annotations: [{ id: "test", result: [] }], config, data };
 
Scenario("Check if the table is sorted", async ({ I, LabelStudio, AtTableView }) => {
  const _sortedArr = ["aaTest", "ATest", "bbbTest", "cTest"];
 
  I.amOnPage("/");
 
  LabelStudio.init(params);
 
  await AtTableView.seeKeys(_sortedArr);
});
 
Scenario("Render JSON array of objects with derived columns", async ({ I, LabelStudio }) => {
  const listConfig = `
<View>
    <Header value="Table from list of objects"/>
    <Table name="table" value="$rows"/>
    <Choices name="choice" toName="table">
        <Choice value="Correct"/>
        <Choice value="Incorrect"/>
    </Choices>
</View>
`;
 
  const listData = {
    rows: [
      { a: 1, b: 2 },
      { a: 3, b: 4, c: 5 },
    ],
  };
 
  const params = { annotations: [{ id: "test", result: [] }], config: listConfig, data: listData };
 
  I.amOnPage("/");
  LabelStudio.init(params);
  LabelStudio.waitForObjectsReady();
 
  I.see("a");
  I.see("b");
  I.see("c");
  I.dontSee("Name");
  I.dontSee("Value");
 
  I.see("1");
  I.see("2");
  I.see("3");
  I.see("4");
  I.see("5");
});
 
Scenario("Render JSON array of primitives as key/value table", async ({ I, LabelStudio }) => {
  const listKVConfig = `
<View>
    <Header value="Table from list of primitives"/>
    <Table name="table" value="$items"/>
    <Choices name="choice" toName="table">
        <Choice value="Correct"/>
        <Choice value="Incorrect"/>
    </Choices>
</View>
`;
 
  const listKVData = {
    items: ["alpha", 123, { nested: true }],
  };
 
  const params = { annotations: [{ id: "test", result: [] }], config: listKVConfig, data: listKVData };
 
  I.amOnPage("/");
  LabelStudio.init(params);
  LabelStudio.waitForObjectsReady();
 
  I.see("Name");
  I.see("Value");
 
  I.see("0");
  I.see("alpha");
  I.see("1");
  I.see("123");
  I.see("2");
  I.see(JSON.stringify({ nested: true }));
});