Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b4b146f

Browse files
Show a back button when viewing a space member (#9095)
1 parent 5944392 commit b4b146f

File tree

4 files changed

+187
-10
lines changed

4 files changed

+187
-10
lines changed

cypress/e2e/6-spaces/spaces.spec.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ function openSpaceCreateMenu(): Chainable<JQuery> {
2727
return cy.get(".mx_SpaceCreateMenu_wrapper .mx_ContextualMenu");
2828
}
2929

30-
function getSpacePanelButton(spaceName: string): Chainable<JQuery> {
31-
return cy.get(`.mx_SpaceButton[aria-label="${spaceName}"]`);
32-
}
33-
3430
function openSpaceContextMenu(spaceName: string): Chainable<JQuery> {
35-
getSpacePanelButton(spaceName).rightclick();
31+
cy.getSpacePanelButton(spaceName).rightclick();
3632
return cy.get(".mx_SpacePanel_contextMenu");
3733
}
3834

@@ -200,14 +196,14 @@ describe("Spaces", () => {
200196
cy.createSpace({
201197
name: "My Space",
202198
});
203-
getSpacePanelButton("My Space").should("exist");
199+
cy.getSpacePanelButton("My Space").should("exist");
204200

205201
cy.getBot(synapse, { displayName: "BotBob" }).then({ timeout: 10000 }, async bot => {
206202
const { room_id: roomId } = await bot.createRoom(spaceCreateOptions("Space Space"));
207203
await bot.invite(roomId, user.userId);
208204
});
209205
// Assert that `Space Space` is above `My Space` due to it being an invite
210-
getSpacePanelButton("Space Space").should("exist")
206+
cy.getSpacePanelButton("Space Space").should("exist")
211207
.parent().next().find('.mx_SpaceButton[aria-label="My Space"]').should("exist");
212208
});
213209

@@ -234,7 +230,7 @@ describe("Spaces", () => {
234230
});
235231

236232
cy.get("@spaceId").then(() => {
237-
getSpacePanelButton(spaceName).dblclick(); // Open space home
233+
cy.viewSpaceHomeByName(spaceName);
238234
});
239235
cy.get(".mx_SpaceRoomView .mx_SpaceHierarchy_list").within(() => {
240236
cy.get(".mx_SpaceHierarchy_roomTile").contains("Music").should("exist");
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
/// <reference types="cypress" />
18+
19+
import { SynapseInstance } from "../../plugins/synapsedocker";
20+
import Chainable = Cypress.Chainable;
21+
22+
const ROOM_NAME = "Test room";
23+
const SPACE_NAME = "Test space";
24+
const NAME = "Alice";
25+
26+
const getMemberTileByName = (name: string): Chainable<JQuery<HTMLElement>> => {
27+
return cy.get(`.mx_EntityTile, [title="${name}"]`);
28+
};
29+
30+
const goBack = (): Chainable<JQuery<HTMLElement>> => {
31+
return cy.get(".mx_BaseCard_back").click();
32+
};
33+
34+
const viewRoomSummaryByName = (name: string): Chainable<JQuery<HTMLElement>> => {
35+
cy.viewRoomByName(name);
36+
cy.get(".mx_RightPanel_roomSummaryButton").click();
37+
return checkRoomSummaryCard(name);
38+
};
39+
40+
const checkRoomSummaryCard = (name: string): Chainable<JQuery<HTMLElement>> => {
41+
cy.get(".mx_RoomSummaryCard").should("have.length", 1);
42+
return cy.get(".mx_BaseCard_header").should("contain", name);
43+
};
44+
45+
describe("RightPanel", () => {
46+
let synapse: SynapseInstance;
47+
48+
beforeEach(() => {
49+
cy.startSynapse("default").then(data => {
50+
synapse = data;
51+
cy.initTestUser(synapse, NAME).then(() =>
52+
cy.window({ log: false }).then(() => {
53+
cy.createRoom({ name: ROOM_NAME });
54+
cy.createSpace({ name: SPACE_NAME });
55+
}),
56+
);
57+
});
58+
});
59+
60+
afterEach(() => {
61+
cy.stopSynapse(synapse);
62+
});
63+
64+
describe("in rooms", () => {
65+
it("should handle clicking add widgets", () => {
66+
viewRoomSummaryByName(ROOM_NAME);
67+
68+
cy.get(".mx_RoomSummaryCard_appsGroup .mx_AccessibleButton").click();
69+
cy.get(".mx_IntegrationManager").should("have.length", 1);
70+
});
71+
72+
it("should handle viewing export chat", () => {
73+
viewRoomSummaryByName(ROOM_NAME);
74+
75+
cy.get(".mx_RoomSummaryCard_icon_export").click();
76+
cy.get(".mx_ExportDialog").should("have.length", 1);
77+
});
78+
79+
it("should handle viewing share room", () => {
80+
viewRoomSummaryByName(ROOM_NAME);
81+
82+
cy.get(".mx_RoomSummaryCard_icon_share").click();
83+
cy.get(".mx_ShareDialog").should("have.length", 1);
84+
});
85+
86+
it("should handle viewing room settings", () => {
87+
viewRoomSummaryByName(ROOM_NAME);
88+
89+
cy.get(".mx_RoomSummaryCard_icon_settings").click();
90+
cy.get(".mx_RoomSettingsDialog").should("have.length", 1);
91+
cy.get(".mx_Dialog_title").should("contain", ROOM_NAME);
92+
});
93+
94+
it("should handle viewing files", () => {
95+
viewRoomSummaryByName(ROOM_NAME);
96+
97+
cy.get(".mx_RoomSummaryCard_icon_files").click();
98+
cy.get(".mx_FilePanel").should("have.length", 1);
99+
cy.get(".mx_FilePanel_empty").should("have.length", 1);
100+
101+
goBack();
102+
checkRoomSummaryCard(ROOM_NAME);
103+
});
104+
105+
it("should handle viewing room member", () => {
106+
viewRoomSummaryByName(ROOM_NAME);
107+
108+
cy.get(".mx_RoomSummaryCard_icon_people").click();
109+
cy.get(".mx_MemberList").should("have.length", 1);
110+
111+
getMemberTileByName(NAME).click();
112+
cy.get(".mx_UserInfo").should("have.length", 1);
113+
cy.get(".mx_UserInfo_profile").should("contain", NAME);
114+
115+
goBack();
116+
cy.get(".mx_MemberList").should("have.length", 1);
117+
118+
goBack();
119+
checkRoomSummaryCard(ROOM_NAME);
120+
});
121+
});
122+
123+
describe("in spaces", () => {
124+
it("should handle viewing space member", () => {
125+
cy.viewSpaceHomeByName(SPACE_NAME);
126+
cy.get(".mx_RoomInfoLine_members").click();
127+
cy.get(".mx_MemberList").should("have.length", 1);
128+
cy.get(".mx_RightPanel_scopeHeader").should("contain", SPACE_NAME);
129+
130+
getMemberTileByName(NAME).click();
131+
cy.get(".mx_UserInfo").should("have.length", 1);
132+
cy.get(".mx_UserInfo_profile").should("contain", NAME);
133+
cy.get(".mx_RightPanel_scopeHeader").should("contain", SPACE_NAME);
134+
135+
goBack();
136+
cy.get(".mx_MemberList").should("have.length", 1);
137+
});
138+
});
139+
});

cypress/support/views.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ declare global {
2828
* @param name The room name to find and click on/open.
2929
*/
3030
viewRoomByName(name: string): Chainable<JQuery<HTMLElement>>;
31+
32+
/**
33+
* Returns the space panel space button based on a name. The space
34+
* must be visible in the space panel
35+
* @param name The space name to find
36+
*/
37+
getSpacePanelButton(name: string): Chainable<JQuery<HTMLElement>>;
38+
39+
/**
40+
* Opens the given space home by name. The space must be visible in
41+
* the space list.
42+
* @param name The space name to find and click on/open.
43+
*/
44+
viewSpaceHomeByName(name: string): Chainable<JQuery<HTMLElement>>;
45+
46+
/**
47+
* Opens the given space by name. The space must be visible in the
48+
* space list.
49+
* @param name The space name to find and click on/open.
50+
*/
51+
viewSpaceByName(name: string): Chainable<JQuery<HTMLElement>>;
3152
}
3253
}
3354
}
@@ -36,5 +57,17 @@ Cypress.Commands.add("viewRoomByName", (name: string): Chainable<JQuery<HTMLElem
3657
return cy.get(`.mx_RoomTile[aria-label="${name}"]`).click();
3758
});
3859

