This commit is contained in:
Michael Telatynski 2020-09-09 12:55:16 +01:00
parent 8d66dce68d
commit d9e17e89b5
3 changed files with 52 additions and 22 deletions

View file

@ -16,6 +16,7 @@ limitations under the License.
*/ */
const assert = require('assert'); const assert = require('assert');
const {openRoomSummaryCard} = require("./rightpanel");
async function openMemberInfo(session, name) { async function openMemberInfo(session, name) {
const membersAndNames = await getMembersInMemberlist(session); const membersAndNames = await getMembersInMemberlist(session);
@ -63,27 +64,8 @@ module.exports.verifyDeviceForUser = async function(session, name, expectedDevic
}; };
async function getMembersInMemberlist(session) { async function getMembersInMemberlist(session) {
try { await openRoomSummaryCard(session);
await session.query('.mx_RoomHeader .mx_RightPanel_headerButton_highlight[aria-label="Room Info"]');
} catch (e) {
// 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();
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) => {
return {label: el, displayName: await session.innerText(el)}; return {label: el, displayName: await session.innerText(el)};

View file

@ -0,0 +1,46 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
module.exports.openRoomRightPanel = async function(session) {
try {
await session.query('.mx_RoomHeader .mx_RightPanel_headerButton_highlight[aria-label="Room Info"]');
} catch (e) {
// 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();
}
};
module.exports.goBackToRoomSummaryCard = async function(session) {
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();
break; // stop trying to go further back
}
}
};
module.exports.openRoomSummaryCard = async function(session) {
await module.exports.openRoomRightPanel(session);
await module.exports.goBackToRoomSummaryCard(session);
};

View file

@ -16,6 +16,7 @@ limitations under the License.
*/ */
const assert = require('assert'); const assert = require('assert');
const {openRoomSummaryCard} = require("./rightpanel");
const {acceptDialog} = require('./dialog'); const {acceptDialog} = require('./dialog');
async function setSettingsToggle(session, toggle, enabled) { async function setSettingsToggle(session, toggle, enabled) {
@ -45,8 +46,9 @@ async function findTabs(session) {
/// XXX delay is needed here, possibly because the header is being rerendered /// XXX delay is needed here, possibly because the header is being rerendered
/// click doesn't do anything otherwise /// click doesn't do anything otherwise
await session.delay(1000); await session.delay(1000);
const roomSummaryButton = await session.query('.mx_RoomHeader .mx_AccessibleButton[aria-label="Room Info"]');
await roomSummaryButton.click(); await openRoomSummaryCard(session);
const settingsButton = await session.query(".mx_RoomSummaryCard_icon_settings"); const settingsButton = await session.query(".mx_RoomSummaryCard_icon_settings");
await settingsButton.click(); await settingsButton.click();