1
+ import Table from "../../src/Table.js" ;
2
+ import TableCell from "../../src/TableCell.js" ;
3
+ import TableRow from "../../src/TableRow.js" ;
4
+ import TableColumn from "../../src/TableColumn.js" ;
5
+ import TableGroupRow from "../../src/TableGroupRow.js" ;
6
+
7
+ function TableRenderer ( { multipleSelection } : { multipleSelection : boolean } ) {
8
+ return < Table mode = { multipleSelection ? "MultiSelect" : "SingleSelect" } >
9
+ < TableColumn slot = "columns" > City</ TableColumn >
10
+ < TableColumn slot = "columns" > Supplier</ TableColumn >
11
+ < TableColumn slot = "columns" > Country</ TableColumn >
12
+
13
+ < TableGroupRow > Country: Bulgaria</ TableGroupRow >
14
+ < TableRow >
15
+ < TableCell > Sofia</ TableCell >
16
+ < TableCell > Sirenje EOOD</ TableCell >
17
+ < TableCell > Bulgaria</ TableCell >
18
+ </ TableRow >
19
+ < TableRow >
20
+ < TableCell > Plovdiv</ TableCell >
21
+ < TableCell > Kashkavali AD</ TableCell >
22
+ < TableCell > Bulgaria</ TableCell >
23
+ </ TableRow >
24
+
25
+ < TableGroupRow > Country: USA</ TableGroupRow >
26
+ < TableRow >
27
+ < TableCell > Dublin</ TableCell >
28
+ < TableCell > J.M. Brothers</ TableCell >
29
+ < TableCell > USA</ TableCell >
30
+ </ TableRow >
31
+ < TableRow >
32
+ < TableCell > Boston</ TableCell >
33
+ < TableCell > J.M. Brothers</ TableCell >
34
+ < TableCell > USA</ TableCell >
35
+ </ TableRow >
36
+ </ Table >
37
+ }
38
+
39
+ describe ( "Table general interaction" , ( ) => {
40
+ it ( "Table group rows should be rendered" , ( ) => {
41
+ cy . mount ( < TableRenderer multipleSelection = { false } /> ) ;
42
+
43
+ cy . get ( "[ui5-table-group-row]" ) . should ( "have.length" , 2 ) ;
44
+ } ) ;
45
+
46
+ it ( "Colspan attribute should be calculated correctly for single table mode" , ( ) => {
47
+ cy . mount ( < TableRenderer multipleSelection = { false } /> ) ;
48
+
49
+ cy . get ( "[ui5-table-group-row]" )
50
+ . first ( )
51
+ . shadow ( )
52
+ . find ( "td" )
53
+ . should ( "have.attr" , "colspan" , "3" ) ;
54
+ } ) ;
55
+
56
+ it ( "Colspan attribute should be calculated correctly for multi table mode" , ( ) => {
57
+ cy . mount ( < TableRenderer multipleSelection = { true } /> ) ;
58
+
59
+ cy . get ( "[ui5-table-group-row]" )
60
+ . first ( )
61
+ . shadow ( )
62
+ . find ( "td" )
63
+ . should ( "have.attr" , "colspan" , "4" ) ;
64
+ } ) ;
65
+
66
+ it ( "ARIA - aria-label should be calculated correctly." , ( ) => {
67
+ cy . mount ( < TableRenderer multipleSelection = { false } /> ) ;
68
+
69
+ cy . get ( "[ui5-table-group-row]" )
70
+ . eq ( 0 )
71
+ . shadow ( )
72
+ . find ( "tr" )
73
+ . should ( "have.attr" , "aria-label" , "Group Header Row Country: Bulgaria. 2 of 7" ) ;
74
+
75
+ cy . get ( "[ui5-table-group-row]" )
76
+ . eq ( 1 )
77
+ . shadow ( )
78
+ . find ( "tr" )
79
+ . should ( "have.attr" , "aria-label" , "Group Header Row Country: USA. 5 of 7" ) ;
80
+ } ) ;
81
+ } ) ;
0 commit comments