Skip to content

Commit ee120f2

Browse files
authored
Use server name explicitly for via. (#30362)
* Use server name explicitly for via. * lint
1 parent 94aa51d commit ee120f2

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

playwright/e2e/spaces/spaces.spec.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function openSpaceContextMenu(page: Page, app: ElementAppPage, spaceName:
2323
return page.locator(".mx_SpacePanel_contextMenu");
2424
}
2525

26-
function spaceCreateOptions(spaceName: string, roomIds: string[] = []): ICreateRoomOpts {
26+
function spaceCreateOptions(serverName: string, spaceName: string, roomIds: string[] = []): ICreateRoomOpts {
2727
return {
2828
creation_content: {
2929
type: "m.space",
@@ -35,17 +35,21 @@ function spaceCreateOptions(spaceName: string, roomIds: string[] = []): ICreateR
3535
name: spaceName,
3636
},
3737
},
38-
...roomIds.map((r) => spaceChildInitialState(r)),
38+
...roomIds.map((r) => spaceChildInitialState(serverName, r)),
3939
],
4040
};
4141
}
4242

43-
function spaceChildInitialState(roomId: string, order?: string): ICreateRoomOpts["initial_state"]["0"] {
43+
function spaceChildInitialState(
44+
serverName: string,
45+
roomId: string,
46+
order?: string,
47+
): ICreateRoomOpts["initial_state"]["0"] {
4448
return {
4549
type: "m.space.child",
4650
state_key: roomId,
4751
content: {
48-
via: [roomId.split(":")[1]],
52+
via: [serverName],
4953
order,
5054
},
5155
};
@@ -240,7 +244,7 @@ test.describe("Spaces", () => {
240244
});
241245
await expect(await app.getSpacePanelButton("My Space")).toBeVisible();
242246

243-
const roomId = await bot.createRoom(spaceCreateOptions("Space Space"));
247+
const roomId = await bot.createRoom(spaceCreateOptions(user.homeServer, "Space Space"));
244248
await bot.inviteUser(roomId, user.userId);
245249

246250
// Assert that `Space Space` is above `My Space` due to it being an invite
@@ -260,7 +264,10 @@ test.describe("Spaces", () => {
260264
const spaceName = "Spacey Mc. Space Space";
261265
await app.client.createSpace({
262266
name: spaceName,
263-
initial_state: [spaceChildInitialState(roomId1), spaceChildInitialState(roomId2)],
267+
initial_state: [
268+
spaceChildInitialState(user.homeServer, roomId1),
269+
spaceChildInitialState(user.homeServer, roomId2),
270+
],
264271
});
265272

266273
await app.viewSpaceHomeByName(spaceName);
@@ -287,7 +294,7 @@ test.describe("Spaces", () => {
287294
});
288295
await app.client.createSpace({
289296
name: "Root Space",
290-
initial_state: [spaceChildInitialState(childSpaceId)],
297+
initial_state: [spaceChildInitialState(user.homeServer, childSpaceId)],
291298
});
292299

293300
// Find collapsed Space panel
@@ -323,7 +330,7 @@ test.describe("Spaces", () => {
323330
name: "Test Room",
324331
topic: "This is a topic https://github.com/matrix-org/matrix-react-sdk/pull/10060 with a link",
325332
});
326-
const spaceId = await bot.createRoom(spaceCreateOptions("Test Space", [roomId]));
333+
const spaceId = await bot.createRoom(spaceCreateOptions(user.homeServer, "Test Space", [roomId]));
327334
await bot.inviteUser(spaceId, user.userId);
328335

329336
await expect(await app.getSpacePanelButton("Test Space")).toBeVisible();
@@ -361,9 +368,9 @@ test.describe("Spaces", () => {
361368
await app.client.createSpace({
362369
name: "Root Space",
363370
initial_state: [
364-
spaceChildInitialState(childSpaceId1, "a"),
365-
spaceChildInitialState(childSpaceId2, "b"),
366-
spaceChildInitialState(childSpaceId3, "c"),
371+
spaceChildInitialState(user.homeServer, childSpaceId1, "a"),
372+
spaceChildInitialState(user.homeServer, childSpaceId2, "b"),
373+
spaceChildInitialState(user.homeServer, childSpaceId3, "c"),
367374
],
368375
});
369376
await app.viewSpaceByName("Root Space");

0 commit comments

Comments
 (0)