Attempt to fix tests and fix RoomSummaryCard having wrong member count

pull/21833/head
Michael Telatynski 2020-09-09 12:28:12 +01:00
parent 8dcb2d4719
commit b635598bc3
3 changed files with 30 additions and 16 deletions

View File

@ -181,6 +181,14 @@ const onRoomSettingsClick = () => {
defaultDispatcher.dispatch({ action: "open_room_settings" }); defaultDispatcher.dispatch({ action: "open_room_settings" });
}; };
const useMemberCount = (room: Room) => {
const [count, setCount] = useState(room.getJoinedMembers().length);
useEventEmitter(room.currentState, "RoomState.members", () => {
setCount(room.getJoinedMembers().length);
});
return count;
};
const RoomSummaryCard: React.FC<IProps> = ({ room, onClose }) => { const RoomSummaryCard: React.FC<IProps> = ({ room, onClose }) => {
const cli = useContext(MatrixClientContext); const cli = useContext(MatrixClientContext);
@ -210,10 +218,12 @@ const RoomSummaryCard: React.FC<IProps> = ({ room, onClose }) => {
</div> </div>
</React.Fragment>; </React.Fragment>;
const memberCount = useMemberCount(room);
return <BaseCard header={header} className="mx_RoomSummaryCard" onClose={onClose}> return <BaseCard header={header} className="mx_RoomSummaryCard" onClose={onClose}>
<Group title={_t("About")} className="mx_RoomSummaryCard_aboutGroup"> <Group title={_t("About")} className="mx_RoomSummaryCard_aboutGroup">
<Button className="mx_RoomSummaryCard_icon_people" onClick={onRoomMembersClick}> <Button className="mx_RoomSummaryCard_icon_people" onClick={onRoomMembersClick}>
{_t("%(count)s people", { count: room.getJoinedMembers().length })} {_t("%(count)s people", { count: memberCount })}
</Button> </Button>
<Button className="mx_RoomSummaryCard_icon_files" onClick={onRoomFilesClick}> <Button className="mx_RoomSummaryCard_icon_files" onClick={onRoomFilesClick}>
{_t("Show files")} {_t("Show files")}

View File

@ -17,11 +17,6 @@ limitations under the License.
const assert = require('assert'); const assert = require('assert');
module.exports.openMemberList = async function(session) {
const peopleButton = await session.query(".mx_RoomSummaryCard_icon_people");
await peopleButton.click();
};
async function openMemberInfo(session, name) { async function openMemberInfo(session, name) {
const membersAndNames = await getMembersInMemberlist(session); const membersAndNames = await getMembersInMemberlist(session);
const matchingLabel = membersAndNames.filter((m) => { const matchingLabel = membersAndNames.filter((m) => {
@ -68,16 +63,26 @@ module.exports.verifyDeviceForUser = async function(session, name, expectedDevic
}; };
async function getMembersInMemberlist(session) { async function getMembersInMemberlist(session) {
const memberPanelButton = await session.query(".mx_RightPanel_membersButton");
try { try {
await session.query(".mx_RightPanel_headerButton_highlight", 500); await session.query('.mx_RoomHeader .mx_RightPanel_headerButton_highlight[aria-label="Room Info"]');
// Right panel is open - toggle it to ensure it's the member list
// Sometimes our tests have this opened to MemberInfo
await memberPanelButton.click();
await memberPanelButton.click();
} catch (e) { } catch (e) {
// Member list is closed - open it // If the room summary is not yet open, open it
const roomSummaryButton = await session.query('.mx_RoomHeader .mx_AccessibleButton[aria-label="Room Info"]');
await roomSummaryButton.click();
}
for (let i = 0; i < 5; i++) {
try {
const backButton = await session.query(".mx_BaseCard_back", 500);
// Right panel is open to the wrong thing - go back up to the Room Summary Card
// Sometimes our tests have this opened to MemberInfo
await backButton.click();
} catch (e) {
const memberPanelButton = await session.query(".mx_RoomSummaryCard_icon_people");
// We are back at the room summary card
await memberPanelButton.click(); await memberPanelButton.click();
break; // stop trying to go further back
}
} }
const memberNameElements = await session.queryAll(".mx_MemberList .mx_EntityTile_name"); const memberNameElements = await session.queryAll(".mx_MemberList .mx_EntityTile_name");
return Promise.all(memberNameElements.map(async (el) => { return Promise.all(memberNameElements.map(async (el) => {

View File

@ -16,11 +16,10 @@ limitations under the License.
*/ */
const assert = require('assert'); const assert = require('assert');
const {openMemberList, openMemberInfo} = require("./memberlist"); const {openMemberInfo} = require("./memberlist");
async function startVerification(session, name) { async function startVerification(session, name) {
session.log.step("opens their opponent's profile and starts verification"); session.log.step("opens their opponent's profile and starts verification");
await openMemberList(session);
await openMemberInfo(session, name); await openMemberInfo(session, name);
// click verify in member info // click verify in member info
const firstVerifyButton = await session.query(".mx_UserInfo_verifyButton"); const firstVerifyButton = await session.query(".mx_UserInfo_verifyButton");