|
|
|
@ -29,7 +29,6 @@ chai.config.includeStack = true;
|
|
|
|
|
const STUB_SNODE_SERVER_PORT = 3000;
|
|
|
|
|
const ENABLE_LOG = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tslint:disable-next-line: no-unnecessary-class
|
|
|
|
|
export class Common {
|
|
|
|
|
/* ************** USERS ****************** */
|
|
|
|
@ -78,7 +77,11 @@ export class Common {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// a wrapper to work around electron/spectron bug
|
|
|
|
|
public static async setValueWrapper(app: Application, selector: any, value: string) {
|
|
|
|
|
public static async setValueWrapper(
|
|
|
|
|
app: Application,
|
|
|
|
|
selector: any,
|
|
|
|
|
value: string
|
|
|
|
|
) {
|
|
|
|
|
// keys, setValue and addValue hang on certain platforms
|
|
|
|
|
|
|
|
|
|
if (process.platform === 'darwin') {
|
|
|
|
@ -117,7 +120,16 @@ export class Common {
|
|
|
|
|
const instance = environment.replace('test-integration-', '');
|
|
|
|
|
|
|
|
|
|
const app1 = new Application({
|
|
|
|
|
path: path.join(__dirname, '..', '..', '..', '..', 'node_modules', '.bin', 'electron'),
|
|
|
|
|
path: path.join(
|
|
|
|
|
__dirname,
|
|
|
|
|
'..',
|
|
|
|
|
'..',
|
|
|
|
|
'..',
|
|
|
|
|
'..',
|
|
|
|
|
'node_modules',
|
|
|
|
|
'.bin',
|
|
|
|
|
'electron'
|
|
|
|
|
),
|
|
|
|
|
args: ['.'],
|
|
|
|
|
env: {
|
|
|
|
|
NODE_ENV: env,
|
|
|
|
@ -181,7 +193,9 @@ export class Common {
|
|
|
|
|
return app2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async startAndAssureCleanedApp(env = 'test-integration-session') {
|
|
|
|
|
public static async startAndAssureCleanedApp(
|
|
|
|
|
env = 'test-integration-session'
|
|
|
|
|
) {
|
|
|
|
|
const userData = path.join(Common.USER_DATA_ROOT_FOLDER, `Session-${env}`);
|
|
|
|
|
|
|
|
|
|
await Common.rmFolder(userData);
|
|
|
|
@ -226,7 +240,11 @@ export class Common {
|
|
|
|
|
return appN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async restoreFromMnemonic(app: Application, mnemonic: string, displayName: string) {
|
|
|
|
|
public static async restoreFromMnemonic(
|
|
|
|
|
app: Application,
|
|
|
|
|
mnemonic: string,
|
|
|
|
|
displayName: string
|
|
|
|
|
) {
|
|
|
|
|
await app.client.element(RegistrationPage.registrationTabSignIn).click();
|
|
|
|
|
await app.client.element(RegistrationPage.restoreFromSeedMode).click();
|
|
|
|
|
await Common.setValueWrapper(
|
|
|
|
@ -250,7 +268,10 @@ export class Common {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async makeFriends(app1: Application, client2: [Application, string]) {
|
|
|
|
|
public static async makeFriends(
|
|
|
|
|
app1: Application,
|
|
|
|
|
client2: [Application, string]
|
|
|
|
|
) {
|
|
|
|
|
const [app2, pubkey2] = client2;
|
|
|
|
|
|
|
|
|
|
/** add each other as friends */
|
|
|
|
@ -259,7 +280,11 @@ export class Common {
|
|
|
|
|
await app1.client.element(ConversationPage.contactsButtonSection).click();
|
|
|
|
|
await app1.client.element(ConversationPage.addContactButton).click();
|
|
|
|
|
|
|
|
|
|
await Common.setValueWrapper(app1, ConversationPage.sessionIDInput, pubkey2);
|
|
|
|
|
await Common.setValueWrapper(
|
|
|
|
|
app1,
|
|
|
|
|
ConversationPage.sessionIDInput,
|
|
|
|
|
pubkey2
|
|
|
|
|
);
|
|
|
|
|
await app1.client.element(ConversationPage.nextButton).click();
|
|
|
|
|
await app1.client.waitForExist(
|
|
|
|
|
ConversationPage.sendFriendRequestTextarea,
|
|
|
|
@ -331,7 +356,10 @@ export class Common {
|
|
|
|
|
return [app1, app2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async addFriendToNewClosedGroup(members: Array<Application>, useSenderKeys?: boolean) {
|
|
|
|
|
public static async addFriendToNewClosedGroup(
|
|
|
|
|
members: Array<Application>,
|
|
|
|
|
useSenderKeys?: boolean
|
|
|
|
|
) {
|
|
|
|
|
const [app, ...others] = members;
|
|
|
|
|
|
|
|
|
|
await app.client
|
|
|
|
@ -433,7 +461,11 @@ export class Common {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async linkApp2ToApp(app1: Application, app2: Application, app1Pubkey: string) {
|
|
|
|
|
public static async linkApp2ToApp(
|
|
|
|
|
app1: Application,
|
|
|
|
|
app2: Application,
|
|
|
|
|
app1Pubkey: string
|
|
|
|
|
) {
|
|
|
|
|
// app needs to be logged in as user1 and app2 needs to be logged out
|
|
|
|
|
// start the pairing dialog for the first app
|
|
|
|
|
await app1.client.element(SettingsPage.settingsButtonSection).click();
|
|
|
|
@ -497,7 +529,10 @@ export class Common {
|
|
|
|
|
.should.eventually.be.equal(app1Pubkey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async triggerUnlinkApp2FromApp(app1: Application, app2: Application) {
|
|
|
|
|
public static async triggerUnlinkApp2FromApp(
|
|
|
|
|
app1: Application,
|
|
|
|
|
app2: Application
|
|
|
|
|
) {
|
|
|
|
|
// check app2 is loggedin
|
|
|
|
|
await app2.client.isExisting(RegistrationPage.conversationListContainer)
|
|
|
|
|
.should.eventually.be.true;
|
|
|
|
@ -541,7 +576,11 @@ export class Common {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async sendMessage(app: Application, messageText: string, fileLocation?: string) {
|
|
|
|
|
public static async sendMessage(
|
|
|
|
|
app: Application,
|
|
|
|
|
messageText: string,
|
|
|
|
|
fileLocation?: string
|
|
|
|
|
) {
|
|
|
|
|
await Common.setValueWrapper(
|
|
|
|
|
app,
|
|
|
|
|
ConversationPage.sendMessageTextarea,
|
|
|
|
@ -647,7 +686,11 @@ export class Common {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async joinOpenGroup(app: Application, openGroupUrl: string, name: string) {
|
|
|
|
|
public static async joinOpenGroup(
|
|
|
|
|
app: Application,
|
|
|
|
|
openGroupUrl: string,
|
|
|
|
|
name: string
|
|
|
|
|
) {
|
|
|
|
|
await app.client
|
|
|
|
|
.element(ConversationPage.conversationButtonSection)
|
|
|
|
|
.click();
|
|
|
|
@ -699,7 +742,11 @@ export class Common {
|
|
|
|
|
* @param str the string to search (not regex)
|
|
|
|
|
* Note: getRenderProcessLogs() clears the app logs each calls.
|
|
|
|
|
*/
|
|
|
|
|
public static async logsContains(renderLogs: Array<{message: string}>, str: string, count?: number) {
|
|
|
|
|
public static async logsContains(
|
|
|
|
|
renderLogs: Array<{ message: string }>,
|
|
|
|
|
str: string,
|
|
|
|
|
count?: number
|
|
|
|
|
) {
|
|
|
|
|
const foundLines = renderLogs.filter(log => log.message.includes(str));
|
|
|
|
|
|
|
|
|
|
// tslint:disable-next-line: no-unused-expression
|
|
|
|
|