File tree 2 files changed +31
-2
lines changed
2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,25 @@ test.describe('lib/fixture.ts (locators)', () => {
119
119
expect ( await hiddenElements . count ( ) ) . toEqual ( 2 )
120
120
} )
121
121
122
+ test . only ( 'supports querying SVG by title' , async ( { screen} ) => {
123
+ const svg = screen . getByRole ( 'img' , { name : 'Vector' } )
124
+
125
+ expect ( await svg . count ( ) ) . toEqual ( 1 )
126
+
127
+ await expect ( svg . click ( ) ) . resolves . not . toThrow ( )
128
+ } )
129
+
130
+ test . only ( 'clicking SVG title element' , async ( { screen, within} ) => {
131
+ const svg = screen . getByRole ( 'img' , { name : 'Vector' } )
132
+ const title = within ( svg ) . getByText ( 'Vector' )
133
+
134
+ screen . setDefaultTimeout ( 1000 )
135
+
136
+ expect ( await title . count ( ) ) . toEqual ( 1 )
137
+
138
+ await expect ( async ( ) => title . click ( ) ) . rejects . toThrow ( )
139
+ } )
140
+
122
141
test . describe ( 'querying by role with `level` option' , ( ) => {
123
142
test ( 'retrieves the correct elements when querying all by role' , async ( {
124
143
queries : { queryAllByRole} ,
Original file line number Diff line number Diff line change @@ -26,13 +26,23 @@ <h3>Hello h3</h3>
26
26
>
27
27
< path d ="M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z " />
28
28
</ svg >
29
+
30
+ < svg
31
+ role ="img "
32
+ xmlns ="http://www.w3.org/2000/svg "
33
+ width ="128px "
34
+ viewBox ="0 0 512 512 "
35
+ >
36
+ < title > Vector</ title >
37
+ < path d ="M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z " />
38
+ </ svg >
29
39
</ body >
30
-
40
+
31
41
< form >
32
42
< label for ="#name "> Name</ label >
33
43
< input id ="name " name ="name " type ="text " />
34
44
</ form >
35
-
45
+
36
46
< label id ="user-label "> User</ label >
37
47
< form aria-labelledby ="user-label ">
38
48
< label for ="username "> Username</ label >
You can’t perform that action at this time.
0 commit comments