diff --git a/src/rest/multi.js b/src/rest/multi.js index 35bb11a0cf..3d24245ddf 100644 --- a/src/rest/multi.js +++ b/src/rest/multi.js @@ -25,7 +25,7 @@ module.exports = class RestMultiSession { this.sessions = sessions; } - slice(start, end, groupName) { + slice(groupName, start, end) { return new RestMultiSession(this.sessions.slice(start, end), groupName); } diff --git a/src/scenarios/lazy-loading.js b/src/scenarios/lazy-loading.js index bd7c1d1507..a606cc0421 100644 --- a/src/scenarios/lazy-loading.js +++ b/src/scenarios/lazy-loading.js @@ -31,9 +31,15 @@ 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 charly1to5 = charlies.slice("charly-1..5", 0, 5); + const charly6to10 = charlies.slice("charly-6..10", 5); + assert(charly1to5.sessions.length, 5); + assert(charly6to10.sessions.length, 5); + await setupRoomWithBobAliceAndCharlies(alice, bob, charly1to5); + await checkPaginatedDisplayNames(alice, charly1to5); + await checkMemberList(alice, charly1to5); + await joinCharliesWhileAliceIsOffline(alice, charly6to10); + await checkMemberList(alice, charly6to10); } const room = "Lazy Loading Test"; @@ -70,7 +76,7 @@ async function checkPaginatedDisplayNames(alice, charlies) { }); }, messages); }, []); - await checkTimelineContains(alice, expectedMessages, "Charly #1-10"); + await checkTimelineContains(alice, expectedMessages, "Charly #1-5"); } async function checkMemberList(alice, charlies) { @@ -85,3 +91,18 @@ async function checkMemberList(alice, charlies) { }); alice.log.done(); } + +async function joinCharliesWhileAliceIsOffline(alice, charly6to10) { + await alice.setOffline(true); + await delay(1000); + const members6to10 = await charly6to10.join(alias); + const member6 = members6to10.rooms[0]; + member6.log.step("sends 20 messages").mute(); + for(let i = 20; i >= 1; --i) { + await member6.talk("where is charly?"); + } + member6.log.unmute().done(); + await delay(1000); + await alice.setOffline(false); + await delay(1000); +} diff --git a/src/session.js b/src/session.js index 3f233ee8f2..82a66fda39 100644 --- a/src/session.js +++ b/src/session.js @@ -173,6 +173,13 @@ module.exports = class RiotSession { return delay(ms); } + async setOffline(enabled) { + const description = enabled ? "offline" : "back online"; + this.log.step(`goes ${description}`); + await this.page.setOfflineMode(enabled); + this.log.done(); + } + close() { return this.browser.close(); }