Move Lazy Loading tests from Puppeteer to Cypress (#8982)

* Remove Puppeteer Lazy Loading tests

* Remove Puppeteer Lazy Loading tests

* Remove Puppeteer Lazy Loading tests

* Stash lazy loading cypress tests

* Stash lazy loading cypress tests

* Update cypress-real-events

* Stash offline-less test

* Add offline/online'ing
This commit is contained in:
Michael Telatynski 2022-07-18 13:16:44 +01:00 committed by GitHub
parent 77d8a242af
commit 42ff9d6dc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 348 additions and 689 deletions

View file

@ -1,31 +0,0 @@
/*
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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import request = require('request-promise-native');
import * as cheerio from 'cheerio';
import * as url from "url";
export const approveConsent = async function(consentUrl: string): Promise<void> {
const body = await request.get(consentUrl);
const doc = cheerio.load(body);
const v = doc("input[name=v]").val();
const u = doc("input[name=u]").val();
const h = doc("input[name=h]").val();
const formAction = doc("form").attr("action");
const absAction = url.resolve(consentUrl, formAction);
await request.post(absAction).form({ v, u, h });
};

View file

@ -1,90 +0,0 @@
/*
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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import request = require('request-promise-native');
import * as crypto from 'crypto';
import { RestSession } from './session';
import { RestMultiSession } from './multi';
export interface Credentials {
accessToken: string;
homeServer: string;
userId: string;
deviceId: string;
hsUrl: string;
}
export class RestSessionCreator {
constructor(private readonly hsUrl: string, private readonly regSecret: string) {}
public async createSessionRange(usernames: string[], password: string,
groupName: string): Promise<RestMultiSession> {
const sessionPromises = usernames.map((username) => this.createSession(username, password));
const sessions = await Promise.all(sessionPromises);
return new RestMultiSession(sessions, groupName);
}
public async createSession(username: string, password: string): Promise<RestSession> {
await this.register(username, password);
console.log(` * created REST user ${username} ... done`);
const authResult = await this.authenticate(username, password);
return new RestSession(authResult);
}
private async register(username: string, password: string): Promise<void> {
// get a nonce
const regUrl = `${this.hsUrl}/_synapse/admin/v1/register`;
const nonceResp = await request.get({ uri: regUrl, json: true });
const mac = crypto.createHmac('sha1', this.regSecret).update(
`${nonceResp.nonce}\0${username}\0${password}\0notadmin`,
).digest('hex');
await request.post({
uri: regUrl,
json: true,
body: {
nonce: nonceResp.nonce,
username,
password,
mac,
admin: false,
},
});
}
private async authenticate(username: string, password: string): Promise<Credentials> {
const requestBody = {
"type": "m.login.password",
"identifier": {
"type": "m.id.user",
"user": username,
},
"password": password,
};
const url = `${this.hsUrl}/_matrix/client/r0/login`;
const responseBody = await request.post({ url, json: true, body: requestBody });
return {
accessToken: responseBody.access_token,
homeServer: responseBody.home_server,
userId: responseBody.user_id,
deviceId: responseBody.device_id,
hsUrl: this.hsUrl,
};
}
}

View file

@ -1,93 +0,0 @@
/*
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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { Logger } from '../logger';
import { RestSession } from "./session";
import { RestRoom } from "./room";
export class RestMultiSession {
readonly log: Logger;
constructor(public readonly sessions: RestSession[], groupName: string) {
this.log = new Logger(groupName);
}
public slice(groupName: string, start: number, end?: number): RestMultiSession {
return new RestMultiSession(this.sessions.slice(start, end), groupName);
}
public pop(userName: string): RestSession {
const idx = this.sessions.findIndex((s) => s.userName() === userName);
if (idx === -1) {
throw new Error(`user ${userName} not found`);
}
const session = this.sessions.splice(idx, 1)[0];
return session;
}
public async setDisplayName(fn: (s: RestSession) => string): Promise<void> {
this.log.step("set their display name");
await Promise.all(this.sessions.map(async (s: RestSession) => {
s.log.mute();
await s.setDisplayName(fn(s));
s.log.unmute();
}));
this.log.done();
}
public async join(roomIdOrAlias: string): Promise<RestMultiRoom> {
this.log.step(`join ${roomIdOrAlias}`);
const rooms = await Promise.all(this.sessions.map(async (s) => {
s.log.mute();
const room = await s.join(roomIdOrAlias);
s.log.unmute();
return room;
}));
this.log.done();
return new RestMultiRoom(rooms, roomIdOrAlias, this.log);
}
public room(roomIdOrAlias: string): RestMultiRoom {
const rooms = this.sessions.map(s => s.room(roomIdOrAlias));
return new RestMultiRoom(rooms, roomIdOrAlias, this.log);
}
}
class RestMultiRoom {
constructor(public readonly rooms: RestRoom[], private readonly roomIdOrAlias: string,
private readonly log: Logger) {}
public async talk(message: string): Promise<void> {
this.log.step(`say "${message}" in ${this.roomIdOrAlias}`);
await Promise.all(this.rooms.map(async (r: RestRoom) => {
r.log.mute();
await r.talk(message);
r.log.unmute();
}));
this.log.done();
}
public async leave() {
this.log.step(`leave ${this.roomIdOrAlias}`);
await Promise.all(this.rooms.map(async (r) => {
r.log.mute();
await r.leave();
r.log.unmute();
}));
this.log.done();
}
}

View file

@ -1,43 +0,0 @@
/*
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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import uuidv4 = require('uuid/v4');
import { RestSession } from "./session";
import { Logger } from "../logger";
/* no pun intended */
export class RestRoom {
constructor(readonly session: RestSession, readonly roomId: string, readonly log: Logger) {}
async talk(message: string): Promise<string> {
this.log.step(`says "${message}" in ${this.roomId}`);
const txId = uuidv4();
const { event_id: eventId } = await this.session.put(`/rooms/${this.roomId}/send/m.room.message/${txId}`, {
"msgtype": "m.text",
"body": message,
});
this.log.done();
return eventId;
}
async leave(): Promise<void> {
this.log.step(`leaves ${this.roomId}`);
await this.session.post(`/rooms/${this.roomId}/leave`);
this.log.done();
}
}

View file

@ -1,138 +0,0 @@
/*
Copyright 2018 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import request = require('request-promise-native');
import { Logger } from '../logger';
import { RestRoom } from './room';
import { approveConsent } from './consent';
import { Credentials } from "./creator";
interface RoomOptions {
invite?: string;
public?: boolean;
topic?: string;
dm?: boolean;
}
export class RestSession {
private _displayName: string = null;
private readonly rooms: Record<string, RestRoom> = {};
readonly log: Logger;
constructor(private readonly credentials: Credentials) {
this.log = new Logger(credentials.userId);
}
userId(): string {
return this.credentials.userId;
}
userName(): string {
return this.credentials.userId.split(":")[0].slice(1);
}
displayName(): string {
return this._displayName;
}
async setDisplayName(displayName: string): Promise<void> {
this.log.step(`sets their display name to ${displayName}`);
this._displayName = displayName;
await this.put(`/profile/${this.credentials.userId}/displayname`, {
displayname: displayName,
});
this.log.done();
}
async join(roomIdOrAlias: string): Promise<RestRoom> {
this.log.step(`joins ${roomIdOrAlias}`);
const roomId = (await this.post(`/join/${encodeURIComponent(roomIdOrAlias)}`)).room_id;
this.log.done();
const room = new RestRoom(this, roomId, this.log);
this.rooms[roomId] = room;
this.rooms[roomIdOrAlias] = room;
return room;
}
room(roomIdOrAlias: string): RestRoom {
if (this.rooms.hasOwnProperty(roomIdOrAlias)) {
return this.rooms[roomIdOrAlias];
} else {
throw new Error(`${this.credentials.userId} is not in ${roomIdOrAlias}`);
}
}
async createRoom(name: string, options: RoomOptions): Promise<RestRoom> {
this.log.step(`creates room ${name}`);
const body = {
name,
};
if (options.invite) {
body['invite'] = options.invite;
}
if (options.public) {
body['visibility'] = "public";
} else {
body['visibility'] = "private";
}
if (options.dm) {
body['is_direct'] = true;
}
if (options.topic) {
body['topic'] = options.topic;
}
const roomId = (await this.post(`/createRoom`, body)).room_id;
this.log.done();
return new RestRoom(this, roomId, this.log);
}
post(csApiPath: string, body?: any): Promise<any> {
return this.request("POST", csApiPath, body);
}
put(csApiPath: string, body?: any): Promise<any> {
return this.request("PUT", csApiPath, body);
}
async request(method: string, csApiPath: string, body?: any): Promise<any> {
try {
return await request({
url: `${this.credentials.hsUrl}/_matrix/client/r0${csApiPath}`,
method,
headers: {
"Authorization": `Bearer ${this.credentials.accessToken}`,
},
json: true,
body,
});
} catch (err) {
if (!err.response) {
throw 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) {
throw new Error(`${method} ${csApiPath}: ${responseBody.error}`);
} else {
throw new Error(`${method} ${csApiPath}: ${err.response.statusCode}`);
}
}
}
}

View file

@ -15,18 +15,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { range } from './util';
import { signup } from './usecases/signup';
import { toastScenarios } from './scenarios/toast';
import { lazyLoadingScenarios } from './scenarios/lazy-loading';
import { e2eEncryptionScenarios } from './scenarios/e2e-encryption';
import { ElementSession } from "./session";
import { RestSessionCreator } from "./rest/creator";
import { RestMultiSession } from "./rest/multi";
import { RestSession } from "./rest/session";
export async function scenario(createSession: (s: string) => Promise<ElementSession>,
restCreator: RestSessionCreator): Promise<void> {
export async function scenario(createSession: (s: string) => Promise<ElementSession>): Promise<void> {
let firstUser = true;
async function createUser(username: string) {
const session = await createSession(username);
@ -45,14 +39,4 @@ export async function scenario(createSession: (s: string) => Promise<ElementSess
await toastScenarios(alice, bob);
await e2eEncryptionScenarios(alice, bob);
console.log("create REST users:");
const charlies = await createRestUsers(restCreator);
await lazyLoadingScenarios(alice, bob, charlies);
}
async function createRestUsers(restCreator: RestSessionCreator): Promise<RestMultiSession> {
const usernames = range(1, 10).map((i) => `charly-${i}`);
const charlies = await restCreator.createSessionRange(usernames, "testtest", "charly-1..10");
await charlies.setDisplayName((s: RestSession) => `Charly #${s.userName().split('-')[1]}`);
return charlies;
}

View file

@ -1,127 +0,0 @@
/*
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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { strict as assert } from 'assert';
import { delay } from '../util';
import { join } from '../usecases/join';
import { sendMessage } from '../usecases/send-message';
import {
checkTimelineContains,
scrollToTimelineTop,
} from '../usecases/timeline';
import { createRoom } from '../usecases/create-room';
import { getMembersInMemberlist } from '../usecases/memberlist';
import { changeRoomSettings } from '../usecases/room-settings';
import { RestMultiSession } from "../rest/multi";
import { ElementSession } from "../session";
export async function lazyLoadingScenarios(alice: ElementSession,
bob: ElementSession, charlies: RestMultiSession): Promise<void> {
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);
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);
await charlies.room(alias).leave();
await delay(1000);
await checkMemberListLacksCharlies(alice, charlies);
await checkMemberListLacksCharlies(bob, charlies);
}
const room = "Lazy Loading Test";
const alias = "#lltest:localhost";
const charlyMsg1 = "hi bob!";
const charlyMsg2 = "how's it going??";
async function setupRoomWithBobAliceAndCharlies(alice: ElementSession, bob: ElementSession,
charlies: RestMultiSession): Promise<void> {
await createRoom(bob, room);
await changeRoomSettings(bob, { directory: true, visibility: "public", alias });
// wait for alias to be set by server after clicking "save"
// so the charlies can join it.
await bob.delay(500);
const charlyMembers = await charlies.join(alias);
await charlyMembers.talk(charlyMsg1);
await charlyMembers.talk(charlyMsg2);
bob.log.step("sends 20 messages").mute();
for (let i = 20; i >= 1; --i) {
await sendMessage(bob, `I will only say this ${i} time(s)!`);
}
bob.log.unmute().done();
await join(alice, alias);
}
async function checkPaginatedDisplayNames(alice: ElementSession, charlies: RestMultiSession): Promise<void> {
await scrollToTimelineTop(alice);
//alice should see 2 messages from every charly with
//the correct display name
const expectedMessages = [charlyMsg1, charlyMsg2].reduce((messages, msgText) => {
return charlies.sessions.reduce((messages, charly) => {
return messages.concat({
sender: charly.displayName(),
body: msgText,
});
}, messages);
}, []);
await checkTimelineContains(alice, expectedMessages, charlies.log.username);
}
async function checkMemberList(alice: ElementSession, charlies: RestMultiSession): Promise<void> {
alice.log.step(`checks the memberlist contains herself, bob and ${charlies.log.username}`);
const displayNames = (await getMembersInMemberlist(alice)).map((m) => m.displayName);
assert(displayNames.includes("alice"));
assert(displayNames.includes("bob"));
charlies.sessions.forEach((charly) => {
assert(displayNames.includes(charly.displayName()),
`${charly.displayName()} should be in the member list, ` +
`only have ${displayNames}`);
});
alice.log.done();
}
async function checkMemberListLacksCharlies(session: ElementSession, charlies: RestMultiSession): Promise<void> {
session.log.step(`checks the memberlist doesn't contain ${charlies.log.username}`);
const displayNames = (await getMembersInMemberlist(session)).map((m) => m.displayName);
charlies.sessions.forEach((charly) => {
assert(!displayNames.includes(charly.displayName()),
`${charly.displayName()} should not be in the member list, ` +
`only have ${displayNames}`);
});
session.log.done();
}
async function joinCharliesWhileAliceIsOffline(alice: ElementSession, charly6to10: RestMultiSession) {
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();
const catchupPromise = alice.waitForNextSuccessfulSync();
await alice.setOffline(false);
await catchupPromise;
await delay(2000);
}

View file

@ -118,24 +118,6 @@ export class ElementSession {
return await this.page.$$(selector);
}
/** wait for a /sync request started after this call that gets a 200 response */
public async waitForNextSuccessfulSync(): Promise<void> {
const syncUrls = [];
function onRequest(request) {
if (request.url().indexOf("/sync") !== -1) {
syncUrls.push(request.url());
}
}
this.page.on('request', onRequest);
await this.page.waitForResponse((response) => {
return syncUrls.includes(response.request().url()) && response.status() === 200;
});
this.page.off('request', onRequest);
}
public async waitNoSpinner(): Promise<void> {
await this.page.waitForSelector(".mx_Spinner", { hidden: true });
}
@ -152,13 +134,6 @@ export class ElementSession {
return delay(ms);
}
public async setOffline(enabled: boolean): Promise<void> {
const description = enabled ? "offline" : "back online";
this.log.step(`goes ${description}`);
await this.page.setOfflineMode(enabled);
this.log.done();
}
public async close(): Promise<void> {
return this.browser.close();
}

View file

@ -15,7 +15,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { strict as assert } from 'assert';
import { ElementHandle } from "puppeteer";
import { openRoomSummaryCard } from "./rightpanel";
@ -29,46 +28,6 @@ export async function openMemberInfo(session: ElementSession, name: String): Pro
await matchingLabel.click();
}
interface Device {
id: string;
key: string;
}
export async function verifyDeviceForUser(session: ElementSession, name: string,
expectedDevice: Device): Promise<void> {
session.log.step(`verifies e2e device for ${name}`);
const membersAndNames = await getMembersInMemberlist(session);
const matchingLabel = membersAndNames.filter((m) => {
return m.displayName === name;
}).map((m) => m.label)[0];
await matchingLabel.click();
// click verify in member info
const firstVerifyButton = await session.query(".mx_MemberDeviceInfo_verify");
await firstVerifyButton.click();
// 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");
await beginVerificationButton.click();
// get emoji SAS labels
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);
const dialogCodeFields = await session.queryAll(".mx_QuestionDialog code");
assert.strictEqual(dialogCodeFields.length, 2);
const deviceId = await session.innerText(dialogCodeFields[0]);
const deviceKey = await session.innerText(dialogCodeFields[1]);
assert.strictEqual(expectedDevice.id, deviceId);
assert.strictEqual(expectedDevice.key, deviceKey);
const confirmButton = await session.query(".mx_Dialog_primary");
await confirmButton.click();
const closeMemberInfo = await session.query(".mx_MemberInfo_cancel");
await closeMemberInfo.click();
session.log.done();
}
interface MemberName {
label: ElementHandle;
displayName: string;

View file

@ -20,32 +20,6 @@ import { ElementHandle } from "puppeteer";
import { ElementSession } from "../session";
export async function scrollToTimelineTop(session: ElementSession): Promise<void> {
session.log.step(`scrolls to the top of the timeline`);
await session.page.evaluate(() => {
return Promise.resolve().then(async () => {
let timedOut = false;
let timeoutHandle = null;
// set scrollTop to 0 in a loop and check every 50ms
// if content became available (scrollTop not being 0 anymore),
// assume everything is loaded after 3s
do {
const timelineScrollView = document.querySelector(".mx_RoomView_timeline .mx_ScrollPanel");
if (timelineScrollView && timelineScrollView.scrollTop !== 0) {
if (timeoutHandle) {
clearTimeout(timeoutHandle);
}
timeoutHandle = setTimeout(() => timedOut = true, 3000);
timelineScrollView.scrollTop = 0;
} else {
await new Promise((resolve) => setTimeout(resolve, 50));
}
} while (!timedOut);
});
});
session.log.done();
}
interface Message {
sender: string;
encrypted?: boolean;
@ -79,41 +53,6 @@ export async function receiveMessage(session: ElementSession, expectedMessage: M
session.log.done();
}
export async function checkTimelineContains(session: ElementSession, expectedMessages: Message[],
sendersDescription: string): Promise<void> {
session.log.step(`checks timeline contains ${expectedMessages.length} ` +
`given messages${sendersDescription ? ` from ${sendersDescription}`:""}`);
const eventTiles = await getAllEventTiles(session);
let timelineMessages: Message[] = await Promise.all(eventTiles.map((eventTile) => {
return getMessageFromEventTile(eventTile);
}));
//filter out tiles that were not messages
timelineMessages = timelineMessages.filter((m) => !!m);
timelineMessages.reduce((prevSender: string, m) => {
if (m.continuation) {
m.sender = prevSender;
return prevSender;
} else {
return m.sender;
}
}, "");
expectedMessages.forEach((expectedMessage) => {
const foundMessage = timelineMessages.find((message) => {
return message.sender === expectedMessage.sender &&
message.body === expectedMessage.body;
});
try {
assertMessage(foundMessage, expectedMessage);
} catch (err) {
console.log("timelineMessages", timelineMessages);
throw err;
}
});
session.log.done();
}
function assertMessage(foundMessage: Message, expectedMessage: Message): void {
assert(foundMessage, `message ${JSON.stringify(expectedMessage)} not found in timeline`);
assert.equal(foundMessage.body, expectedMessage.body);
@ -127,10 +66,6 @@ function getLastEventTile(session: ElementSession): Promise<ElementHandle> {
return session.query(".mx_EventTile_last");
}
function getAllEventTiles(session: ElementSession): Promise<ElementHandle[]> {
return session.queryAll(".mx_RoomView_MessageList .mx_EventTile");
}
async function getMessageFromEventTile(eventTile: ElementHandle): Promise<Message> {
const senderElement = await eventTile.$(".mx_DisambiguatedProfile_displayName");
const className: string = await (await eventTile.getProperty("className")).jsonValue();

View file

@ -20,14 +20,6 @@ import { padEnd } from "lodash";
import { ElementSession } from "./session";
export const range = function(start: number, amount: number, step = 1): Array<number> {
const r = [];
for (let i = 0; i < amount; ++i) {
r.push(start + (i * step));
}
return r;
};
export const delay = function(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
};

View file

@ -19,7 +19,6 @@ import { Command } from "commander";
import { ElementSession } from './src/session';
import { scenario } from './src/scenario';
import { RestSessionCreator } from './src/rest/creator';
const program = new Command();
@ -54,12 +53,7 @@ async function runTests() {
options['executablePath'] = path;
}
const restCreator = new RestSessionCreator(
hsUrl,
program.opts().registrationSharedSecret,
);
async function createSession(username) {
async function createSession(username: string) {
const session = await ElementSession.create(
username, options, program.opts().appUrl, hsUrl, program.opts().throttleCpu,
);
@ -69,7 +63,7 @@ async function runTests() {
let failure = false;
try {
await scenario(createSession, restCreator);
await scenario(createSession);
} catch (err) {
failure = true;
console.log('failure: ', err);