diff --git a/integration_test/add_friends_test.js b/integration_test/add_friends_test.js index 29a5e83ab..db6fcff00 100644 --- a/integration_test/add_friends_test.js +++ b/integration_test/add_friends_test.js @@ -18,13 +18,11 @@ describe('Add friends', function() { const app1Props = { mnemonic: common.TEST_MNEMONIC1, displayName: common.TEST_DISPLAY_NAME1, - stubSnode: true, }; const app2Props = { mnemonic: common.TEST_MNEMONIC2, displayName: common.TEST_DISPLAY_NAME2, - stubSnode: true, }; [app, app2] = await Promise.all([ diff --git a/integration_test/common.js b/integration_test/common.js index 91b686630..dd2cb4214 100644 --- a/integration_test/common.js +++ b/integration_test/common.js @@ -184,20 +184,11 @@ module.exports = { async startAndStub({ mnemonic, displayName, - stubSnode = false, - stubOpenGroups = false, env = 'test-integration-session', }) { const app = await this.startAndAssureCleanedApp(env); - if (stubSnode) { - await this.startStubSnodeServer(); - this.stubSnodeCalls(app); - } - - if (stubOpenGroups) { - this.stubOpenGroupsCalls(app); - } + await this.startStubSnodeServer(); if (mnemonic && displayName) { await this.restoreFromMnemonic(app, mnemonic, displayName); @@ -246,13 +237,11 @@ module.exports = { const app1Props = { mnemonic: this.TEST_MNEMONIC1, displayName: this.TEST_DISPLAY_NAME1, - stubSnode: true, }; const app2Props = { mnemonic: this.TEST_MNEMONIC2, displayName: this.TEST_DISPLAY_NAME2, - stubSnode: true, }; const [app1, app2] = await Promise.all([ @@ -469,9 +458,9 @@ module.exports = { await app2.client.isExisting(RegistrationPage.conversationListContainer) .should.eventually.be.true; - await app1.client.element(ConversationPage.settingsButtonSection).click(); + await app1.client.element(SettingsPage.settingsButtonSection).click(); await app1.client - .element(ConversationPage.settingsRowWithText('Devices')) + .element(SettingsPage.settingsRowWithText('Devices')) .click(); await app1.client.isExisting(ConversationPage.linkDeviceButtonDisabled) .should.eventually.be.true; @@ -536,17 +525,6 @@ module.exports = { generateSendMessageText: () => `Test message from integration tests ${Date.now()}`, - stubOpenGroupsCalls: app1 => { - app1.webContents.executeJavaScript( - 'window.LokiAppDotNetServerAPI = window.StubAppDotNetAPI;' - ); - }, - - stubSnodeCalls(app1) { - app1.webContents.executeJavaScript( - 'window.LokiMessageAPI = window.StubMessageAPI;' - ); - }, async startStubSnodeServer() { if (!this.stubSnode) { @@ -568,7 +546,7 @@ module.exports = { this.messages[pubkey] = [...ori, { data, timestamp }]; - response.writeHead(200, { 'Content-Type': 'text/html' }); + response.writeHead(200, { 'Content-Type': 'application/json' }); response.end(); } else { const messages = this.messages[pubkey] || []; @@ -576,11 +554,11 @@ module.exports = { if (ENABLE_LOG) { console.warn('GET for', pubkey, retrievedMessages); } - if (this.messages[pubkey]) { - response.writeHead(200, { 'Content-Type': 'application/json' }); - response.write(JSON.stringify(retrievedMessages)); - this.messages[pubkey] = []; - } + response.writeHead(200, { 'Content-Type': 'application/json' }); + + response.write(JSON.stringify(retrievedMessages)); + this.messages[pubkey] = []; + response.end(); } } diff --git a/integration_test/link_device_test.js b/integration_test/link_device_test.js index c805bdb8e..c7f3399b9 100644 --- a/integration_test/link_device_test.js +++ b/integration_test/link_device_test.js @@ -18,11 +18,9 @@ describe('Link Device', function() { const app1Props = { mnemonic: common.TEST_MNEMONIC1, displayName: common.TEST_DISPLAY_NAME1, - stubSnode: true, }; const app2Props = { - stubSnode: true, }; [app, app2] = await Promise.all([ @@ -68,8 +66,8 @@ describe('Link Device', function() { ); // no friends, no closed groups, no open groups. we should see those message sync in the log - await common.logsContains(primaryRenderLogs, 'No closed group to sync.'); - await common.logsContains(primaryRenderLogs, 'No open groups to sync'); - await common.logsContains(primaryRenderLogs, 'No contacts to sync.'); + await common.logsContains(primaryRenderLogs, 'No closed group to sync.', 1); + await common.logsContains(primaryRenderLogs, 'No open groups to sync', 1); + await common.logsContains(primaryRenderLogs, 'No contacts to sync.', 1); }); }); diff --git a/integration_test/open_group_test.js b/integration_test/open_group_test.js index 89f8a3fa7..8f319d491 100644 --- a/integration_test/open_group_test.js +++ b/integration_test/open_group_test.js @@ -15,7 +15,6 @@ describe('Open groups', function() { const login = { mnemonic: common.TEST_MNEMONIC1, displayName: common.TEST_DISPLAY_NAME1, - stubOpenGroups: true, }; app = await common.startAndStub(login); }); diff --git a/integration_test/registration_test.js b/integration_test/registration_test.js index 69bf4b27f..f9ba07704 100644 --- a/integration_test/registration_test.js +++ b/integration_test/registration_test.js @@ -5,6 +5,7 @@ const { afterEach, beforeEach, describe, it } = require('mocha'); 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'); @@ -104,7 +105,6 @@ describe('Window Test and Login', function() { const login = { mnemonic: common.TEST_MNEMONIC1, displayName: common.TEST_DISPLAY_NAME1, - stubOpenGroups: true, }; app = await common.startAndStub(login); @@ -117,7 +117,7 @@ describe('Window Test and Login', function() { .executeJavaScript("window.storage.get('primaryDevicePubKey')") .should.eventually.be.equal(common.TEST_PUBKEY1); // delete account - await app.client.element(ConversationPage.settingsButtonSection).click(); + await app.client.element(SettingsPage.settingsButtonSection).click(); await app.client.element(ConversationPage.deleteAccountButton).click(); await app.client.isExisting(ConversationPage.descriptionDeleteAccount) .should.eventually.be.true; diff --git a/integration_test/settings_test.js b/integration_test/settings_test.js index b166592b3..cf463a411 100644 --- a/integration_test/settings_test.js +++ b/integration_test/settings_test.js @@ -27,7 +27,6 @@ describe('Settings', function() { const appProps = { mnemonic: common.TEST_MNEMONIC1, displayName: common.TEST_DISPLAY_NAME1, - stubSnode: true, }; app = await common.startAndStub(appProps); diff --git a/integration_test/stubs/stub_snode_api.js b/integration_test/stubs/stub_snode_api.js new file mode 100644 index 000000000..7c26d8ecd --- /dev/null +++ b/integration_test/stubs/stub_snode_api.js @@ -0,0 +1,10 @@ +/* eslint-disable class-methods-use-this */ + +class StubSnodeAPI { + + async refreshSwarmNodesForPubKey() { + return []; + } +} + +module.exports = StubSnodeAPI; diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index de913df47..e17871499 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -59,7 +59,7 @@ function MessageReceiver(username, password, signalingKey, options = {}) { openGroupBound = true; } } else { - window.log.error('Can not handle open group data, API is not available'); + window.log.warn('Can not handle open group data, API is not available'); } } diff --git a/preload.js b/preload.js index 2b57298d6..df9237a14 100644 --- a/preload.js +++ b/preload.js @@ -324,15 +324,32 @@ window.lokiSnodeAPI = new LokiSnodeAPI({ localUrl: config.localUrl, }); -window.LokiMessageAPI = require('./js/modules/loki_message_api'); if (process.env.USE_STUBBED_NETWORK) { - window.StubMessageAPI = require('./integration_test/stubs/stub_message_api'); - window.StubAppDotNetApi = require('./integration_test/stubs/stub_app_dot_net_api'); + const StubMessageAPI = require('./integration_test/stubs/stub_message_api'); + window.LokiMessageAPI = StubMessageAPI; + + const StubAppDotNetAPI = require('./integration_test/stubs/stub_app_dot_net_api'); + window.LokiAppDotNetServerAPI = StubAppDotNetAPI; + + const StubSnodeAPI = require('./integration_test/stubs/stub_snode_api'); + + window.lokiSnodeAPI = new StubSnodeAPI({ + serverUrl: config.serverUrl, + localUrl: config.localUrl, + }); +} else { + window.lokiSnodeAPI = new LokiSnodeAPI({ + serverUrl: config.serverUrl, + localUrl: config.localUrl, + }); + + window.LokiMessageAPI = require('./js/modules/loki_message_api'); + + window.LokiAppDotNetServerAPI = require('./js/modules/loki_app_dot_net_api'); } window.LokiPublicChatAPI = require('./js/modules/loki_public_chat_api'); -window.LokiAppDotNetServerAPI = require('./js/modules/loki_app_dot_net_api'); window.LokiFileServerAPI = require('./js/modules/loki_file_server_api'); @@ -427,7 +444,8 @@ Promise.prototype.ignore = function() { if ( config.environment.includes('test') && - !config.environment.includes('swarm-testing') + !config.environment.includes('swarm-testing') && + !config.environment.includes('test-integration') ) { const isWindows = process.platform === 'win32'; /* eslint-disable global-require, import/no-extraneous-dependencies */ @@ -449,5 +467,6 @@ if (config.environment.includes('test-integration')) { multiDeviceUnpairing: true, privateGroupChats: true, useSnodeProxy: !process.env.USE_STUBBED_NETWORK, + useOnionRequests: false, }; }