@@ -36,19 +36,21 @@ describe("Polls", () => {
36
36
throw new Error ( "Poll must have at least two options" ) ;
37
37
}
38
38
cy . get ( ".mx_PollCreateDialog" ) . within ( ( pollCreateDialog ) => {
39
- cy . get ( "#poll- topic-input" ) . type ( title ) ;
39
+ cy . findByRole ( "textbox" , { name : "Question or topic" } ) . type ( title ) ;
40
40
41
41
options . forEach ( ( option , index ) => {
42
42
const optionId = `#pollcreate_option_${ index } ` ;
43
43
44
44
// click 'add option' button if needed
45
45
if ( pollCreateDialog . find ( optionId ) . length === 0 ) {
46
- cy . get ( ".mx_PollCreateDialog_addOption" ) . scrollIntoView ( ) . click ( ) ;
46
+ cy . findByRole ( "button" , { name : "Add option" } ) . scrollIntoView ( ) . click ( ) ;
47
47
}
48
48
cy . get ( optionId ) . scrollIntoView ( ) . type ( option ) ;
49
49
} ) ;
50
50
} ) ;
51
- cy . get ( '.mx_Dialog button[type="submit"]' ) . click ( ) ;
51
+ cy . get ( ".mx_Dialog" ) . within ( ( ) => {
52
+ cy . findByRole ( "button" , { name : "Create Poll" } ) . click ( ) ;
53
+ } ) ;
52
54
} ;
53
55
54
56
const getPollTile = ( pollId : string ) : Chainable < JQuery > => {
@@ -67,7 +69,7 @@ describe("Polls", () => {
67
69
68
70
const botVoteForOption = ( bot : MatrixClient , roomId : string , pollId : string , optionText : string ) : void => {
69
71
getPollOption ( pollId , optionText ) . within ( ( ref ) => {
70
- cy . get ( 'input[type= "radio"]' )
72
+ cy . findByRole ( "radio" )
71
73
. invoke ( "attr" , "value" )
72
74
. then ( ( optionId ) => {
73
75
// We can't use the js-sdk types for this stuff directly, so manually construct the event.
@@ -111,11 +113,11 @@ describe("Polls", () => {
111
113
cy . inviteUser ( roomId , bot . getUserId ( ) ) ;
112
114
cy . visit ( "/#/room/" + roomId ) ;
113
115
// wait until Bob joined
114
- cy . contains ( ".mx_TextualEvent" , "BotBob joined the room" ) . should ( "exist" ) ;
116
+ cy . findByText ( "BotBob joined the room" ) . should ( "exist" ) ;
115
117
} ) ;
116
118
117
119
cy . openMessageComposerOptions ( ) . within ( ( ) => {
118
- cy . get ( '[aria-label=" Poll"]' ) . click ( ) ;
120
+ cy . findByRole ( "menuitem" , { name : " Poll" } ) . click ( ) ;
119
121
} ) ;
120
122
121
123
// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24688
@@ -142,7 +144,9 @@ describe("Polls", () => {
142
144
botVoteForOption ( bot , roomId , pollId , pollParams . options [ 2 ] ) ;
143
145
144
146
// no votes shown until I vote, check bots vote has arrived
145
- cy . get ( ".mx_MPollBody_totalVotes" ) . should ( "contain" , "1 vote cast" ) ;
147
+ cy . get ( ".mx_MPollBody_totalVotes" ) . within ( ( ) => {
148
+ cy . findByText ( "1 vote cast. Vote to see the results" ) ;
149
+ } ) ;
146
150
147
151
// vote 'Maybe'
148
152
getPollOption ( pollId , pollParams . options [ 2 ] ) . click ( "topLeft" ) ;
@@ -183,7 +187,7 @@ describe("Polls", () => {
183
187
} ) ;
184
188
185
189
cy . openMessageComposerOptions ( ) . within ( ( ) => {
186
- cy . get ( '[aria-label=" Poll"]' ) . click ( ) ;
190
+ cy . findByRole ( "menuitem" , { name : " Poll" } ) . click ( ) ;
187
191
} ) ;
188
192
189
193
const pollParams = {
@@ -203,9 +207,7 @@ describe("Polls", () => {
203
207
getPollTile ( pollId ) . rightclick ( ) ;
204
208
205
209
// Select edit item
206
- cy . get ( ".mx_ContextualMenu" ) . within ( ( ) => {
207
- cy . get ( '[aria-label="Edit"]' ) . click ( ) ;
208
- } ) ;
210
+ cy . findByRole ( "menuitem" , { name : "Edit" } ) . click ( ) ;
209
211
210
212
// Expect poll editing dialog
211
213
cy . get ( ".mx_PollCreateDialog" ) ;
@@ -226,7 +228,7 @@ describe("Polls", () => {
226
228
} ) ;
227
229
228
230
cy . openMessageComposerOptions ( ) . within ( ( ) => {
229
- cy . get ( '[aria-label=" Poll"]' ) . click ( ) ;
231
+ cy . findByRole ( "menuitem" , { name : " Poll" } ) . click ( ) ;
230
232
} ) ;
231
233
232
234
const pollParams = {
@@ -252,9 +254,7 @@ describe("Polls", () => {
252
254
getPollTile ( pollId ) . rightclick ( ) ;
253
255
254
256
// Select edit item
255
- cy . get ( ".mx_ContextualMenu" ) . within ( ( ) => {
256
- cy . get ( '[aria-label="Edit"]' ) . click ( ) ;
257
- } ) ;
257
+ cy . findByRole ( "menuitem" , { name : "Edit" } ) . click ( ) ;
258
258
259
259
// Expect error dialog
260
260
cy . get ( ".mx_ErrorDialog" ) ;
@@ -278,11 +278,11 @@ describe("Polls", () => {
278
278
cy . inviteUser ( roomId , botCharlie . getUserId ( ) ) ;
279
279
cy . visit ( "/#/room/" + roomId ) ;
280
280
// wait until the bots joined
281
- cy . contains ( ".mx_TextualEvent" , " and one other were invited and joined") . should ( "exist" ) ;
281
+ cy . findByText ( "BotBob and one other were invited and joined", { timeout : 10000 } ) . should ( "exist" ) ;
282
282
} ) ;
283
283
284
284
cy . openMessageComposerOptions ( ) . within ( ( ) => {
285
- cy . get ( '[aria-label=" Poll"]' ) . click ( ) ;
285
+ cy . findByRole ( "menuitem" , { name : " Poll" } ) . click ( ) ;
286
286
} ) ;
287
287
288
288
const pollParams = {
@@ -304,17 +304,21 @@ describe("Polls", () => {
304
304
} ) ;
305
305
306
306
// open the thread summary
307
- cy . get ( ".mx_RoomView_body .mx_ThreadSummary" ) . click ( ) ;
307
+ cy . findByRole ( "button" , { name : "Open thread" } ) . click ( ) ;
308
308
309
309
// Bob votes 'Maybe' in the poll
310
310
botVoteForOption ( botBob , roomId , pollId , pollParams . options [ 2 ] ) ;
311
311
// Charlie votes 'No'
312
312
botVoteForOption ( botCharlie , roomId , pollId , pollParams . options [ 1 ] ) ;
313
313
314
314
// no votes shown until I vote, check votes have arrived in main tl
315
- cy . get ( ".mx_RoomView_body .mx_MPollBody_totalVotes" ) . should ( "contain" , "2 votes cast" ) ;
315
+ cy . get ( ".mx_RoomView_body .mx_MPollBody_totalVotes" ) . within ( ( ) => {
316
+ cy . findByText ( "2 votes cast. Vote to see the results" ) . should ( "exist" ) ;
317
+ } ) ;
316
318
// and thread view
317
- cy . get ( ".mx_ThreadView .mx_MPollBody_totalVotes" ) . should ( "contain" , "2 votes cast" ) ;
319
+ cy . get ( ".mx_ThreadView .mx_MPollBody_totalVotes" ) . within ( ( ) => {
320
+ cy . findByText ( "2 votes cast. Vote to see the results" ) . should ( "exist" ) ;
321
+ } ) ;
318
322
319
323
// Take snapshots of poll on ThreadView
320
324
cy . setSettingValue ( "layout" , null , SettingLevel . DEVICE , Layout . Bubble ) ;
0 commit comments