diff --git a/test/end-to-end-tests/src/usecases/memberlist.js b/test/end-to-end-tests/src/usecases/memberlist.js index 1f166d6ccf..c3b4d65351 100644 --- a/test/end-to-end-tests/src/usecases/memberlist.js +++ b/test/end-to-end-tests/src/usecases/memberlist.js @@ -16,6 +16,7 @@ limitations under the License. */ const assert = require('assert'); +const {openRoomSummaryCard} = require("./rightpanel"); async function openMemberInfo(session, name) { const membersAndNames = await getMembersInMemberlist(session); @@ -63,27 +64,8 @@ module.exports.verifyDeviceForUser = async function(session, name, expectedDevic }; async function getMembersInMemberlist(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(); - } + await openRoomSummaryCard(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 - } - } const memberNameElements = await session.queryAll(".mx_MemberList .mx_EntityTile_name"); return Promise.all(memberNameElements.map(async (el) => { return {label: el, displayName: await session.innerText(el)}; diff --git a/test/end-to-end-tests/src/usecases/rightpanel.js b/test/end-to-end-tests/src/usecases/rightpanel.js new file mode 100644 index 0000000000..42ecff1c6a --- /dev/null +++ b/test/end-to-end-tests/src/usecases/rightpanel.js @@ -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); +}; diff --git a/test/end-to-end-tests/src/usecases/room-settings.js b/test/end-to-end-tests/src/usecases/room-settings.js index f5fb37167c..abd4488db2 100644 --- a/test/end-to-end-tests/src/usecases/room-settings.js +++ b/test/end-to-end-tests/src/usecases/room-settings.js @@ -16,6 +16,7 @@ limitations under the License. */ const assert = require('assert'); +const {openRoomSummaryCard} = require("./rightpanel"); const {acceptDialog} = require('./dialog'); 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 /// click doesn't do anything otherwise 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"); await settingsButton.click();