move add_contacts_test open_group_test and registration_test to ts

pull/1287/head
Audric Ackermann 5 years ago
parent 592c31dfc0
commit 720bb54bc1
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -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;

@ -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';

@ -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),

@ -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);
Loading…
Cancel
Save