From 239e6a4bcef1a92aa69d48923b8f46e072d8c00c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 13 Sep 2018 12:03:29 +0200 Subject: [PATCH] add ll tests to check if all expected members are in memberlist also move verify-device use case to timeline to reuse memberlist query for this test. --- src/scenarios/e2e-encryption.js | 2 +- src/scenarios/lazy-loading.js | 16 ++++++++++++ .../{verify-device.js => memberlist.js} | 26 ++++++++++++------- 3 files changed, 33 insertions(+), 11 deletions(-) rename src/usecases/{verify-device.js => memberlist.js} (68%) diff --git a/src/scenarios/e2e-encryption.js b/src/scenarios/e2e-encryption.js index 938dc5e592..51d8a70236 100644 --- a/src/scenarios/e2e-encryption.js +++ b/src/scenarios/e2e-encryption.js @@ -25,7 +25,7 @@ const {receiveMessage} = require('../usecases/timeline'); const createRoom = require('../usecases/create-room'); const changeRoomSettings = require('../usecases/room-settings'); const {getE2EDeviceFromSettings} = require('../usecases/settings'); -const verifyDeviceForUser = require('../usecases/verify-device'); +const {verifyDeviceForUser} = require('../usecases/memberlist'); module.exports = async function e2eEncryptionScenarios(alice, bob) { console.log(" creating an e2e encrypted room and join through invite:"); diff --git a/src/scenarios/lazy-loading.js b/src/scenarios/lazy-loading.js index 0adb3fc793..bd7c1d1507 100644 --- a/src/scenarios/lazy-loading.js +++ b/src/scenarios/lazy-loading.js @@ -23,14 +23,17 @@ const { scrollToTimelineTop } = require('../usecases/timeline'); const createRoom = require('../usecases/create-room'); +const {getMembersInMemberlist} = require('../usecases/memberlist'); const changeRoomSettings = require('../usecases/room-settings'); const {enableLazyLoading} = require('../usecases/settings'); +const assert = require('assert'); module.exports = async function lazyLoadingScenarios(alice, bob, charlies) { console.log(" creating a room for lazy loading member scenarios:"); await enableLazyLoading(alice); await setupRoomWithBobAliceAndCharlies(alice, bob, charlies); await checkPaginatedDisplayNames(alice, charlies); + await checkMemberList(alice, charlies); } const room = "Lazy Loading Test"; @@ -69,3 +72,16 @@ async function checkPaginatedDisplayNames(alice, charlies) { }, []); await checkTimelineContains(alice, expectedMessages, "Charly #1-10"); } + +async function checkMemberList(alice, charlies) { + alice.log.step("checks the memberlist contains herself, bob and all charlies"); + const displayNames = (await getMembersInMemberlist(alice)).map((m) => m.displayName); + assert(displayNames.includes("alice")); + assert(displayNames.includes("bob")); + charlies.sessions.forEach((charly) => { + assert(displayNames.includes(charly.displayName()), + `${charly.displayName()} should be in the member list, ` + + `only have ${displayNames}`); + }); + alice.log.done(); +} diff --git a/src/usecases/verify-device.js b/src/usecases/memberlist.js similarity index 68% rename from src/usecases/verify-device.js rename to src/usecases/memberlist.js index 7b01e7c756..b018ed552c 100644 --- a/src/usecases/verify-device.js +++ b/src/usecases/memberlist.js @@ -16,16 +16,13 @@ limitations under the License. const assert = require('assert'); -module.exports = async function verifyDeviceForUser(session, name, expectedDevice) { +module.exports.verifyDeviceForUser = async function(session, name, expectedDevice) { session.log.step(`verifies e2e device for ${name}`); - const memberNameElements = await session.queryAll(".mx_MemberList .mx_EntityTile_name"); - const membersAndNames = await Promise.all(memberNameElements.map(async (el) => { - return [el, await session.innerText(el)]; - })); - const matchingMember = membersAndNames.filter(([el, text]) => { - return text === name; - }).map(([el]) => el)[0]; - await matchingMember.click(); + const membersAndNames = await getMembersInMemberlist(session); + const matchingLabel = membersAndNames.filter((m) => { + return m.displayName === name; + }).map((m) => m.label)[0]; + await matchingLabel.click(); const firstVerifyButton = await session.waitAndQuery(".mx_MemberDeviceInfo_verify"); await firstVerifyButton.click(); const dialogCodeFields = await session.waitAndQueryAll(".mx_QuestionDialog code"); @@ -39,4 +36,13 @@ module.exports = async function verifyDeviceForUser(session, name, expectedDevic const closeMemberInfo = await session.query(".mx_MemberInfo_cancel"); await closeMemberInfo.click(); session.log.done(); -} \ No newline at end of file +} + +async function getMembersInMemberlist(session) { + const memberNameElements = await session.waitAndQueryAll(".mx_MemberList .mx_EntityTile_name"); + return Promise.all(memberNameElements.map(async (el) => { + return {label: el, displayName: await session.innerText(el)}; + })); +} + +module.exports.getMembersInMemberlist = getMembersInMemberlist;