Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bwindels committed Oct 9, 2019
1 parent 3e971e4 commit 2d848bb
Show file tree
Hide file tree
Showing 25 changed files with 84 additions and 100 deletions.
5 changes: 2 additions & 3 deletions test/end-to-end-tests/src/logbuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
}
}
};
2 changes: 1 addition & 1 deletion test/end-to-end-tests/src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ module.exports = class Logger {
this.muted = false;
return this;
}
}
};
10 changes: 5 additions & 5 deletions test/end-to-end-tests/src/rest/creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand All @@ -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});
Expand All @@ -88,4 +88,4 @@ module.exports = class RestSessionCreator {
hsUrl: this.hsUrl,
};
}
}
};
17 changes: 7 additions & 10 deletions test/end-to-end-tests/src/rest/multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -31,15 +28,15 @@ 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];
return session;
}

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));
Expand All @@ -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;
}));
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions test/end-to-end-tests/src/rest/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ 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();
}

roomId() {
return this._roomId;
}
}
};
23 changes: 11 additions & 12 deletions test/end-to-end-tests/src/rest/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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}`);
}
}
}
}
};
2 changes: 1 addition & 1 deletion test/end-to-end-tests/src/scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
4 changes: 2 additions & 2 deletions test/end-to-end-tests/src/scenarios/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
};
8 changes: 2 additions & 6 deletions test/end-to-end-tests/src/scenarios/e2e-encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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});
}
};
9 changes: 4 additions & 5 deletions test/end-to-end-tests/src/scenarios/lazy-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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";
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
18 changes: 9 additions & 9 deletions test/end-to-end-tests/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
Expand All @@ -70,7 +70,7 @@ module.exports = class RiotSession {
return this.getElementProperty(field, 'innerText');
}

getOuterHTML(element_handle) {
getOuterHTML(field) {
return this.getElementProperty(field, 'outerHTML');
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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()) {
Expand All @@ -219,4 +219,4 @@ module.exports = class RiotSession {
}
return false;
}
}
};
5 changes: 1 addition & 4 deletions test/end-to-end-tests/src/usecases/accept-invite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,4 +32,4 @@ module.exports = async function acceptInvite(session, name) {
await acceptInvitationLink.click();

session.log.done();
}
};
2 changes: 0 additions & 2 deletions test/end-to-end-tests/src/usecases/create-room.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end-tests/src/usecases/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 2d848bb

Please sign in to comment.