1
1
/*
2
- Copyright 2024 New Vector Ltd.
2
+ Copyright 2024,2025 New Vector Ltd.
3
3
Copyright 2022 The Matrix.org Foundation C.I.C.
4
4
5
5
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
@@ -35,17 +35,18 @@ function spaceCreateOptions(spaceName: string, roomIds: string[] = []): ICreateR
35
35
name : spaceName ,
36
36
} ,
37
37
} ,
38
- ...roomIds . map ( spaceChildInitialState ) ,
38
+ ...roomIds . map ( ( r ) => spaceChildInitialState ( r ) ) ,
39
39
] ,
40
40
} ;
41
41
}
42
42
43
- function spaceChildInitialState ( roomId : string ) : ICreateRoomOpts [ "initial_state" ] [ "0" ] {
43
+ function spaceChildInitialState ( roomId : string , order ?: string ) : ICreateRoomOpts [ "initial_state" ] [ "0" ] {
44
44
return {
45
45
type : "m.space.child" ,
46
46
state_key : roomId ,
47
47
content : {
48
48
via : [ roomId . split ( ":" ) [ 1 ] ] ,
49
+ order,
49
50
} ,
50
51
} ;
51
52
}
@@ -121,9 +122,10 @@ test.describe("Spaces", () => {
121
122
await page . getByRole ( "button" , { name : "Skip for now" } ) . click ( ) ;
122
123
123
124
// Assert rooms exist in the room list
124
- await expect ( page . getByRole ( "treeitem" , { name : "General" , exact : true } ) ) . toBeVisible ( ) ;
125
- await expect ( page . getByRole ( "treeitem" , { name : "Random" , exact : true } ) ) . toBeVisible ( ) ;
126
- await expect ( page . getByRole ( "treeitem" , { name : "Projects" , exact : true } ) ) . toBeVisible ( ) ;
125
+ const roomList = page . getByRole ( "tree" , { name : "Rooms" } ) ;
126
+ await expect ( roomList . getByRole ( "treeitem" , { name : "General" , exact : true } ) ) . toBeVisible ( ) ;
127
+ await expect ( roomList . getByRole ( "treeitem" , { name : "Random" , exact : true } ) ) . toBeVisible ( ) ;
128
+ await expect ( roomList . getByRole ( "treeitem" , { name : "Projects" , exact : true } ) ) . toBeVisible ( ) ;
127
129
128
130
// Assert rooms exist in the space explorer
129
131
await expect (
@@ -155,7 +157,7 @@ test.describe("Spaces", () => {
155
157
156
158
await page . getByRole ( "button" , { name : "Just me" } ) . click ( ) ;
157
159
158
- await page . getByText ( " Sample Room") . click ( { force : true } ) ; // force click as checkbox size is zero
160
+ await page . getByRole ( "checkbox" , { name : " Sample Room" } ) . click ( ) ;
159
161
160
162
// Temporal implementation as multiple elements with the role "button" and name "Add" are found
161
163
await page . locator ( ".mx_AddExistingToSpace_footer" ) . getByRole ( "button" , { name : "Add" } ) . click ( ) ;
@@ -165,6 +167,50 @@ test.describe("Spaces", () => {
165
167
) . toBeVisible ( ) ;
166
168
} ) ;
167
169
170
+ test (
171
+ "should allow user to add an existing room to a space after creation" ,
172
+ { tag : "@screenshot" } ,
173
+ async ( { page, app, user } ) => {
174
+ await app . client . createRoom ( {
175
+ name : "Sample Room" ,
176
+ } ) ;
177
+ await app . client . createRoom ( {
178
+ name : "A Room that will not be selected" ,
179
+ } ) ;
180
+
181
+ const menu = await openSpaceCreateMenu ( page ) ;
182
+ await menu . getByRole ( "button" , { name : "Private" } ) . click ( ) ;
183
+
184
+ await menu
185
+ . locator ( '.mx_SpaceBasicSettings_avatarContainer input[type="file"]' )
186
+ . setInputFiles ( "playwright/sample-files/riot.png" ) ;
187
+ await expect ( menu . getByRole ( "textbox" , { name : "Address" } ) ) . not . toBeVisible ( ) ;
188
+ await menu
189
+ . getByRole ( "textbox" , { name : "Description" } )
190
+ . fill ( "This is a personal space to mourn Riot.im..." ) ;
191
+ await menu . getByRole ( "textbox" , { name : "Name" } ) . fill ( "This is my Riot" ) ;
192
+ await menu . getByRole ( "textbox" , { name : "Name" } ) . press ( "Enter" ) ;
193
+
194
+ await page . getByRole ( "button" , { name : "Just me" } ) . click ( ) ;
195
+
196
+ await page . getByRole ( "button" , { name : "Skip for now" } ) . click ( ) ;
197
+
198
+ await page . getByRole ( "button" , { name : "Add room" } ) . click ( ) ;
199
+ await page . getByRole ( "menuitem" , { name : "Add existing room" } ) . click ( ) ;
200
+
201
+ await page . getByRole ( "checkbox" , { name : "Sample Room" } ) . click ( ) ;
202
+
203
+ await expect ( page . getByRole ( "dialog" , { name : "Avatar Add existing rooms" } ) ) . toMatchScreenshot (
204
+ "add-existing-rooms-dialog.png" ,
205
+ ) ;
206
+
207
+ await page . getByRole ( "button" , { name : "Add" } ) . click ( ) ;
208
+ await expect (
209
+ page . locator ( ".mx_SpaceHierarchy_list" ) . getByRole ( "treeitem" , { name : "Sample Room" } ) ,
210
+ ) . toBeVisible ( ) ;
211
+ } ,
212
+ ) ;
213
+
168
214
test ( "should allow user to invite another to a space" , { tag : "@no-webkit" } , async ( { page, app, user, bot } ) => {
169
215
await app . client . createSpace ( {
170
216
visibility : "public" as any ,
@@ -291,4 +337,36 @@ test.describe("Spaces", () => {
291
337
// Assert we get shown the new room intro, and thus not the soft crash screen
292
338
await expect ( page . locator ( ".mx_NewRoomIntro" ) ) . toBeVisible ( ) ;
293
339
} ) ;
340
+
341
+ test ( "should render spaces view" , { tag : "@screenshot" } , async ( { page, app, user, axe } ) => {
342
+ axe . disableRules ( [
343
+ // Disable this check as it triggers on nested roving tab index elements which are in practice fine
344
+ "nested-interactive" ,
345
+ // XXX: We have some known contrast issues here
346
+ "color-contrast" ,
347
+ ] ) ;
348
+
349
+ const childSpaceId1 = await app . client . createSpace ( {
350
+ name : "Child Space 1" ,
351
+ initial_state : [ ] ,
352
+ } ) ;
353
+ const childSpaceId2 = await app . client . createSpace ( {
354
+ name : "Child Space 2" ,
355
+ initial_state : [ ] ,
356
+ } ) ;
357
+ const childSpaceId3 = await app . client . createSpace ( {
358
+ name : "Child Space 3" ,
359
+ initial_state : [ ] ,
360
+ } ) ;
361
+ await app . client . createSpace ( {
362
+ name : "Root Space" ,
363
+ initial_state : [
364
+ spaceChildInitialState ( childSpaceId1 , "a" ) ,
365
+ spaceChildInitialState ( childSpaceId2 , "b" ) ,
366
+ spaceChildInitialState ( childSpaceId3 , "c" ) ,
367
+ ] ,
368
+ } ) ;
369
+ await app . viewSpaceByName ( "Root Space" ) ;
370
+ await expect ( page . locator ( ".mx_SpaceRoomView" ) ) . toMatchScreenshot ( "space-room-view.png" ) ;
371
+ } ) ;
294
372
} ) ;
0 commit comments