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.
This commit is contained in:
Bruno Windels 2018-09-13 12:03:29 +02:00
parent 5d06c65ce5
commit 239e6a4bce
3 changed files with 33 additions and 11 deletions

View File

@ -25,7 +25,7 @@ const {receiveMessage} = require('../usecases/timeline');
const createRoom = require('../usecases/create-room'); const createRoom = require('../usecases/create-room');
const changeRoomSettings = require('../usecases/room-settings'); const changeRoomSettings = require('../usecases/room-settings');
const {getE2EDeviceFromSettings} = require('../usecases/settings'); const {getE2EDeviceFromSettings} = require('../usecases/settings');
const verifyDeviceForUser = require('../usecases/verify-device'); const {verifyDeviceForUser} = require('../usecases/memberlist');
module.exports = async function e2eEncryptionScenarios(alice, bob) { module.exports = async function e2eEncryptionScenarios(alice, bob) {
console.log(" creating an e2e encrypted room and join through invite:"); console.log(" creating an e2e encrypted room and join through invite:");

View File

@ -23,14 +23,17 @@ const {
scrollToTimelineTop scrollToTimelineTop
} = require('../usecases/timeline'); } = require('../usecases/timeline');
const createRoom = require('../usecases/create-room'); const createRoom = require('../usecases/create-room');
const {getMembersInMemberlist} = require('../usecases/memberlist');
const changeRoomSettings = require('../usecases/room-settings'); const changeRoomSettings = require('../usecases/room-settings');
const {enableLazyLoading} = require('../usecases/settings'); const {enableLazyLoading} = require('../usecases/settings');
const assert = require('assert');
module.exports = async function lazyLoadingScenarios(alice, bob, charlies) { module.exports = async function lazyLoadingScenarios(alice, bob, charlies) {
console.log(" creating a room for lazy loading member scenarios:"); console.log(" creating a room for lazy loading member scenarios:");
await enableLazyLoading(alice); await enableLazyLoading(alice);
await setupRoomWithBobAliceAndCharlies(alice, bob, charlies); await setupRoomWithBobAliceAndCharlies(alice, bob, charlies);
await checkPaginatedDisplayNames(alice, charlies); await checkPaginatedDisplayNames(alice, charlies);
await checkMemberList(alice, charlies);
} }
const room = "Lazy Loading Test"; const room = "Lazy Loading Test";
@ -69,3 +72,16 @@ async function checkPaginatedDisplayNames(alice, charlies) {
}, []); }, []);
await checkTimelineContains(alice, expectedMessages, "Charly #1-10"); 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();
}

View File

@ -16,16 +16,13 @@ limitations under the License.
const assert = require('assert'); 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}`); session.log.step(`verifies e2e device for ${name}`);
const memberNameElements = await session.queryAll(".mx_MemberList .mx_EntityTile_name"); const membersAndNames = await getMembersInMemberlist(session);
const membersAndNames = await Promise.all(memberNameElements.map(async (el) => { const matchingLabel = membersAndNames.filter((m) => {
return [el, await session.innerText(el)]; return m.displayName === name;
})); }).map((m) => m.label)[0];
const matchingMember = membersAndNames.filter(([el, text]) => { await matchingLabel.click();
return text === name;
}).map(([el]) => el)[0];
await matchingMember.click();
const firstVerifyButton = await session.waitAndQuery(".mx_MemberDeviceInfo_verify"); const firstVerifyButton = await session.waitAndQuery(".mx_MemberDeviceInfo_verify");
await firstVerifyButton.click(); await firstVerifyButton.click();
const dialogCodeFields = await session.waitAndQueryAll(".mx_QuestionDialog code"); const dialogCodeFields = await session.waitAndQueryAll(".mx_QuestionDialog code");
@ -40,3 +37,12 @@ module.exports = async function verifyDeviceForUser(session, name, expectedDevic
await closeMemberInfo.click(); await closeMemberInfo.click();
session.log.done(); session.log.done();
} }
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;