Merge pull request #36 from matrix-org/bwindels/checkleavesmemberlist
test leaving members disappear from memberlist
This commit is contained in:
commit
240c715c84
3 changed files with 34 additions and 2 deletions
|
@ -59,6 +59,11 @@ module.exports = class RestMultiSession {
|
||||||
this.log.done();
|
this.log.done();
|
||||||
return new RestMultiRoom(rooms, roomIdOrAlias, this.log);
|
return new RestMultiRoom(rooms, roomIdOrAlias, this.log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
room(roomIdOrAlias) {
|
||||||
|
const rooms = this.sessions.map(s => s.room(roomIdOrAlias));
|
||||||
|
return new RestMultiRoom(rooms, roomIdOrAlias, this.log);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestMultiRoom {
|
class RestMultiRoom {
|
||||||
|
@ -82,7 +87,7 @@ class RestMultiRoom {
|
||||||
this.log.step(`leave ${this.roomIdOrAlias}`)
|
this.log.step(`leave ${this.roomIdOrAlias}`)
|
||||||
await Promise.all(this.rooms.map(async (r) => {
|
await Promise.all(this.rooms.map(async (r) => {
|
||||||
r.log.mute();
|
r.log.mute();
|
||||||
await r.leave(message);
|
await r.leave();
|
||||||
r.log.unmute();
|
r.log.unmute();
|
||||||
}));
|
}));
|
||||||
this.log.done();
|
this.log.done();
|
||||||
|
|
|
@ -24,6 +24,7 @@ module.exports = class RestSession {
|
||||||
this.log = new Logger(credentials.userId);
|
this.log = new Logger(credentials.userId);
|
||||||
this._credentials = credentials;
|
this._credentials = credentials;
|
||||||
this._displayName = null;
|
this._displayName = null;
|
||||||
|
this._rooms = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
userId() {
|
userId() {
|
||||||
|
@ -51,7 +52,18 @@ module.exports = class RestSession {
|
||||||
this.log.step(`joins ${roomIdOrAlias}`);
|
this.log.step(`joins ${roomIdOrAlias}`);
|
||||||
const {room_id} = await this._post(`/join/${encodeURIComponent(roomIdOrAlias)}`);
|
const {room_id} = await this._post(`/join/${encodeURIComponent(roomIdOrAlias)}`);
|
||||||
this.log.done();
|
this.log.done();
|
||||||
return new RestRoom(this, room_id, this.log);
|
const room = new RestRoom(this, room_id, this.log);
|
||||||
|
this._rooms[room_id] = room;
|
||||||
|
this._rooms[roomIdOrAlias] = room;
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
|
||||||
|
room(roomIdOrAlias) {
|
||||||
|
if (this._rooms.hasOwnProperty(roomIdOrAlias)) {
|
||||||
|
return this._rooms[roomIdOrAlias];
|
||||||
|
} else {
|
||||||
|
throw new Error(`${this._credentials.userId} is not in ${roomIdOrAlias}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async createRoom(name, options) {
|
async createRoom(name, options) {
|
||||||
|
|
|
@ -40,6 +40,10 @@ module.exports = async function lazyLoadingScenarios(alice, bob, charlies) {
|
||||||
await checkMemberList(alice, charly1to5);
|
await checkMemberList(alice, charly1to5);
|
||||||
await joinCharliesWhileAliceIsOffline(alice, charly6to10);
|
await joinCharliesWhileAliceIsOffline(alice, charly6to10);
|
||||||
await checkMemberList(alice, charly6to10);
|
await checkMemberList(alice, charly6to10);
|
||||||
|
await charlies.room(alias).leave();
|
||||||
|
await delay(1000);
|
||||||
|
await checkMemberListLacksCharlies(alice, charlies);
|
||||||
|
await checkMemberListLacksCharlies(bob, charlies);
|
||||||
}
|
}
|
||||||
|
|
||||||
const room = "Lazy Loading Test";
|
const room = "Lazy Loading Test";
|
||||||
|
@ -92,6 +96,17 @@ async function checkMemberList(alice, charlies) {
|
||||||
alice.log.done();
|
alice.log.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkMemberListLacksCharlies(session, charlies) {
|
||||||
|
session.log.step(`checks the memberlist doesn't contain ${charlies.log.username}`);
|
||||||
|
const displayNames = (await getMembersInMemberlist(session)).map((m) => m.displayName);
|
||||||
|
charlies.sessions.forEach((charly) => {
|
||||||
|
assert(!displayNames.includes(charly.displayName()),
|
||||||
|
`${charly.displayName()} should not be in the member list, ` +
|
||||||
|
`only have ${displayNames}`);
|
||||||
|
});
|
||||||
|
session.log.done();
|
||||||
|
}
|
||||||
|
|
||||||
async function joinCharliesWhileAliceIsOffline(alice, charly6to10) {
|
async function joinCharliesWhileAliceIsOffline(alice, charly6to10) {
|
||||||
await alice.setOffline(true);
|
await alice.setOffline(true);
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
|
|
Loading…
Reference in a new issue