@@ -46,8 +46,8 @@ describe("Editing", () => {
46
46
47
47
// Edit "Message"
48
48
const editLastMessage = ( edit : string ) => {
49
- cy . get ( ".mx_EventTile_last" ) . realHover ( ) . findButton ( " Edit") . click ( ) ;
50
- cy . get ( ".mx_BasicMessageComposer_input" ) . type ( `{selectAll}{del}${ edit } {enter}` ) ;
49
+ cy . get ( ".mx_EventTile_last" ) . realHover ( ) . findByRole ( "button" , { name : " Edit" } ) . click ( ) ;
50
+ cy . findByRole ( "textbox" , { name : "Edit message" } ) . type ( `{selectAll}{del}${ edit } {enter}` ) ;
51
51
} ;
52
52
53
53
const clickEditedMessage = ( edited : string ) => {
@@ -62,7 +62,7 @@ describe("Editing", () => {
62
62
63
63
const clickButtonViewSource = ( ) => {
64
64
// Assert that "View Source" button is rendered and click it
65
- cy . get ( ".mx_EventTile .mx_EventTile_line" ) . realHover ( ) . findButton ( " View Source") . click ( ) ;
65
+ cy . get ( ".mx_EventTile .mx_EventTile_line" ) . realHover ( ) . findByRole ( "button" , { name : " View Source" } ) . click ( ) ;
66
66
} ;
67
67
68
68
beforeEach ( ( ) => {
@@ -84,7 +84,7 @@ describe("Editing", () => {
84
84
it ( "should render and interact with the message edit history dialog" , ( ) => {
85
85
// Click the "Remove" button on the message edit history dialog
86
86
const clickButtonRemove = ( ) => {
87
- cy . get ( ".mx_EventTile_line" ) . realHover ( ) . findButton ( " Remove") . click ( ) ;
87
+ cy . get ( ".mx_EventTile_line" ) . realHover ( ) . findByRole ( "button" , { name : " Remove" } ) . click ( ) ;
88
88
} ;
89
89
90
90
cy . visit ( "/#/room/" + roomId ) ;
@@ -120,7 +120,9 @@ describe("Editing", () => {
120
120
121
121
// Assert that the date separator is rendered at the top
122
122
cy . get ( "li:nth-child(1) .mx_DateSeparator" ) . within ( ( ) => {
123
- cy . get ( "h2" ) . should ( "have.text" , "Today" ) ;
123
+ cy . get ( "h2" ) . within ( ( ) => {
124
+ cy . findByText ( "Today" ) ;
125
+ } ) ;
124
126
} ) ;
125
127
126
128
// Assert that the edited message is rendered under the date separator
@@ -130,14 +132,20 @@ describe("Editing", () => {
130
132
cy . get ( ".mx_EventTile_content .mx_EventTile_body" ) . should ( "have.text" , "Meassage" ) ;
131
133
132
134
cy . get ( ".mx_EventTile_content .mx_EventTile_body" ) . within ( ( ) => {
133
- cy . get ( ".mx_EditHistoryMessage_deletion" ) . should ( "have.text" , "e" ) ;
134
- cy . get ( ".mx_EditHistoryMessage_insertion" ) . should ( "have.text" , "a" ) ;
135
+ cy . get ( ".mx_EditHistoryMessage_deletion" ) . within ( ( ) => {
136
+ cy . findByText ( "e" ) ;
137
+ } ) ;
138
+ cy . get ( ".mx_EditHistoryMessage_insertion" ) . within ( ( ) => {
139
+ cy . findByText ( "a" ) ;
140
+ } ) ;
135
141
} ) ;
136
142
} ) ;
137
143
138
144
// Assert that the original message is rendered at the bottom
139
145
cy . get ( "li:nth-child(3) .mx_EventTile" ) . within ( ( ) => {
140
- cy . get ( ".mx_EventTile_content .mx_EventTile_body" ) . should ( "have.text" , "Message" ) ;
146
+ cy . get ( ".mx_EventTile_content .mx_EventTile_body" ) . within ( ( ) => {
147
+ cy . findByText ( "Message" ) ;
148
+ } ) ;
141
149
} ) ;
142
150
} ) ;
143
151
} ) ;
@@ -169,20 +177,24 @@ describe("Editing", () => {
169
177
170
178
// This time remove the message really
171
179
cy . get ( ".mx_TextInputDialog" ) . within ( ( ) => {
172
- cy . get ( ".mx_TextInputDialog_input" ) . type ( "This is a test." ) ; // Reason
173
- cy . contains ( "[data-testid='dialog-primary- button'] ", "Remove" ) . click ( ) ;
180
+ cy . findByRole ( "textbox" , { name : "Reason (optional)" } ) . type ( "This is a test." ) ; // Reason
181
+ cy . findByRole ( " button", { name : "Remove" } ) . click ( ) ;
174
182
} ) ;
175
183
176
184
// Assert that the message edit history dialog is rendered again
177
185
cy . get ( ".mx_MessageEditHistoryDialog" ) . within ( ( ) => {
178
186
// Assert that the date is rendered
179
187
cy . get ( "li:nth-child(1) .mx_DateSeparator" ) . within ( ( ) => {
180
- cy . get ( "h2" ) . should ( "have.text" , "Today" ) ;
188
+ cy . get ( "h2" ) . within ( ( ) => {
189
+ cy . findByText ( "Today" ) ;
190
+ } ) ;
181
191
} ) ;
182
192
183
193
// Assert that the original message is rendered under the date on the dialog
184
194
cy . get ( "li:nth-child(2) .mx_EventTile" ) . within ( ( ) => {
185
- cy . get ( ".mx_EventTile_content .mx_EventTile_body" ) . should ( "have.text" , "Message" ) ;
195
+ cy . get ( ".mx_EventTile_content .mx_EventTile_body" ) . within ( ( ) => {
196
+ cy . findByText ( "Message" ) ;
197
+ } ) ;
186
198
} ) ;
187
199
188
200
// Assert that the edited message is gone
@@ -194,9 +206,9 @@ describe("Editing", () => {
194
206
195
207
// Assert that the main timeline is rendered
196
208
cy . get ( ".mx_RoomView_MessageList" ) . within ( ( ) => {
197
- cy . get ( ".mx_EventTile_last" ) . within ( ( ) => {
209
+ cy . get ( ".mx_EventTile_last .mx_RedactedBody " ) . within ( ( ) => {
198
210
// Assert that the placeholder is rendered
199
- cy . contains ( ".mx_RedactedBody" , "Message deleted" ) ;
211
+ cy . findByText ( "Message deleted" ) ;
200
212
} ) ;
201
213
} ) ;
202
214
} ) ;
@@ -223,7 +235,7 @@ describe("Editing", () => {
223
235
// Assert that "View Source" is not rendered
224
236
cy . get ( ".mx_EventTile .mx_EventTile_line" )
225
237
. realHover ( )
226
- . contains ( ".mx_AccessibleButton ", "View Source" )
238
+ . findByRole ( "button ", { name : "View Source" } )
227
239
. should ( "not.exist" ) ;
228
240
} ) ;
229
241
@@ -241,7 +253,7 @@ describe("Editing", () => {
241
253
// Assert that the edited message is rendered
242
254
cy . get ( ".mx_MessageEditHistoryDialog li:nth-child(2)" ) . within ( ( ) => {
243
255
// Assert that "Remove" button for the original message is rendered
244
- cy . get ( ".mx_EventTile .mx_EventTile_line" ) . realHover ( ) . findButton ( " Remove") ;
256
+ cy . get ( ".mx_EventTile .mx_EventTile_line" ) . realHover ( ) . findByRole ( "button" , { name : " Remove" } ) ;
245
257
246
258
clickButtonViewSource ( ) ;
247
259
} ) ;
@@ -254,7 +266,7 @@ describe("Editing", () => {
254
266
// Assert that "Remove" button for the original message does not exist
255
267
cy . get ( ".mx_EventTile .mx_EventTile_line" )
256
268
. realHover ( )
257
- . contains ( ".mx_AccessibleButton ", "Remove" )
269
+ . findByRole ( "button ", { name : "Remove" } )
258
270
. should ( "not.exist" ) ;
259
271
260
272
clickButtonViewSource ( ) ;
@@ -271,16 +283,20 @@ describe("Editing", () => {
271
283
sendEvent ( roomId ) ;
272
284
273
285
// Edit message
274
- cy . contains ( ".mx_RoomView_body .mx_EventTile" , "Message" ) . within ( ( ) => {
275
- cy . get ( ".mx_EventTile_line" ) . realHover ( ) . findButton ( "Edit" ) . click ( ) . checkA11y ( ) ;
276
- cy . get ( ".mx_EventTile_line .mx_BasicMessageComposer_input" )
286
+ cy . get ( ".mx_RoomView_body .mx_EventTile" ) . within ( ( ) => {
287
+ cy . findByText ( "Message" ) ;
288
+ cy . get ( ".mx_EventTile_line" ) . realHover ( ) . findByRole ( "button" , { name : "Edit" } ) . click ( ) . checkA11y ( ) ;
289
+ cy . get ( ".mx_EventTile_line" )
290
+ . findByRole ( "textbox" , { name : "Edit message" } )
277
291
. type ( "Foo{backspace}{backspace}{backspace}{enter}" )
278
292
. checkA11y ( ) ;
279
293
} ) ;
280
- cy . contains ( ".mx_RoomView_body .mx_EventTile[data-scroll-tokens]" , "Message" ) ;
294
+ cy . get ( ".mx_RoomView_body .mx_EventTile[data-scroll-tokens]" ) . within ( ( ) => {
295
+ cy . findByText ( "Message" ) ;
296
+ } ) ;
281
297
282
298
// Assert that the edit composer has gone away
283
- cy . get ( ".mx_EditMessageComposer" ) . should ( "not.exist" ) ;
299
+ cy . findByRole ( "textbox" , { name : "Edit message" } ) . should ( "not.exist" ) ;
284
300
} ) ;
285
301
286
302
it ( "should correctly display events which are edited, where we lack the edit event" , ( ) => {
0 commit comments