From 13791d28be84b88fdddf7a65ae4f84db238b2167 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 12 May 2020 15:55:12 +1000 Subject: [PATCH] integration test: move joinOpenGroup() to common --- integration_test/common.js | 36 +++++++++++++++++++++++++--- integration_test/integration_test.js | 1 + integration_test/link_device_test.js | 4 ++-- integration_test/open_group_test.js | 35 ++------------------------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/integration_test/common.js b/integration_test/common.js index cac5a9526..849c7cd92 100644 --- a/integration_test/common.js +++ b/integration_test/common.js @@ -397,7 +397,7 @@ module.exports = { .click(); }, - async linkApp2ToApp(app1, app2) { + async linkApp2ToApp(app1, app2, app1Pubkey) { // 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(); @@ -422,7 +422,7 @@ module.exports = { await this.setValueWrapper( app2, RegistrationPage.textareaLinkDevicePubkey, - this.TEST_PUBKEY1 + app1Pubkey ); await app2.client.element(RegistrationPage.linkDeviceTriggerButton).click(); await app1.client.waitForExist(RegistrationPage.toastWrapper, 7000); @@ -458,7 +458,7 @@ module.exports = { // validate primary pubkey of app2 is the same that in app1 await app2.webContents .executeJavaScript("window.storage.get('primaryDevicePubKey')") - .should.eventually.be.equal(this.TEST_PUBKEY1); + .should.eventually.be.equal(app1Pubkey); }, async triggerUnlinkApp2FromApp(app1, app2) { @@ -593,6 +593,36 @@ module.exports = { } }, + async joinOpenGroup(app, openGroupUrl, name) { + await app.client.element(ConversationPage.globeButtonSection).click(); + await app.client.element(ConversationPage.joinOpenGroupButton).click(); + + await this.setValueWrapper(app, ConversationPage.openGroupInputUrl, openGroupUrl); + await app.client + .element(ConversationPage.openGroupInputUrl) + .getValue() + .should.eventually.equal(openGroupUrl); + await app.client.element(ConversationPage.joinOpenGroupButton).click(); + + // validate session loader is shown + await app.client.isExisting(ConversationPage.sessionLoader).should + .eventually.be.true; + // account for slow home internet connection delays... + await app.client.waitForExist( + ConversationPage.sessionToastJoinOpenGroupSuccess, + 60 * 1000 + ); + + // validate overlay is closed + await app.client.isExisting(ConversationPage.leftPaneOverlay).should + .eventually.be.false; + + // validate open chat has been added + await app.client.isExisting( + ConversationPage.rowOpenGroupConversationName(name) + ).should.eventually.be.true; + }, + async stopStubSnodeServer() { if (this.stubSnode) { this.stubSnode.close(); diff --git a/integration_test/integration_test.js b/integration_test/integration_test.js index f5a78e070..97c72430e 100644 --- a/integration_test/integration_test.js +++ b/integration_test/integration_test.js @@ -13,6 +13,7 @@ require('./link_device_test'); require('./closed_group_test'); require('./message_functions_test'); require('./settings_test'); +require('./message_sync_test'); before(async () => { // start the app once before all tests to get the platform-dependent diff --git a/integration_test/link_device_test.js b/integration_test/link_device_test.js index 63239e58a..b29c9e10a 100644 --- a/integration_test/link_device_test.js +++ b/integration_test/link_device_test.js @@ -37,11 +37,11 @@ describe('Link Device', function() { }); it('linkDevice: link two desktop devices', async () => { - await common.linkApp2ToApp(app, app2); + await common.linkApp2ToApp(app, app2, common.TEST_PUBKEY1); }); it('linkDevice: unlink two devices', async () => { - await common.linkApp2ToApp(app, app2); + await common.linkApp2ToApp(app, app2, common.TEST_PUBKEY1); await common.timeout(1000); await common.triggerUnlinkApp2FromApp(app, app2); }); diff --git a/integration_test/open_group_test.js b/integration_test/open_group_test.js index dba3d13e7..bfbdd7d26 100644 --- a/integration_test/open_group_test.js +++ b/integration_test/open_group_test.js @@ -24,43 +24,12 @@ describe('Open groups', function() { await common.killallElectron(); }); - // reduce code duplication to get the initial join - async function joinOpenGroup(url, name) { - await app.client.element(ConversationPage.globeButtonSection).click(); - await app.client.element(ConversationPage.joinOpenGroupButton).click(); - - await common.setValueWrapper(app, ConversationPage.openGroupInputUrl, url); - await app.client - .element(ConversationPage.openGroupInputUrl) - .getValue() - .should.eventually.equal(url); - await app.client.element(ConversationPage.joinOpenGroupButton).click(); - - // validate session loader is shown - await app.client.isExisting(ConversationPage.sessionLoader).should - .eventually.be.true; - // account for slow home internet connection delays... - await app.client.waitForExist( - ConversationPage.sessionToastJoinOpenGroupSuccess, - 60 * 1000 - ); - - // validate overlay is closed - await app.client.isExisting(ConversationPage.leftPaneOverlay).should - .eventually.be.false; - - // validate open chat has been added - await app.client.isExisting( - ConversationPage.rowOpenGroupConversationName(name) - ).should.eventually.be.true; - } - it('openGroup: works with valid open group url', async () => { - await joinOpenGroup(common.VALID_GROUP_URL, common.VALID_GROUP_NAME); + await common.joinOpenGroup(app, common.VALID_GROUP_URL, common.VALID_GROUP_NAME); }); it('openGroup: cannot join two times the same open group', async () => { - await joinOpenGroup(common.VALID_GROUP_URL2, common.VALID_GROUP_NAME2); + await common.joinOpenGroup(app, common.VALID_GROUP_URL2, common.VALID_GROUP_NAME2); // adding a second time the same open group await app.client.element(ConversationPage.globeButtonSection).click();