From 4c0ab117bfab1ce4c4caebe83c5f67c1e7488feb Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 7 Aug 2018 17:16:27 +0200 Subject: [PATCH] move outputting steps to session to scope it to username --- src/session.js | 15 +++++++++++++++ start.js | 14 +++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/session.js b/src/session.js index f8f41b20b8..5b0f78ccd3 100644 --- a/src/session.js +++ b/src/session.js @@ -31,6 +31,20 @@ class LogBuffer { } } +class Logger { + constructor(username) { + this.username = username; + } + + step(description) { + process.stdout.write(` * ${this.username} ${description} ... `); + } + + done() { + process.stdout.write("done\n"); + } +} + module.exports = class RiotSession { constructor(browser, page, username, riotserver) { this.browser = browser; @@ -43,6 +57,7 @@ module.exports = class RiotSession { const response = await req.response(); return `${type} ${response.status()} ${req.method()} ${req.url()} \n`; }, true); + this.log = new Logger(this.username); } static async create(username, puppeteerOptions, riotserver) { diff --git a/start.js b/start.js index 0aa2cb9364..9b0ed716e0 100644 --- a/start.js +++ b/start.js @@ -39,19 +39,19 @@ async function runTests() { const alice = await RiotSession.create("alice", options, riotserver); sessions.push(alice); - process.stdout.write(`* signing up as ${alice.username} ... `); + alice.log.step("signs up"); await signup(alice, alice.username, 'testtest'); - process.stdout.write('done\n'); - + alice.log.done(); + const noticesName = "Server Notices"; - process.stdout.write(`* accepting "${noticesName}" and accepting terms & conditions ... `); + alice.log.step(`accepts "${noticesName}" invite and accepting terms & conditions`); await acceptServerNoticesInviteAndConsent(alice, noticesName); - process.stdout.write('done\n'); + alice.log.done(); const room = 'test'; - process.stdout.write(`* creating room ${room} ... `); + alice.log.step(`creates room ${room}`); await createRoom(alice, room); - process.stdout.write('done\n'); + alice.log.done(); await alice.close(); }