60+
Cypress.Commands.add("getSpacePanelButton", (name: string): Chainable<JQuery<HTMLElement>> => {
61+
return cy.get(`.mx_SpaceButton[aria-label="${name}"]`);
62+
});
63+
64+
Cypress.Commands.add("viewSpaceByName", (name: string): Chainable<JQuery<HTMLElement>> => {
65+
return cy.getSpacePanelButton(name).click();
66+
});
67+
68+
Cypress.Commands.add("viewSpaceHomeByName", (name: string): Chainable<JQuery<HTMLElement>> => {
69+
return cy.getSpacePanelButton(name).dblclick();
70+
});
71+
3972
// Needed to make this file a module
4073
export { };

src/components/structures/SpaceRoomView.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { inviteMultipleToRoom, showRoomInviteDialog } from "../../RoomInvite";
3838
import { UIComponent } from "../../settings/UIFeature";
3939
import { UPDATE_EVENT } from "../../stores/AsyncStore";
4040
import RightPanelStore from "../../stores/right-panel/RightPanelStore";
41+
import { IRightPanelCard } from "../../stores/right-panel/RightPanelStoreIPanelState";
4142
import { RightPanelPhases } from "../../stores/right-panel/RightPanelStorePhases";
4243
import ResizeNotifier from "../../utils/ResizeNotifier";
4344
import {
@@ -617,10 +618,18 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
617618
if (payload.action !== Action.ViewUser && payload.action !== "view_3pid_invite") return;
618619

619620
if (payload.action === Action.ViewUser && payload.member) {
620-
RightPanelStore.instance.setCard({
621+
const spaceMemberInfoCard: IRightPanelCard = {
621622
phase: RightPanelPhases.SpaceMemberInfo,
622623
state: { spaceId: this.props.space.roomId, member: payload.member },
623-
});
624+
};
625+
if (payload.push) {
626+
RightPanelStore.instance.pushCard(spaceMemberInfoCard);
627+
} else {
628+
RightPanelStore.instance.setCards([
629+
{ phase: RightPanelPhases.SpaceMemberList, state: { spaceId: this.props.space.roomId } },
630+
spaceMemberInfoCard,
631+
]);
632+
}
624633
} else if (payload.action === "view_3pid_invite" && payload.event) {
625634
RightPanelStore.instance.setCard({
626635
phase: RightPanelPhases.Space3pidMemberInfo,

0 commit comments

Comments
 (0)