@@ -63,7 +63,7 @@ describe("Knock Into Room", () => {
63
63
cy . stopHomeserver ( homeserver ) ;
64
64
} ) ;
65
65
66
- it ( "should knock into the room then knock is approved and user joins the room" , ( ) => {
66
+ it ( "should knock into the room then knock is approved and user joins the room then user is kicked and joins again " , ( ) => {
67
67
cy . viewRoomById ( roomId ) ;
68
68
69
69
cy . get ( ".mx_RoomPreviewBar" ) . within ( ( ) => {
@@ -104,6 +104,124 @@ describe("Knock Into Room", () => {
104
104
cy . findByRole ( "group" , { name : "Rooms" } ) . findByRole ( "treeitem" , { name : "Cybersecurity" } ) ;
105
105
106
106
cy . findByText ( "Alice joined the room" ) . should ( "exist" ) ;
107
+
108
+ cy . window ( ) . then ( async ( win ) => {
109
+ // bot kicks Alice
110
+ await bot . kick ( roomId , user . userId ) ;
111
+ } ) ;
112
+
113
+ cy . get ( ".mx_RoomPreviewBar" ) . within ( ( ) => {
114
+ cy . findByRole ( "button" , { name : "Re-join" } ) . click ( ) ;
115
+
116
+ cy . findByRole ( "heading" , { name : "Ask to join Cybersecurity?" } ) ;
117
+ cy . findByRole ( "button" , { name : "Request access" } ) . click ( ) ;
118
+ } ) ;
119
+
120
+ cy . window ( ) . then ( async ( win ) => {
121
+ // bot waits for knock request from Alice
122
+ await waitForRoom ( win , bot , roomId , ( room ) => {
123
+ const events = room . getLiveTimeline ( ) . getEvents ( ) ;
124
+ return events . some (
125
+ ( e ) =>
126
+ e . getType ( ) === "m.room.member" &&
127
+ e . getContent ( ) ?. membership === "knock" &&
128
+ e . getContent ( ) ?. displayname === "Alice" ,
129
+ ) ;
130
+ } ) ;
131
+
132
+ // bot invites Alice
133
+ await bot . invite ( roomId , user . userId ) ;
134
+ } ) ;
135
+
136
+ // Alice have to accept invitation in order to join the room.
137
+ // It will be not needed when homeserver implements auto accept knock requests.
138
+ cy . get ( ".mx_RoomView" ) . findByRole ( "button" , { name : "Accept" } ) . click ( ) ;
139
+
140
+ cy . findByText ( "Alice was invited, joined, was removed, was invited, and joined" ) . should ( "exist" ) ;
141
+ } ) ;
142
+
143
+ it ( "should knock into the room then knock is approved and user joins the room then user is banned/unbanned and joins again" , ( ) => {
144
+ cy . viewRoomById ( roomId ) ;
145
+
146
+ cy . get ( ".mx_RoomPreviewBar" ) . within ( ( ) => {
147
+ cy . findByRole ( "button" , { name : "Join the discussion" } ) . click ( ) ;
148
+
149
+ cy . findByRole ( "heading" , { name : "Ask to join?" } ) ;
150
+ cy . findByRole ( "textbox" ) ;
151
+ cy . findByRole ( "button" , { name : "Request access" } ) . click ( ) ;
152
+
153
+ cy . findByRole ( "heading" , { name : "Request to join sent" } ) ;
154
+ } ) ;
155
+
156
+ // Knocked room should appear in Rooms
157
+ cy . findByRole ( "group" , { name : "Rooms" } ) . findByRole ( "treeitem" , { name : "Cybersecurity" } ) ;
158
+
159
+ cy . window ( ) . then ( async ( win ) => {
160
+ // bot waits for knock request from Alice
161
+ await waitForRoom ( win , bot , roomId , ( room ) => {
162
+ const events = room . getLiveTimeline ( ) . getEvents ( ) ;
163
+ return events . some (
164
+ ( e ) =>
165
+ e . getType ( ) === "m.room.member" &&
166
+ e . getContent ( ) ?. membership === "knock" &&
167
+ e . getContent ( ) ?. displayname === "Alice" ,
168
+ ) ;
169
+ } ) ;
170
+
171
+ // bot invites Alice
172
+ await bot . invite ( roomId , user . userId ) ;
173
+ } ) ;
174
+
175
+ cy . findByRole ( "group" , { name : "Invites" } ) . findByRole ( "treeitem" , { name : "Cybersecurity" } ) ;
176
+
177
+ // Alice have to accept invitation in order to join the room.
178
+ // It will be not needed when homeserver implements auto accept knock requests.
179
+ cy . get ( ".mx_RoomView" ) . findByRole ( "button" , { name : "Accept" } ) . click ( ) ;
180
+
181
+ cy . findByRole ( "group" , { name : "Rooms" } ) . findByRole ( "treeitem" , { name : "Cybersecurity" } ) ;
182
+
183
+ cy . findByText ( "Alice joined the room" ) . should ( "exist" ) ;
184
+
185
+ cy . window ( ) . then ( async ( win ) => {
186
+ // bot bans Alice
187
+ await bot . ban ( roomId , user . userId ) ;
188
+ } ) ;
189
+
190
+ cy . get ( ".mx_RoomPreviewBar" ) . findByText ( "You were banned from Cybersecurity by Bob" ) . should ( "exist" ) ;
191
+
192
+ cy . window ( ) . then ( async ( win ) => {
193
+ // bot unbans Alice
194
+ await bot . unban ( roomId , user . userId ) ;
195
+ } ) ;
196
+
197
+ cy . get ( ".mx_RoomPreviewBar" ) . within ( ( ) => {
198
+ cy . findByRole ( "button" , { name : "Re-join" } ) . click ( ) ;
199
+
200
+ cy . findByRole ( "heading" , { name : "Ask to join Cybersecurity?" } ) ;
201
+ cy . findByRole ( "button" , { name : "Request access" } ) . click ( ) ;
202
+ } ) ;
203
+
204
+ cy . window ( ) . then ( async ( win ) => {
205
+ // bot waits for knock request from Alice
206
+ await waitForRoom ( win , bot , roomId , ( room ) => {
207
+ const events = room . getLiveTimeline ( ) . getEvents ( ) ;
208
+ return events . some (
209
+ ( e ) =>
210
+ e . getType ( ) === "m.room.member" &&
211
+ e . getContent ( ) ?. membership === "knock" &&
212
+ e . getContent ( ) ?. displayname === "Alice" ,
213
+ ) ;
214
+ } ) ;
215
+
216
+ // bot invites Alice
217
+ await bot . invite ( roomId , user . userId ) ;
218
+ } ) ;
219
+
220
+ // Alice have to accept invitation in order to join the room.
221
+ // It will be not needed when homeserver implements auto accept knock requests.
222
+ cy . get ( ".mx_RoomView" ) . findByRole ( "button" , { name : "Accept" } ) . click ( ) ;
223
+
224
+ cy . findByText ( "Alice was invited, joined, was banned, was unbanned, was invited, and joined" ) . should ( "exist" ) ;
107
225
} ) ;
108
226
109
227
it ( "should knock into the room and knock is cancelled by user himself" , ( ) => {
0 commit comments