From 2d848bba298873962327ab76407baf38b10eeb52 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 9 Oct 2019 17:51:50 +0200 Subject: [PATCH] fix lint --- test/end-to-end-tests/src/logbuffer.js | 5 ++-- test/end-to-end-tests/src/logger.js | 2 +- test/end-to-end-tests/src/rest/creator.js | 10 ++++---- test/end-to-end-tests/src/rest/multi.js | 17 ++++++-------- test/end-to-end-tests/src/rest/room.js | 8 +++---- test/end-to-end-tests/src/rest/session.js | 23 +++++++++---------- test/end-to-end-tests/src/scenario.js | 2 +- .../src/scenarios/directory.js | 4 ++-- .../src/scenarios/e2e-encryption.js | 8 ++----- .../src/scenarios/lazy-loading.js | 9 ++++---- test/end-to-end-tests/src/session.js | 18 +++++++-------- .../src/usecases/accept-invite.js | 5 +--- .../src/usecases/create-room.js | 2 -- test/end-to-end-tests/src/usecases/dialog.js | 2 +- test/end-to-end-tests/src/usecases/invite.js | 4 +--- test/end-to-end-tests/src/usecases/join.js | 3 +-- .../src/usecases/memberlist.js | 9 ++++---- .../src/usecases/room-settings.js | 2 +- .../src/usecases/send-message.js | 2 +- .../end-to-end-tests/src/usecases/settings.js | 7 +++--- test/end-to-end-tests/src/usecases/signup.js | 6 ++--- .../end-to-end-tests/src/usecases/timeline.js | 16 ++++++------- test/end-to-end-tests/src/usecases/verify.js | 3 ++- test/end-to-end-tests/src/util.js | 4 ++-- test/end-to-end-tests/start.js | 13 +++++------ 25 files changed, 84 insertions(+), 100 deletions(-) diff --git a/test/end-to-end-tests/src/logbuffer.js b/test/end-to-end-tests/src/logbuffer.js index 8bf6285e25..d586dc8b84 100644 --- a/test/end-to-end-tests/src/logbuffer.js +++ b/test/end-to-end-tests/src/logbuffer.js @@ -21,10 +21,9 @@ module.exports = class LogBuffer { const result = eventMapper(arg); if (reduceAsync) { result.then((r) => this.buffer += r); - } - else { + } else { this.buffer += result; } }); } -} +}; diff --git a/test/end-to-end-tests/src/logger.js b/test/end-to-end-tests/src/logger.js index be3ebde75b..283d07f163 100644 --- a/test/end-to-end-tests/src/logger.js +++ b/test/end-to-end-tests/src/logger.js @@ -59,4 +59,4 @@ module.exports = class Logger { this.muted = false; return this; } -} +}; diff --git a/test/end-to-end-tests/src/rest/creator.js b/test/end-to-end-tests/src/rest/creator.js index 31c352b31a..fde54014b2 100644 --- a/test/end-to-end-tests/src/rest/creator.js +++ b/test/end-to-end-tests/src/rest/creator.js @@ -57,13 +57,13 @@ module.exports = class RestSessionCreator { `-u ${username}`, `-p ${password}`, '--no-admin', - this.hsUrl + this.hsUrl, ]; const registerCmd = `./register_new_matrix_user ${registerArgs.join(' ')}`; const allCmds = [ `cd ${this.synapseSubdir}`, ". ./activate", - registerCmd + registerCmd, ].join(' && '); await execAsync(allCmds, {cwd: this.cwd, encoding: 'utf-8'}); @@ -74,9 +74,9 @@ module.exports = class RestSessionCreator { "type": "m.login.password", "identifier": { "type": "m.id.user", - "user": username + "user": username, }, - "password": password + "password": password, }; const url = `${this.hsUrl}/_matrix/client/r0/login`; const responseBody = await request.post({url, json: true, body: requestBody}); @@ -88,4 +88,4 @@ module.exports = class RestSessionCreator { hsUrl: this.hsUrl, }; } -} +}; diff --git a/test/end-to-end-tests/src/rest/multi.js b/test/end-to-end-tests/src/rest/multi.js index b930a27c1e..e58b9f3f57 100644 --- a/test/end-to-end-tests/src/rest/multi.js +++ b/test/end-to-end-tests/src/rest/multi.js @@ -14,9 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -const request = require('request-promise-native'); -const RestRoom = require('./room'); -const {approveConsent} = require('./consent'); const Logger = require('../logger'); module.exports = class RestMultiSession { @@ -31,7 +28,7 @@ module.exports = class RestMultiSession { pop(userName) { const idx = this.sessions.findIndex((s) => s.userName() === userName); - if(idx === -1) { + if (idx === -1) { throw new Error(`user ${userName} not found`); } const session = this.sessions.splice(idx, 1)[0]; @@ -39,7 +36,7 @@ module.exports = class RestMultiSession { } async setDisplayName(fn) { - this.log.step("set their display name") + this.log.step("set their display name"); await Promise.all(this.sessions.map(async (s) => { s.log.mute(); await s.setDisplayName(fn(s)); @@ -49,10 +46,10 @@ module.exports = class RestMultiSession { } async join(roomIdOrAlias) { - this.log.step(`join ${roomIdOrAlias}`) + this.log.step(`join ${roomIdOrAlias}`); const rooms = await Promise.all(this.sessions.map(async (s) => { s.log.mute(); - const room = await s.join(roomIdOrAlias); + const room = await s.join(roomIdOrAlias); s.log.unmute(); return room; })); @@ -64,7 +61,7 @@ module.exports = class RestMultiSession { const rooms = this.sessions.map(s => s.room(roomIdOrAlias)); return new RestMultiRoom(rooms, roomIdOrAlias, this.log); } -} +}; class RestMultiRoom { constructor(rooms, roomIdOrAlias, log) { @@ -74,7 +71,7 @@ class RestMultiRoom { } async talk(message) { - this.log.step(`say "${message}" in ${this.roomIdOrAlias}`) + this.log.step(`say "${message}" in ${this.roomIdOrAlias}`); await Promise.all(this.rooms.map(async (r) => { r.log.mute(); await r.talk(message); @@ -84,7 +81,7 @@ class RestMultiRoom { } async leave() { - this.log.step(`leave ${this.roomIdOrAlias}`) + this.log.step(`leave ${this.roomIdOrAlias}`); await Promise.all(this.rooms.map(async (r) => { r.log.mute(); await r.leave(); diff --git a/test/end-to-end-tests/src/rest/room.js b/test/end-to-end-tests/src/rest/room.js index a7f40af594..429a29c31a 100644 --- a/test/end-to-end-tests/src/rest/room.js +++ b/test/end-to-end-tests/src/rest/room.js @@ -25,18 +25,18 @@ module.exports = class RestRoom { } async talk(message) { - this.log.step(`says "${message}" in ${this._roomId}`) + this.log.step(`says "${message}" in ${this._roomId}`); const txId = uuidv4(); await this.session._put(`/rooms/${this._roomId}/send/m.room.message/${txId}`, { "msgtype": "m.text", - "body": message + "body": message, }); this.log.done(); return txId; } async leave() { - this.log.step(`leaves ${this._roomId}`) + this.log.step(`leaves ${this._roomId}`); await this.session._post(`/rooms/${this._roomId}/leave`); this.log.done(); } @@ -44,4 +44,4 @@ module.exports = class RestRoom { roomId() { return this._roomId; } -} +}; diff --git a/test/end-to-end-tests/src/rest/session.js b/test/end-to-end-tests/src/rest/session.js index de05cd4b5c..2e29903800 100644 --- a/test/end-to-end-tests/src/rest/session.js +++ b/test/end-to-end-tests/src/rest/session.js @@ -43,17 +43,17 @@ module.exports = class RestSession { this.log.step(`sets their display name to ${displayName}`); this._displayName = displayName; await this._put(`/profile/${this._credentials.userId}/displayname`, { - displayname: displayName + displayname: displayName, }); this.log.done(); } async join(roomIdOrAlias) { this.log.step(`joins ${roomIdOrAlias}`); - const {room_id} = await this._post(`/join/${encodeURIComponent(roomIdOrAlias)}`); + const roomId = await this._post(`/join/${encodeURIComponent(roomIdOrAlias)}`).room_id; this.log.done(); - const room = new RestRoom(this, room_id, this.log); - this._rooms[room_id] = room; + const room = new RestRoom(this, roomId, this.log); + this._rooms[roomId] = room; this._rooms[roomIdOrAlias] = room; return room; } @@ -86,9 +86,9 @@ module.exports = class RestSession { body.topic = options.topic; } - const {room_id} = await this._post(`/createRoom`, body); + const roomId = await this._post(`/createRoom`, body).room_id; this.log.done(); - return new RestRoom(this, room_id, this.log); + return new RestRoom(this, roomId, this.log); } _post(csApiPath, body) { @@ -105,23 +105,22 @@ module.exports = class RestSession { url: `${this._credentials.hsUrl}/_matrix/client/r0${csApiPath}`, method, headers: { - "Authorization": `Bearer ${this._credentials.accessToken}` + "Authorization": `Bearer ${this._credentials.accessToken}`, }, json: true, - body + body, }); return responseBody; - - } catch(err) { + } catch (err) { const responseBody = err.response.body; if (responseBody.errcode === 'M_CONSENT_NOT_GIVEN') { await approveConsent(responseBody.consent_uri); return this._request(method, csApiPath, body); - } else if(responseBody && responseBody.error) { + } else if (responseBody && responseBody.error) { throw new Error(`${method} ${csApiPath}: ${responseBody.error}`); } else { throw new Error(`${method} ${csApiPath}: ${err.response.statusCode}`); } } } -} +}; diff --git a/test/end-to-end-tests/src/scenario.js b/test/end-to-end-tests/src/scenario.js index 1ad177a4f5..f575fb392e 100644 --- a/test/end-to-end-tests/src/scenario.js +++ b/test/end-to-end-tests/src/scenario.js @@ -42,7 +42,7 @@ module.exports = async function scenario(createSession, restCreator) { console.log("create REST users:"); const charlies = await createRestUsers(restCreator); await lazyLoadingScenarios(alice, bob, charlies); -} +}; async function createRestUsers(restCreator) { const usernames = range(1, 10).map((i) => `charly-${i}`); diff --git a/test/end-to-end-tests/src/scenarios/directory.js b/test/end-to-end-tests/src/scenarios/directory.js index 582b6867b2..3ae728a5b7 100644 --- a/test/end-to-end-tests/src/scenarios/directory.js +++ b/test/end-to-end-tests/src/scenarios/directory.js @@ -30,7 +30,7 @@ module.exports = async function roomDirectoryScenarios(alice, bob) { const bobMessage = "hi Alice!"; await sendMessage(bob, bobMessage); await receiveMessage(alice, {sender: "bob", body: bobMessage}); - const aliceMessage = "hi Bob, welcome!" + const aliceMessage = "hi Bob, welcome!"; await sendMessage(alice, aliceMessage); await receiveMessage(bob, {sender: "alice", body: aliceMessage}); -} +}; diff --git a/test/end-to-end-tests/src/scenarios/e2e-encryption.js b/test/end-to-end-tests/src/scenarios/e2e-encryption.js index 29b97f2047..8df374bacb 100644 --- a/test/end-to-end-tests/src/scenarios/e2e-encryption.js +++ b/test/end-to-end-tests/src/scenarios/e2e-encryption.js @@ -14,10 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ - -const {delay} = require('../util'); -const {acceptDialogMaybe} = require('../usecases/dialog'); -const join = require('../usecases/join'); const sendMessage = require('../usecases/send-message'); const acceptInvite = require('../usecases/accept-invite'); const invite = require('../usecases/invite'); @@ -43,10 +39,10 @@ module.exports = async function e2eEncryptionScenarios(alice, bob) { const [bobSas, aliceSas] = await Promise.all([bobSasPromise, aliceSasPromise]); assert.deepEqual(bobSas, aliceSas); bob.log.done(`done (match for ${bobSas.join(", ")})`); - const aliceMessage = "Guess what I just heard?!" + const aliceMessage = "Guess what I just heard?!"; await sendMessage(alice, aliceMessage); await receiveMessage(bob, {sender: "alice", body: aliceMessage, encrypted: true}); const bobMessage = "You've got to tell me!"; await sendMessage(bob, bobMessage); await receiveMessage(alice, {sender: "bob", body: bobMessage, encrypted: true}); -} +}; diff --git a/test/end-to-end-tests/src/scenarios/lazy-loading.js b/test/end-to-end-tests/src/scenarios/lazy-loading.js index f924f78cf1..be5a91bb71 100644 --- a/test/end-to-end-tests/src/scenarios/lazy-loading.js +++ b/test/end-to-end-tests/src/scenarios/lazy-loading.js @@ -20,12 +20,11 @@ const join = require('../usecases/join'); const sendMessage = require('../usecases/send-message'); const { checkTimelineContains, - scrollToTimelineTop + 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) { @@ -43,7 +42,7 @@ module.exports = async function lazyLoadingScenarios(alice, bob, charlies) { await delay(1000); await checkMemberListLacksCharlies(alice, charlies); await checkMemberListLacksCharlies(bob, charlies); -} +}; const room = "Lazy Loading Test"; const alias = "#lltest:localhost"; @@ -60,7 +59,7 @@ async function setupRoomWithBobAliceAndCharlies(alice, bob, charlies) { await charlyMembers.talk(charlyMsg1); await charlyMembers.talk(charlyMsg2); bob.log.step("sends 20 messages").mute(); - for(let i = 20; i >= 1; --i) { + for (let i = 20; i >= 1; --i) { await sendMessage(bob, `I will only say this ${i} time(s)!`); } bob.log.unmute().done(); @@ -112,7 +111,7 @@ async function joinCharliesWhileAliceIsOffline(alice, charly6to10) { 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) { + for (let i = 20; i >= 1; --i) { await member6.talk("where is charly?"); } member6.log.unmute().done(); diff --git a/test/end-to-end-tests/src/session.js b/test/end-to-end-tests/src/session.js index d3c26c07e4..65cec6fef0 100644 --- a/test/end-to-end-tests/src/session.js +++ b/test/end-to-end-tests/src/session.js @@ -42,7 +42,7 @@ module.exports = class RiotSession { const page = await browser.newPage(); await page.setViewport({ width: 1280, - height: 800 + height: 800, }); if (throttleCpuFactor !== 1) { const client = await page.target().createCDPSession(); @@ -55,8 +55,8 @@ module.exports = class RiotSession { async tryGetInnertext(selector) { const field = await this.page.$(selector); if (field != null) { - const text_handle = await field.getProperty('innerText'); - return await text_handle.jsonValue(); + const textHandle = await field.getProperty('innerText'); + return await textHandle.jsonValue(); } return null; } @@ -70,7 +70,7 @@ module.exports = class RiotSession { return this.getElementProperty(field, 'innerText'); } - getOuterHTML(element_handle) { + getOuterHTML(field) { return this.getElementProperty(field, 'outerHTML'); } @@ -97,12 +97,12 @@ module.exports = class RiotSession { return { logs() { return buffer; - } - } + }, + }; } async printElements(label, elements) { - console.log(label, await Promise.all(elements.map(getOuterHTML))); + console.log(label, await Promise.all(elements.map(this.getOuterHTML))); } async replaceInputText(input, text) { @@ -210,7 +210,7 @@ module.exports = class RiotSession { async poll(callback, interval = 100) { const timeout = DEFAULT_TIMEOUT; let waited = 0; - while(waited < timeout) { + while (waited < timeout) { await this.delay(interval); waited += interval; if (await callback()) { @@ -219,4 +219,4 @@ module.exports = class RiotSession { } return false; } -} +}; diff --git a/test/end-to-end-tests/src/usecases/accept-invite.js b/test/end-to-end-tests/src/usecases/accept-invite.js index bcecf41ed2..085c60aa6a 100644 --- a/test/end-to-end-tests/src/usecases/accept-invite.js +++ b/test/end-to-end-tests/src/usecases/accept-invite.js @@ -14,9 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -const assert = require('assert'); -const {acceptDialogMaybe} = require('./dialog'); - module.exports = async function acceptInvite(session, name) { session.log.step(`accepts "${name}" invite`); //TODO: brittle selector @@ -35,4 +32,4 @@ module.exports = async function acceptInvite(session, name) { await acceptInvitationLink.click(); session.log.done(); -} +}; diff --git a/test/end-to-end-tests/src/usecases/create-room.js b/test/end-to-end-tests/src/usecases/create-room.js index 88547610f0..75abdc78f4 100644 --- a/test/end-to-end-tests/src/usecases/create-room.js +++ b/test/end-to-end-tests/src/usecases/create-room.js @@ -14,8 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -const assert = require('assert'); - async function openRoomDirectory(session) { const roomDirectoryButton = await session.query('.mx_LeftPanel_explore .mx_AccessibleButton'); await roomDirectoryButton.click(); diff --git a/test/end-to-end-tests/src/usecases/dialog.js b/test/end-to-end-tests/src/usecases/dialog.js index 58f135de04..7b5d4d09fa 100644 --- a/test/end-to-end-tests/src/usecases/dialog.js +++ b/test/end-to-end-tests/src/usecases/dialog.js @@ -33,7 +33,7 @@ async function acceptDialogMaybe(session, expectedTitle) { let primaryButton = null; try { primaryButton = await session.query(".mx_Dialog .mx_Dialog_primary"); - } catch(err) { + } catch (err) { return false; } if (expectedTitle) { diff --git a/test/end-to-end-tests/src/usecases/invite.js b/test/end-to-end-tests/src/usecases/invite.js index 7b3f8a2b48..d7e02a38d8 100644 --- a/test/end-to-end-tests/src/usecases/invite.js +++ b/test/end-to-end-tests/src/usecases/invite.js @@ -14,8 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -const assert = require('assert'); - module.exports = async function invite(session, userId) { session.log.step(`invites "${userId}" to room`); await session.delay(1000); @@ -27,4 +25,4 @@ module.exports = async function invite(session, userId) { const confirmButton = await session.query(".mx_Dialog_primary"); await confirmButton.click(); session.log.done(); -} +}; diff --git a/test/end-to-end-tests/src/usecases/join.js b/test/end-to-end-tests/src/usecases/join.js index 3c14a76143..bc292a0768 100644 --- a/test/end-to-end-tests/src/usecases/join.js +++ b/test/end-to-end-tests/src/usecases/join.js @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -const assert = require('assert'); const {openRoomDirectory} = require('./create-room'); module.exports = async function join(session, roomName) { @@ -27,4 +26,4 @@ module.exports = async function join(session, roomName) { await joinFirstLink.click(); await session.query('.mx_MessageComposer'); session.log.done(); -} +}; diff --git a/test/end-to-end-tests/src/usecases/memberlist.js b/test/end-to-end-tests/src/usecases/memberlist.js index 5858e82bb8..f6b07b3500 100644 --- a/test/end-to-end-tests/src/usecases/memberlist.js +++ b/test/end-to-end-tests/src/usecases/memberlist.js @@ -22,7 +22,7 @@ async function openMemberInfo(session, name) { return m.displayName === name; }).map((m) => m.label)[0]; await matchingLabel.click(); -}; +} module.exports.openMemberInfo = openMemberInfo; @@ -39,10 +39,11 @@ module.exports.verifyDeviceForUser = async function(session, name, expectedDevic // expect "Verify device" dialog and click "Begin Verification" const dialogHeader = await session.innerText(await session.query(".mx_Dialog .mx_Dialog_title")); assert(dialogHeader, "Verify device"); - const beginVerificationButton = await session.query(".mx_Dialog .mx_Dialog_primary") + const beginVerificationButton = await session.query(".mx_Dialog .mx_Dialog_primary"); await beginVerificationButton.click(); // get emoji SAS labels - const sasLabelElements = await session.queryAll(".mx_VerificationShowSas .mx_VerificationShowSas_emojiSas .mx_VerificationShowSas_emojiSas_label"); + const sasLabelElements = await session.queryAll( + ".mx_VerificationShowSas .mx_VerificationShowSas_emojiSas .mx_VerificationShowSas_emojiSas_label"); const sasLabels = await Promise.all(sasLabelElements.map(e => session.innerText(e))); console.log("my sas labels", sasLabels); @@ -58,7 +59,7 @@ module.exports.verifyDeviceForUser = async function(session, name, expectedDevic const closeMemberInfo = await session.query(".mx_MemberInfo_cancel"); await closeMemberInfo.click(); session.log.done(); -} +}; async function getMembersInMemberlist(session) { const memberNameElements = await session.queryAll(".mx_MemberList .mx_EntityTile_name"); diff --git a/test/end-to-end-tests/src/usecases/room-settings.js b/test/end-to-end-tests/src/usecases/room-settings.js index bf3e60d490..7655d2d066 100644 --- a/test/end-to-end-tests/src/usecases/room-settings.js +++ b/test/end-to-end-tests/src/usecases/room-settings.js @@ -96,4 +96,4 @@ module.exports = async function changeRoomSettings(session, settings) { await closeButton.click(); session.log.endGroup(); -} +}; diff --git a/test/end-to-end-tests/src/usecases/send-message.js b/test/end-to-end-tests/src/usecases/send-message.js index 38fe6fceb3..764994420c 100644 --- a/test/end-to-end-tests/src/usecases/send-message.js +++ b/test/end-to-end-tests/src/usecases/send-message.js @@ -31,4 +31,4 @@ module.exports = async function sendMessage(session, message) { // wait for the message to appear sent await session.query(".mx_EventTile_last:not(.mx_EventTile_sending)"); session.log.done(); -} +}; diff --git a/test/end-to-end-tests/src/usecases/settings.js b/test/end-to-end-tests/src/usecases/settings.js index 903524e6b8..ec675157f2 100644 --- a/test/end-to-end-tests/src/usecases/settings.js +++ b/test/end-to-end-tests/src/usecases/settings.js @@ -22,7 +22,8 @@ async function openSettings(session, section) { const settingsItem = await session.query(".mx_TopLeftMenu_icon_settings"); await settingsItem.click(); if (section) { - const sectionButton = await session.query(`.mx_UserSettingsDialog .mx_TabbedView_tabLabels .mx_UserSettingsDialog_${section}Icon`); + const sectionButton = await session.query( + `.mx_UserSettingsDialog .mx_TabbedView_tabLabels .mx_UserSettingsDialog_${section}Icon`); await sectionButton.click(); } } @@ -37,7 +38,7 @@ module.exports.enableLazyLoading = async function(session) { const closeButton = await session.query(".mx_RoomHeader_cancelButton"); await closeButton.click(); session.log.done(); -} +}; module.exports.getE2EDeviceFromSettings = async function(session) { session.log.step(`gets e2e device/key from settings`); @@ -50,4 +51,4 @@ module.exports.getE2EDeviceFromSettings = async function(session) { await closeButton.click(); session.log.done(); return {id, key}; -} +}; diff --git a/test/end-to-end-tests/src/usecases/signup.js b/test/end-to-end-tests/src/usecases/signup.js index 014d2ff786..391ce76441 100644 --- a/test/end-to-end-tests/src/usecases/signup.js +++ b/test/end-to-end-tests/src/usecases/signup.js @@ -60,8 +60,8 @@ module.exports = async function signup(session, username, password, homeserver) // Password validation is async, wait for it to complete before submit await session.query(".mx_Field_valid #mx_RegistrationForm_password"); //check no errors - const error_text = await session.tryGetInnertext('.mx_Login_error'); - assert.strictEqual(!!error_text, false); + const errorText = await session.tryGetInnertext('.mx_Login_error'); + assert.strictEqual(!!errorText, false); //submit form //await page.screenshot({path: "beforesubmit.png", fullPage: true}); await registerButton.click(); @@ -87,4 +87,4 @@ module.exports = async function signup(session, username, password, homeserver) }); assert(foundHomeUrl); session.log.done(); -} +}; diff --git a/test/end-to-end-tests/src/usecases/timeline.js b/test/end-to-end-tests/src/usecases/timeline.js index 1770e0df9f..3ff9e0f5b4 100644 --- a/test/end-to-end-tests/src/usecases/timeline.js +++ b/test/end-to-end-tests/src/usecases/timeline.js @@ -36,11 +36,11 @@ module.exports.scrollToTimelineTop = async function(session) { } else { await new Promise((resolve) => setTimeout(resolve, 50)); } - } while (!timedOut) + } while (!timedOut); }); - }) + }); session.log.done(); -} +}; module.exports.receiveMessage = async function(session, expectedMessage) { session.log.step(`receives message "${expectedMessage.body}" from ${expectedMessage.sender}`); @@ -56,7 +56,7 @@ module.exports.receiveMessage = async function(session, expectedMessage) { await session.poll(async () => { try { lastMessage = await getLastMessage(); - } catch(err) { + } catch (err) { return false; } // stop polling when found the expected message @@ -66,10 +66,10 @@ module.exports.receiveMessage = async function(session, expectedMessage) { }); assertMessage(lastMessage, expectedMessage); session.log.done(); -} +}; -module.exports.checkTimelineContains = async function (session, expectedMessages, sendersDescription) { +module.exports.checkTimelineContains = async function(session, expectedMessages, sendersDescription) { session.log.step(`checks timeline contains ${expectedMessages.length} ` + `given messages${sendersDescription ? ` from ${sendersDescription}`:""}`); const eventTiles = await getAllEventTiles(session); @@ -94,14 +94,14 @@ module.exports.checkTimelineContains = async function (session, expectedMessages }); try { assertMessage(foundMessage, expectedMessage); - } catch(err) { + } catch (err) { console.log("timelineMessages", timelineMessages); throw err; } }); session.log.done(); -} +}; function assertMessage(foundMessage, expectedMessage) { assert(foundMessage, `message ${JSON.stringify(expectedMessage)} not found in timeline`); diff --git a/test/end-to-end-tests/src/usecases/verify.js b/test/end-to-end-tests/src/usecases/verify.js index 323765bebf..11ff98d097 100644 --- a/test/end-to-end-tests/src/usecases/verify.js +++ b/test/end-to-end-tests/src/usecases/verify.js @@ -31,7 +31,8 @@ async function startVerification(session, name) { } async function getSasCodes(session) { - const sasLabelElements = await session.queryAll(".mx_VerificationShowSas .mx_VerificationShowSas_emojiSas .mx_VerificationShowSas_emojiSas_label"); + const sasLabelElements = await session.queryAll( + ".mx_VerificationShowSas .mx_VerificationShowSas_emojiSas .mx_VerificationShowSas_emojiSas_label"); const sasLabels = await Promise.all(sasLabelElements.map(e => session.innerText(e))); return sasLabels; } diff --git a/test/end-to-end-tests/src/util.js b/test/end-to-end-tests/src/util.js index 8080d771be..699b11b5ce 100644 --- a/test/end-to-end-tests/src/util.js +++ b/test/end-to-end-tests/src/util.js @@ -20,8 +20,8 @@ module.exports.range = function(start, amount, step = 1) { r.push(start + (i * step)); } return r; -} +}; module.exports.delay = function(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); -} +}; diff --git a/test/end-to-end-tests/start.js b/test/end-to-end-tests/start.js index d19b232236..83bc186356 100644 --- a/test/end-to-end-tests/start.js +++ b/test/end-to-end-tests/start.js @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -const assert = require('assert'); const RiotSession = require('./src/session'); const scenario = require('./src/scenario'); const RestSessionCreator = require('./src/rest/creator'); @@ -35,7 +34,7 @@ program const hsUrl = 'http://localhost:5005'; async function runTests() { - let sessions = []; + const sessions = []; const options = { slowMo: program.slowMo ? 20 : undefined, devtools: program.devTools, @@ -54,7 +53,7 @@ async function runTests() { const restCreator = new RestSessionCreator( 'synapse/installations/consent/env/bin', hsUrl, - __dirname + __dirname, ); async function createSession(username) { @@ -66,7 +65,7 @@ async function runTests() { let failure = false; try { await scenario(createSession, restCreator); - } catch(err) { + } catch (err) { failure = true; console.log('failure: ', err); if (program.logDirectory) { @@ -90,15 +89,15 @@ async function runTests() { } async function writeLogs(sessions, dir) { - let logs = ""; - for(let i = 0; i < sessions.length; ++i) { + const logs = ""; + for (let i = 0; i < sessions.length; ++i) { const session = sessions[i]; const userLogDir = `${dir}/${session.username}`; fs.mkdirSync(userLogDir); const consoleLogName = `${userLogDir}/console.log`; const networkLogName = `${userLogDir}/network.log`; const appHtmlName = `${userLogDir}/app.html`; - documentHtml = await session.page.content(); + const documentHtml = await session.page.content(); fs.writeFileSync(appHtmlName, documentHtml); fs.writeFileSync(networkLogName, session.networkLogs()); fs.writeFileSync(consoleLogName, session.consoleLogs());