Merge pull request #3761 from matrix-org/travis/babel7-wp-es6-export

Convert CommonJS exports to ES6 exports
This commit is contained in:
Travis Ralston 2020-01-08 09:09:11 -07:00 committed by GitHub
commit 59f608ffd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
159 changed files with 745 additions and 717 deletions

View file

@ -4,7 +4,7 @@
import React from 'react';
import createReactClass from 'create-react-class';
module.exports = function(opts) {
export default function(opts) {
opts = opts || {};
if (!opts.displayName) {
opts.displayName = 'StubComponent';

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
module.exports = class LogBuffer {
export default class LogBuffer {
constructor(page, eventName, eventMapper, reduceAsync=false, initialValue = "") {
this.buffer = initialValue;
page.on(eventName, (arg) => {

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
module.exports = class Logger {
export default class Logger {
constructor(username) {
this.indent = 0;
this.username = username;

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -18,7 +19,7 @@ const request = require('request-promise-native');
const cheerio = require('cheerio');
const url = require("url");
module.exports.approveConsent = async function(consentUrl) {
export async function approveConsent(consentUrl) {
const body = await request.get(consentUrl);
const doc = cheerio.load(body);
const v = doc("input[name=v]").val();
@ -27,4 +28,4 @@ module.exports.approveConsent = async function(consentUrl) {
const formAction = doc("form").attr("action");
const absAction = url.resolve(consentUrl, formAction);
await request.post(absAction).form({v, u, h});
};
}

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -31,7 +32,7 @@ function execAsync(command, options) {
});
}
module.exports = class RestSessionCreator {
export default class RestSessionCreator {
constructor(synapseSubdir, hsUrl, cwd) {
this.synapseSubdir = synapseSubdir;
this.hsUrl = hsUrl;

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,7 +17,7 @@ limitations under the License.
const Logger = require('../logger');
module.exports = class RestMultiSession {
export default class RestMultiSession {
constructor(sessions, groupName) {
this.log = new Logger(groupName);
this.sessions = sessions;

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -17,7 +18,7 @@ limitations under the License.
const uuidv4 = require('uuid/v4');
/* no pun intented */
module.exports = class RestRoom {
export default class RestRoom {
constructor(session, roomId, log) {
this.session = session;
this._roomId = roomId;

View file

@ -19,7 +19,7 @@ const Logger = require('../logger');
const RestRoom = require('./room');
const {approveConsent} = require('./consent');
module.exports = class RestSession {
export default class RestSession {
constructor(credentials) {
this.log = new Logger(credentials.userId);
this._credentials = credentials;

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -21,7 +22,7 @@ const {receiveMessage} = require('../usecases/timeline');
const {createRoom} = require('../usecases/create-room');
const changeRoomSettings = require('../usecases/room-settings');
module.exports = async function roomDirectoryScenarios(alice, bob) {
export default async function roomDirectoryScenarios(alice, bob) {
console.log(" creating a public room and join through directory:");
const room = 'test';
await createRoom(alice, room);

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -23,7 +24,7 @@ const changeRoomSettings = require('../usecases/room-settings');
const {startSasVerifcation, acceptSasVerification} = require('../usecases/verify');
const assert = require('assert');
module.exports = async function e2eEncryptionScenarios(alice, bob) {
export default async function e2eEncryptionScenarios(alice, bob) {
console.log(" creating an e2e encrypted room and join through invite:");
const room = "secrets";
await createRoom(bob, room);

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -27,7 +28,7 @@ const {getMembersInMemberlist} = require('../usecases/memberlist');
const changeRoomSettings = require('../usecases/room-settings');
const assert = require('assert');
module.exports = async function lazyLoadingScenarios(alice, bob, charlies) {
export default async function lazyLoadingScenarios(alice, bob, charlies) {
console.log(" creating a room for lazy loading member scenarios:");
const charly1to5 = charlies.slice("charly-1..5", 0, 5);
const charly6to10 = charlies.slice("charly-6..10", 5);

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -21,7 +22,7 @@ const {delay} = require('./util');
const DEFAULT_TIMEOUT = 20000;
module.exports = class RiotSession {
export default class RiotSession {
constructor(browser, page, username, riotserver, hsUrl) {
this.browser = browser;
this.page = page;

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
module.exports = async function acceptInvite(session, name) {
export default async function acceptInvite(session, name) {
session.log.step(`accepts "${name}" invite`);
//TODO: brittle selector
const invitesHandles = await session.queryAll('.mx_RoomTile_name.mx_RoomTile_invite');

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,12 +15,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
async function openRoomDirectory(session) {
export async function openRoomDirectory(session) {
const roomDirectoryButton = await session.query('.mx_LeftPanel_explore .mx_AccessibleButton');
await roomDirectoryButton.click();
}
async function createRoom(session, roomName) {
export async function createRoom(session, roomName) {
session.log.step(`creates room "${roomName}"`);
const roomListHeaders = await session.queryAll('.mx_RoomSubList_labelContainer');
@ -42,5 +43,3 @@ async function createRoom(session, roomName) {
await session.query('.mx_MessageComposer');
session.log.done();
}
module.exports = {openRoomDirectory, createRoom};

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,20 +17,20 @@ limitations under the License.
const assert = require('assert');
async function assertDialog(session, expectedTitle) {
export async function assertDialog(session, expectedTitle) {
const titleElement = await session.query(".mx_Dialog .mx_Dialog_title");
const dialogHeader = await session.innerText(titleElement);
assert(dialogHeader, expectedTitle);
}
async function acceptDialog(session, expectedTitle) {
export async function acceptDialog(session, expectedTitle) {
const foundDialog = await acceptDialogMaybe(session, expectedTitle);
if (!foundDialog) {
throw new Error("could not find a dialog");
}
}
async function acceptDialogMaybe(session, expectedTitle) {
export async function acceptDialogMaybe(session, expectedTitle) {
let primaryButton = null;
try {
primaryButton = await session.query(".mx_Dialog .mx_Dialog_primary");
@ -42,9 +43,3 @@ async function acceptDialogMaybe(session, expectedTitle) {
await primaryButton.click();
return true;
}
module.exports = {
assertDialog,
acceptDialog,
acceptDialogMaybe,
};

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
module.exports = async function invite(session, userId) {
export default async function invite(session, userId) {
session.log.step(`invites "${userId}" to room`);
await session.delay(1000);
const memberPanelButton = await session.query(".mx_RightPanel_membersButton");

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,7 +17,7 @@ limitations under the License.
const {openRoomDirectory} = require('./create-room');
module.exports = async function join(session, roomName) {
export default async function join(session, roomName) {
session.log.step(`joins room "${roomName}"`);
await openRoomDirectory(session);
const roomInput = await session.query('.mx_DirectorySearchBox input');

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,7 +17,7 @@ limitations under the License.
const assert = require('assert');
async function openMemberInfo(session, name) {
export async function openMemberInfo(session, name) {
const membersAndNames = await getMembersInMemberlist(session);
const matchingLabel = membersAndNames.filter((m) => {
return m.displayName === name;
@ -24,9 +25,7 @@ async function openMemberInfo(session, name) {
await matchingLabel.click();
}
module.exports.openMemberInfo = openMemberInfo;
module.exports.verifyDeviceForUser = async function(session, name, expectedDevice) {
export async function verifyDeviceForUser(session, name, expectedDevice) {
session.log.step(`verifies e2e device for ${name}`);
const membersAndNames = await getMembersInMemberlist(session);
const matchingLabel = membersAndNames.filter((m) => {
@ -59,9 +58,9 @@ 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) {
export async function getMembersInMemberlist(session) {
const memberPanelButton = await session.query(".mx_RightPanel_membersButton");
try {
await session.query(".mx_RightPanel_headerButton_highlight", 500);
@ -78,5 +77,3 @@ async function getMembersInMemberlist(session) {
return {label: el, displayName: await session.innerText(el)};
}));
}
module.exports.getMembersInMemberlist = getMembersInMemberlist;

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -29,7 +30,7 @@ async function setSettingsToggle(session, toggle, enabled) {
}
}
module.exports = async function changeRoomSettings(session, settings) {
export default async function changeRoomSettings(session, settings) {
session.log.startGroup(`changes the room settings`);
/// XXX delay is needed here, possibly because the header is being rerendered
/// click doesn't do anything otherwise

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -28,7 +29,7 @@ async function openSettings(session, section) {
}
}
module.exports.enableLazyLoading = async function(session) {
export async function enableLazyLoading(session) {
session.log.step(`enables lazy loading of members in the lab settings`);
const settingsButton = await session.query('.mx_BottomLeftMenu_settings');
await settingsButton.click();
@ -38,9 +39,9 @@ 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) {
export async function getE2EDeviceFromSettings(session) {
session.log.step(`gets e2e device/key from settings`);
await openSettings(session, "security");
const deviceAndKey = await session.queryAll(".mx_SettingsTab_section .mx_SecurityUserSettingsTab_deviceInfo code");
@ -51,4 +52,4 @@ module.exports.getE2EDeviceFromSettings = async function(session) {
await closeButton.click();
session.log.done();
return {id, key};
};
}

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,7 +17,7 @@ limitations under the License.
const assert = require('assert');
module.exports = async function signup(session, username, password, homeserver) {
export default async function signup(session, username, password, homeserver) {
session.log.step("signs up");
await session.goto(session.url('/#/register'));
// change the homeserver by clicking the advanced section

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,7 +17,7 @@ limitations under the License.
const assert = require('assert');
module.exports.scrollToTimelineTop = async function(session) {
export async function scrollToTimelineTop(session) {
session.log.step(`scrolls to the top of the timeline`);
await session.page.evaluate(() => {
return Promise.resolve().then(async () => {
@ -40,9 +41,9 @@ module.exports.scrollToTimelineTop = async function(session) {
});
});
session.log.done();
};
}
module.exports.receiveMessage = async function(session, expectedMessage) {
export async function receiveMessage(session, expectedMessage) {
session.log.step(`receives message "${expectedMessage.body}" from ${expectedMessage.sender}`);
// wait for a response to come in that contains the message
// crude, but effective
@ -66,10 +67,10 @@ module.exports.receiveMessage = async function(session, expectedMessage) {
});
assertMessage(lastMessage, expectedMessage);
session.log.done();
};
}
module.exports.checkTimelineContains = async function(session, expectedMessages, sendersDescription) {
export async function checkTimelineContains(session, expectedMessages, sendersDescription) {
session.log.step(`checks timeline contains ${expectedMessages.length} ` +
`given messages${sendersDescription ? ` from ${sendersDescription}`:""}`);
const eventTiles = await getAllEventTiles(session);
@ -101,7 +102,7 @@ module.exports.checkTimelineContains = async function(session, expectedMessages,
});
session.log.done();
};
}
function assertMessage(foundMessage, expectedMessage) {
assert(foundMessage, `message ${JSON.stringify(expectedMessage)} not found in timeline`);

View file

@ -1,5 +1,6 @@
/*
Copyright 2019 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -37,7 +38,7 @@ async function getSasCodes(session) {
return sasLabels;
}
module.exports.startSasVerifcation = async function(session, name) {
export async function startSasVerifcation(session, name) {
await startVerification(session, name);
// expect "Verify device" dialog and click "Begin Verification"
await assertDialog(session, "Verify device");
@ -50,9 +51,9 @@ module.exports.startSasVerifcation = async function(session, name) {
// click "Got it" when verification is done
await acceptDialog(session);
return sasCodes;
};
}
module.exports.acceptSasVerification = async function(session, name) {
export async function acceptSasVerification(session, name) {
await assertDialog(session, "Incoming Verification Request");
const opponentLabelElement = await session.query(".mx_IncomingSasDialog_opponentProfile h2");
const opponentLabel = await session.innerText(opponentLabelElement);
@ -66,4 +67,4 @@ module.exports.acceptSasVerification = async function(session, name) {
// click "Got it" when verification is done
await acceptDialog(session);
return sasCodes;
};
}

View file

@ -1,5 +1,6 @@
/*
Copyright 2018 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,14 +15,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
module.exports.range = function(start, amount, step = 1) {
export function range(start, amount, step = 1) {
const r = [];
for (let i = 0; i < amount; ++i) {
r.push(start + (i * step));
}
return r;
};
}
module.exports.delay = function(ms) {
export function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
};
}

View file

@ -1,5 +1,6 @@
/*
Copyright (c) 2008-2015 Pivotal Labs
Copyright 2019 The Matrix.org Foundation C.I.C.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@ -411,10 +412,10 @@ j$.MockDate = function() {
return MockDate;
}();
const clock = new j$.Clock(global, function() { return new j$.DelayedFunctionScheduler(); }, new j$.MockDate(global));
const _clock = new j$.Clock(global, function() { return new j$.DelayedFunctionScheduler(); }, new j$.MockDate(global));
module.exports.clock = function() {
return clock;
};
export function clock() {
return _clock;
}