@@ -94,7 +94,7 @@ describe("Polls", () => {
94
94
cy . stopSynapse ( synapse ) ;
95
95
} ) ;
96
96
97
- it ( "Open polls can be created and voted in " , ( ) => {
97
+ it ( "should be creatable and votable " , ( ) => {
98
98
let bot : MatrixClient ;
99
99
cy . getBot ( synapse , { displayName : "BotBob" } ) . then ( _bot => {
100
100
bot = _bot ;
@@ -159,7 +159,92 @@ describe("Polls", () => {
159
159
} ) ;
160
160
} ) ;
161
161
162
- it ( "displays polls correctly in thread panel" , ( ) => {
162
+ it ( "should be editable from context menu if no votes have been cast" , ( ) => {
163
+ let bot : MatrixClient ;
164
+ cy . getBot ( synapse , { displayName : "BotBob" } ) . then ( _bot => {
165
+ bot = _bot ;
166
+ } ) ;
167
+
168
+ let roomId : string ;
169
+ cy . createRoom ( { } ) . then ( _roomId => {
170
+ roomId = _roomId ;
171
+ cy . inviteUser ( roomId , bot . getUserId ( ) ) ;
172
+ cy . visit ( '/#/room/' + roomId ) ;
173
+ } ) ;
174
+
175
+ cy . openMessageComposerOptions ( ) . within ( ( ) => {
176
+ cy . get ( '[aria-label="Poll"]' ) . click ( ) ;
177
+ } ) ;
178
+
179
+ const pollParams = {
180
+ title : 'Does the polls feature work?' ,
181
+ options : [ 'Yes' , 'No' , 'Maybe' ] ,
182
+ } ;
183
+ createPoll ( pollParams ) ;
184
+
185
+ // Wait for message to send, get its ID and save as @pollId
186
+ cy . get ( ".mx_RoomView_body .mx_EventTile" ) . contains ( ".mx_EventTile[data-scroll-tokens]" , pollParams . title )
187
+ . invoke ( "attr" , "data-scroll-tokens" ) . as ( "pollId" ) ;
188
+
189
+ cy . get < string > ( "@pollId" ) . then ( pollId => {
190
+ // Open context menu
191
+ getPollTile ( pollId ) . rightclick ( ) ;
192
+
193
+ // Select edit item
194
+ cy . get ( '.mx_ContextualMenu' ) . within ( ( ) => {
195
+ cy . get ( '[aria-label="Edit"]' ) . click ( ) ;
196
+ } ) ;
197
+
198
+ // Expect poll editing dialog
199
+ cy . get ( '.mx_PollCreateDialog' ) ;
200
+ } ) ;
201
+ } ) ;
202
+
203
+ it ( "should not be editable from context menu if votes have been cast" , ( ) => {
204
+ let bot : MatrixClient ;
205
+ cy . getBot ( synapse , { displayName : "BotBob" } ) . then ( _bot => {
206
+ bot = _bot ;
207
+ } ) ;
208
+
209
+ let roomId : string ;
210
+ cy . createRoom ( { } ) . then ( _roomId => {
211
+ roomId = _roomId ;
212
+ cy . inviteUser ( roomId , bot . getUserId ( ) ) ;
213
+ cy . visit ( '/#/room/' + roomId ) ;
214
+ } ) ;
215
+
216
+ cy . openMessageComposerOptions ( ) . within ( ( ) => {
217
+ cy . get ( '[aria-label="Poll"]' ) . click ( ) ;
218
+ } ) ;
219
+
220
+ const pollParams = {
221
+ title : 'Does the polls feature work?' ,
222
+ options : [ 'Yes' , 'No' , 'Maybe' ] ,
223
+ } ;
224
+ createPoll ( pollParams ) ;
225
+
226
+ // Wait for message to send, get its ID and save as @pollId
227
+ cy . get ( ".mx_RoomView_body .mx_EventTile" ) . contains ( ".mx_EventTile[data-scroll-tokens]" , pollParams . title )
228
+ . invoke ( "attr" , "data-scroll-tokens" ) . as ( "pollId" ) ;
229
+
230
+ cy . get < string > ( "@pollId" ) . then ( pollId => {
231
+ // Bot votes 'Maybe' in the poll
232
+ botVoteForOption ( bot , roomId , pollId , pollParams . options [ 2 ] ) ;
233
+
234
+ // Open context menu
235
+ getPollTile ( pollId ) . rightclick ( ) ;
236
+
237
+ // Select edit item
238
+ cy . get ( '.mx_ContextualMenu' ) . within ( ( ) => {
239
+ cy . get ( '[aria-label="Edit"]' ) . click ( ) ;
240
+ } ) ;
241
+
242
+ // Expect error dialog
243
+ cy . get ( '.mx_ErrorDialog' ) ;
244
+ } ) ;
245
+ } ) ;
246
+
247
+ it ( "should be displayed correctly in thread panel" , ( ) => {
163
248
let botBob : MatrixClient ;
164
249
let botCharlie : MatrixClient ;
165
250
cy . getBot ( synapse , { displayName : "BotBob" } ) . then ( _bot => {
0 commit comments