From 720bb54bc19f7b9ca8fc0c3b037db59e201266c9 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 28 Jul 2020 11:08:34 +1000 Subject: [PATCH] move add_contacts_test open_group_test and registration_test to ts --- .../session/integration/add_contacts_test.ts | 46 +++++++------- .../session/integration/integration_test.ts | 6 +- .../session/integration/open_group_test.ts | 58 +++++++++--------- .../session/integration/registration_test.ts | 60 ++++++++++--------- 4 files changed, 91 insertions(+), 79 deletions(-) rename integration_test/add_contacts_test.js => ts/test/session/integration/add_contacts_test.ts (63%) rename integration_test/open_group_test.js => ts/test/session/integration/open_group_test.ts (69%) rename integration_test/registration_test.js => ts/test/session/integration/registration_test.ts (74%) diff --git a/integration_test/add_contacts_test.js b/ts/test/session/integration/add_contacts_test.ts similarity index 63% rename from integration_test/add_contacts_test.js rename to ts/test/session/integration/add_contacts_test.ts index 58bc930b6..7d617f984 100644 --- a/integration_test/add_contacts_test.js +++ b/ts/test/session/integration/add_contacts_test.ts @@ -1,59 +1,63 @@ /* eslint-disable func-names */ /* eslint-disable import/no-extraneous-dependencies */ -const { afterEach, beforeEach, describe, it } = require('mocha'); +// tslint:disable: await-promise +// tslint:disable: no-implicit-dependencies -const common = require('./common'); -const ConversationPage = require('./page-objects/conversation.page'); +import { afterEach, beforeEach, describe, it } from 'mocha'; +import { Common } from './common'; +import { Application } from 'spectron'; + +import ConversationPage from './page-objects/conversation.page'; describe('Add contact', function() { - let app; - let app2; + let app: Application; + let app2: Application; this.timeout(60000); this.slow(15000); beforeEach(async () => { - await common.killallElectron(); - await common.stopStubSnodeServer(); + await Common.killallElectron(); + await Common.stopStubSnodeServer(); const app1Props = { - mnemonic: common.TEST_MNEMONIC1, - displayName: common.TEST_DISPLAY_NAME1, + mnemonic: Common.TEST_MNEMONIC1, + displayName: Common.TEST_DISPLAY_NAME1, }; const app2Props = { - mnemonic: common.TEST_MNEMONIC2, - displayName: common.TEST_DISPLAY_NAME2, + mnemonic: Common.TEST_MNEMONIC2, + displayName: Common.TEST_DISPLAY_NAME2, }; [app, app2] = await Promise.all([ - common.startAndStub(app1Props), - common.startAndStubN(app2Props, 2), + Common.startAndStub(app1Props), + Common.startAndStubN(app2Props, 2), ]); }); afterEach(async () => { - await common.stopApp(app); - await common.killallElectron(); - await common.stopStubSnodeServer(); + await Common.stopApp(app); + await Common.killallElectron(); + await Common.stopStubSnodeServer(); }); it('addContacts: can add a contact by sessionID', async () => { - const textMessage = common.generateSendMessageText(); + const textMessage = Common.generateSendMessageText(); await app.client.element(ConversationPage.contactsButtonSection).click(); await app.client.element(ConversationPage.addContactButton).click(); await app.client.isExisting(ConversationPage.leftPaneOverlay).should .eventually.be.true; - await common.setValueWrapper( + await Common.setValueWrapper( app, ConversationPage.sessionIDInput, - common.TEST_PUBKEY2 + Common.TEST_PUBKEY2 ); await app.client .element(ConversationPage.sessionIDInput) .getValue() - .should.eventually.equal(common.TEST_PUBKEY2); + .should.eventually.equal(Common.TEST_PUBKEY2); await app.client.element(ConversationPage.nextButton).click(); await app.client.waitForExist(ConversationPage.sendMessageTextarea, 1000); @@ -69,7 +73,7 @@ describe('Add contact', function() { ); // assure session request message has been sent - await common.timeout(3000); + await Common.timeout(3000); await app.client.isExisting(ConversationPage.retrySendButton).should .eventually.be.false; diff --git a/ts/test/session/integration/integration_test.ts b/ts/test/session/integration/integration_test.ts index 14961af6a..9e3b6eb28 100644 --- a/ts/test/session/integration/integration_test.ts +++ b/ts/test/session/integration/integration_test.ts @@ -12,9 +12,9 @@ import { Common } from './common'; // tslint:disable: no-import-side-effect -// import './registration_test'; -// import './open_group_test'; -// import './add_contacts_test'; +import './registration_test'; +import './open_group_test'; +import './add_contacts_test'; import './link_device_test'; // import './closed_group_test'; // import './message_functions_test'; diff --git a/integration_test/open_group_test.js b/ts/test/session/integration/open_group_test.ts similarity index 69% rename from integration_test/open_group_test.js rename to ts/test/session/integration/open_group_test.ts index 6e13adb56..a38d5f570 100644 --- a/integration_test/open_group_test.js +++ b/ts/test/session/integration/open_group_test.ts @@ -1,41 +1,45 @@ /* eslint-disable func-names */ /* eslint-disable import/no-extraneous-dependencies */ -const { afterEach, beforeEach, describe, it } = require('mocha'); +// tslint:disable: await-promise +// tslint:disable: no-implicit-dependencies -const common = require('./common'); -const ConversationPage = require('./page-objects/conversation.page'); +import { afterEach, beforeEach, describe, it } from 'mocha'; +import { Common } from './common'; +import { Application } from 'spectron'; + +import ConversationPage from './page-objects/conversation.page'; describe('Open groups', function() { - let app; + let app: Application; this.timeout(40000); this.slow(15000); beforeEach(async () => { - await common.killallElectron(); + await Common.killallElectron(); const login = { - mnemonic: common.TEST_MNEMONIC1, - displayName: common.TEST_DISPLAY_NAME1, + mnemonic: Common.TEST_MNEMONIC1, + displayName: Common.TEST_DISPLAY_NAME1, }; - app = await common.startAndStub(login); + app = await Common.startAndStub(login); }); afterEach(async () => { - await common.killallElectron(); + await Common.killallElectron(); }); it('openGroup: works with valid open group url', async () => { - await common.joinOpenGroup( + await Common.joinOpenGroup( app, - common.VALID_GROUP_URL, - common.VALID_GROUP_NAME + Common.VALID_GROUP_URL, + Common.VALID_GROUP_NAME ); }); it('openGroup: cannot join two times the same open group', async () => { - await common.joinOpenGroup( + await Common.joinOpenGroup( app, - common.VALID_GROUP_URL2, - common.VALID_GROUP_NAME2 + Common.VALID_GROUP_URL2, + Common.VALID_GROUP_NAME2 ); // adding a second time the same open group @@ -44,10 +48,10 @@ describe('Open groups', function() { .click(); await app.client.element(ConversationPage.joinOpenGroupButton).click(); - await common.setValueWrapper( + await Common.setValueWrapper( app, ConversationPage.openGroupInputUrl, - common.VALID_GROUP_URL2 + Common.VALID_GROUP_URL2 ); await app.client.element(ConversationPage.joinOpenGroupButton).click(); // validate session loader is not shown @@ -71,10 +75,10 @@ describe('Open groups', function() { .click(); await app.client.element(ConversationPage.joinOpenGroupButton).click(); - await common.setValueWrapper( + await Common.setValueWrapper( app, ConversationPage.openGroupInputUrl, - common.VALID_GROUP_URL2 + Common.VALID_GROUP_URL2 ); await app.client.element(ConversationPage.joinOpenGroupButton).click(); @@ -83,29 +87,29 @@ describe('Open groups', function() { ConversationPage.sessionToastJoinOpenGroupSuccess, 30 * 1000 ); - await common.timeout(5 * 1000); // wait for toast to clear + await Common.timeout(5 * 1000); // wait for toast to clear await app.client.waitForExist( - ConversationPage.rowOpenGroupConversationName(common.VALID_GROUP_NAME2), + ConversationPage.rowOpenGroupConversationName(Common.VALID_GROUP_NAME2), 10 * 1000 ); // generate a message containing the current timestamp so we can find it in the list of messages - const textMessage = common.generateSendMessageText(); + const textMessage = Common.generateSendMessageText(); await app.client .element(ConversationPage.conversationButtonSection) .click(); await app.client.isExisting( - ConversationPage.rowOpenGroupConversationName(common.VALID_GROUP_NAME2) + ConversationPage.rowOpenGroupConversationName(Common.VALID_GROUP_NAME2) ); await app.client .element( - ConversationPage.rowOpenGroupConversationName(common.VALID_GROUP_NAME2) + ConversationPage.rowOpenGroupConversationName(Common.VALID_GROUP_NAME2) ) .click(); - await common.setValueWrapper( + await Common.setValueWrapper( app, ConversationPage.sendMessageTextarea, textMessage @@ -115,11 +119,11 @@ describe('Open groups', function() { .getValue() .should.eventually.equal(textMessage); // allow some time to fetch some messages - await common.timeout(3000); + await Common.timeout(3000); // send the message await app.client.keys('Enter'); - await common.timeout(5000); + await Common.timeout(5000); // validate that the message has been added to the message list view await app.client.waitForExist( ConversationPage.existingSendMessageText(textMessage), diff --git a/integration_test/registration_test.js b/ts/test/session/integration/registration_test.ts similarity index 74% rename from integration_test/registration_test.js rename to ts/test/session/integration/registration_test.ts index f9ba07704..dba321788 100644 --- a/integration_test/registration_test.js +++ b/ts/test/session/integration/registration_test.ts @@ -1,35 +1,39 @@ /* eslint-disable prefer-arrow-callback */ /* eslint-disable func-names */ /* eslint-disable import/no-extraneous-dependencies */ +// tslint:disable: no-implicit-dependencies +// tslint:disable: await-promise -const { afterEach, beforeEach, describe, it } = require('mocha'); +import { afterEach, beforeEach, describe, it } from 'mocha'; +import { Common } from './common'; +import { Application } from 'spectron'; + +import SettingsPage from './page-objects/settings.page'; +import RegistrationPage from './page-objects/registration.page'; +import ConversationPage from './page-objects/conversation.page'; -const common = require('./common'); -const SettingsPage = require('./page-objects/settings.page'); -const RegistrationPage = require('./page-objects/registration.page'); -const ConversationPage = require('./page-objects/conversation.page'); describe('Window Test and Login', function() { - let app; + let app: Application; this.timeout(20000); this.slow(15000); beforeEach(async () => { - await common.killallElectron(); + await Common.killallElectron(); }); afterEach(async () => { - await common.stopApp(app); - await common.killallElectron(); + await Common.stopApp(app); + await Common.killallElectron(); }); it('registration: opens one window', async () => { - app = await common.startAndAssureCleanedApp(); + app = await Common.startAndAssureCleanedApp(); app.client.getWindowCount().should.eventually.be.equal(1); }); it('registration: window title is correct', async () => { - app = await common.startAndAssureCleanedApp(); + app = await Common.startAndAssureCleanedApp(); app.client .getTitle() @@ -37,26 +41,26 @@ describe('Window Test and Login', function() { }); it('registration: can restore from seed', async () => { - app = await common.startAndAssureCleanedApp(); + app = await Common.startAndAssureCleanedApp(); await app.client.element(RegistrationPage.registrationTabSignIn).click(); await app.client.element(RegistrationPage.restoreFromSeedMode).click(); await app.client .element(RegistrationPage.recoveryPhraseInput) - .setValue(common.TEST_MNEMONIC1); + .setValue(Common.TEST_MNEMONIC1); await app.client .element(RegistrationPage.displayNameInput) - .setValue(common.TEST_DISPLAY_NAME1); + .setValue(Common.TEST_DISPLAY_NAME1); // validate fields are filled await app.client .element(RegistrationPage.recoveryPhraseInput) .getValue() - .should.eventually.equal(common.TEST_MNEMONIC1); + .should.eventually.equal(Common.TEST_MNEMONIC1); await app.client .element(RegistrationPage.displayNameInput) .getValue() - .should.eventually.equal(common.TEST_DISPLAY_NAME1); + .should.eventually.equal(Common.TEST_DISPLAY_NAME1); // trigger login await app.client.element(RegistrationPage.continueSessionButton).click(); @@ -65,18 +69,18 @@ describe('Window Test and Login', function() { 4000 ); - await common.timeout(2000); + await Common.timeout(2000); await app.webContents .executeJavaScript("window.storage.get('primaryDevicePubKey')") - .should.eventually.be.equal(common.TEST_PUBKEY1); + .should.eventually.be.equal(Common.TEST_PUBKEY1); }); it('registration: can create new account', async () => { - app = await common.startAndAssureCleanedApp(); + app = await Common.startAndAssureCleanedApp(); await app.client.element(RegistrationPage.createSessionIDButton).click(); // wait for the animation of generated pubkey to finish - await common.timeout(2000); + await Common.timeout(2000); const pubkeyGenerated = await app.client .element(RegistrationPage.textareaGeneratedPubkey) .getValue(); @@ -88,7 +92,7 @@ describe('Window Test and Login', function() { .eventually.be.true; await app.client .element(RegistrationPage.displayNameInput) - .setValue(common.TEST_DISPLAY_NAME1); + .setValue(Common.TEST_DISPLAY_NAME1); await app.client.element(RegistrationPage.getStartedButton).click(); await app.client.waitForExist( ConversationPage.conversationButtonSection, @@ -103,10 +107,10 @@ describe('Window Test and Login', function() { it('registration: can delete account when logged in', async () => { // login as user1 const login = { - mnemonic: common.TEST_MNEMONIC1, - displayName: common.TEST_DISPLAY_NAME1, + mnemonic: Common.TEST_MNEMONIC1, + displayName: Common.TEST_DISPLAY_NAME1, }; - app = await common.startAndStub(login); + app = await Common.startAndStub(login); await app.client.waitForExist( RegistrationPage.conversationListContainer, @@ -115,7 +119,7 @@ describe('Window Test and Login', function() { await app.webContents .executeJavaScript("window.storage.get('primaryDevicePubKey')") - .should.eventually.be.equal(common.TEST_PUBKEY1); + .should.eventually.be.equal(Common.TEST_PUBKEY1); // delete account await app.client.element(SettingsPage.settingsButtonSection).click(); await app.client.element(ConversationPage.deleteAccountButton).click(); @@ -124,12 +128,12 @@ describe('Window Test and Login', function() { // click on the modal OK button to delete the account await app.client.element(ConversationPage.validateDeleteAccount).click(); // wait for the app restart - await common.timeout(2000); + await Common.timeout(2000); // Spectron will loose the connection with the app during the app restart. // We have to restart the app without altering the logged in user or anything here, just to get a valid new ref to the app. - await common.stopApp(app); - app = await common.startApp(); + await Common.stopApp(app); + app = await Common.startApp(); // validate that on app start, the registration sign in is shown await app.client.waitForExist(RegistrationPage.registrationTabSignIn, 3000);