@@ -7,107 +7,121 @@ describe('constructSelector', () => {
7
7
alt : 'view more' ,
8
8
aria_label : 'View More' ,
9
9
class : [ 'classA' ] ,
10
+ component_name : 'TestButton' ,
10
11
id : 'ID1' ,
11
12
role : 'button' ,
12
13
tag : 'button' ,
13
14
testid : 'button-test' ,
14
15
title : 'cool title' ,
15
16
} ,
16
17
fullSelector :
17
- 'button#ID1.classA[role="button"][aria="View More"][data-test-id="button-test"][alt="view more"][title="cool title"]' ,
18
+ 'button#ID1.classA[role="button"][aria="View More"][data-test-id="button-test"][alt="view more"][title="cool title"][data-sentry-component="TestButton"] ' ,
18
19
selector :
19
- 'button #ID1.classA [role="button"][aria="View More"][data-test-id="button-test"][alt="view more"][title="cool title"]' ,
20
+ 'TestButton #ID1[role="button"][aria="View More"][data-test-id="button-test"][alt="view more"][title="cool title"]' ,
20
21
} ,
21
22
{
22
23
element : {
23
24
alt : '' ,
24
25
aria_label : '' ,
25
26
class : [ '' , '' ] ,
27
+ component_name : '' ,
26
28
id : '' ,
27
29
role : '' ,
28
30
tag : 'a' ,
29
31
testid : '' ,
30
32
title : '' ,
31
33
} ,
32
- fullSelector : 'a[role=""][aria=""][data-test-id=""][alt=""][title=""]' ,
34
+ fullSelector :
35
+ 'a[role=""][aria=""][data-test-id=""][alt=""][title=""][data-sentry-component=""]' ,
33
36
selector : 'a' ,
34
37
} ,
35
38
{
36
39
element : {
37
40
alt : '' ,
38
41
aria_label : '' ,
39
42
class : [ 'classA' , '' ] ,
43
+ component_name : '' ,
40
44
id : '' ,
41
45
role : '' ,
42
46
tag : 'a' ,
43
47
testid : '' ,
44
48
title : '' ,
45
49
} ,
46
- fullSelector : 'a.classA[role=""][aria=""][data-test-id=""][alt=""][title=""]' ,
50
+ fullSelector :
51
+ 'a.classA[role=""][aria=""][data-test-id=""][alt=""][title=""][data-sentry-component=""]' ,
47
52
selector : 'a.classA' ,
48
53
} ,
49
54
{
50
55
element : {
51
56
alt : '' ,
52
57
aria_label : '' ,
53
58
class : [ 'classA' , '' ] ,
59
+ component_name : '' ,
54
60
id : 'ID2' ,
55
61
role : '' ,
56
62
tag : 'a' ,
57
63
testid : '' ,
58
64
title : '' ,
59
65
} ,
60
- fullSelector : 'a#ID2.classA[role=""][aria=""][data-test-id=""][alt=""][title=""]' ,
66
+ fullSelector :
67
+ 'a#ID2.classA[role=""][aria=""][data-test-id=""][alt=""][title=""][data-sentry-component=""]' ,
61
68
selector : 'a#ID2.classA' ,
62
69
} ,
63
70
{
64
71
element : {
65
72
alt : '' ,
66
73
aria_label : '' ,
67
74
class : [ 'classA' , 'classB' ] ,
75
+ component_name : 'TestButton' ,
68
76
id : 'ID2' ,
69
77
role : '' ,
70
78
tag : 'a' ,
71
79
testid : '' ,
72
80
title : '' ,
73
81
} ,
74
82
fullSelector :
75
- 'a#ID2.classA.classB[role=""][aria=""][data-test-id=""][alt=""][title=""]' ,
76
- selector : 'a #ID2.classA.classB ' ,
83
+ 'a#ID2.classA.classB[role=""][aria=""][data-test-id=""][alt=""][title=""][data-sentry-component="TestButton"] ' ,
84
+ selector : 'TestButton #ID2' ,
77
85
} ,
78
86
{
79
87
element : {
80
88
alt : '' ,
81
89
aria_label : 'hello' ,
82
90
class : [ 'classA' , 'classB' ] ,
91
+ component_name : '' ,
83
92
id : 'ID2' ,
84
93
role : '' ,
85
94
tag : 'a' ,
86
95
testid : '' ,
87
96
title : '' ,
88
97
} ,
89
98
fullSelector :
90
- 'a#ID2.classA.classB[role=""][aria="hello"][data-test-id=""][alt=""][title=""]' ,
99
+ 'a#ID2.classA.classB[role=""][aria="hello"][data-test-id=""][alt=""][title=""][data-sentry-component=""] ' ,
91
100
selector : 'a#ID2.classA.classB[aria="hello"]' ,
92
101
} ,
93
102
{
94
103
element : {
95
104
alt : '' ,
96
105
aria_label : 'hello' ,
106
+ component_name : 'TestHello' ,
97
107
class : [ '' ] ,
98
108
id : 'ID2' ,
99
109
role : '' ,
100
110
tag : 'a' ,
101
111
testid : '' ,
102
112
title : '' ,
103
113
} ,
104
- fullSelector : 'a#ID2[role=""][aria="hello"][data-test-id=""][alt=""][title=""]' ,
105
- selector : 'a#ID2[aria="hello"]' ,
114
+ fullSelector :
115
+ 'a#ID2[role=""][aria="hello"][data-test-id=""][alt=""][title=""][data-sentry-component="TestHello"]' ,
116
+ selector : 'TestHello#ID2[aria="hello"]' ,
106
117
} ,
107
118
] ) (
108
119
'should construct the correct trimmed selector and full selector, for each element in the list' ,
109
120
( { element, fullSelector, selector} ) => {
110
- expect ( constructSelector ( element ) ) . toStrictEqual ( { fullSelector, selector} ) ;
121
+ expect ( constructSelector ( element ) ) . toStrictEqual ( {
122
+ fullSelector,
123
+ selector,
124
+ } ) ;
111
125
}
112
126
) ;
113
127
} ) ;
0 commit comments