From 5f42eb821282453c1f36bb49afd26b4079df698c Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 1 Apr 2020 10:10:32 +1100 Subject: [PATCH] fix integration tests --- integration_test/add_friends_test.js | 17 ++++++++--------- integration_test/closed_group_test.js | 9 ++++----- integration_test/common.js | 14 +++++++++----- integration_test/open_group_test.js | 18 ++++++++---------- integration_test/page-objects/common.page.js | 2 +- .../page-objects/conversation.page.js | 12 ++++++------ integration_test/registration_test.js | 6 ++++-- preload.js | 7 +++++++ 8 files changed, 47 insertions(+), 38 deletions(-) diff --git a/integration_test/add_friends_test.js b/integration_test/add_friends_test.js index daea18b8d..a86dbf1ec 100644 --- a/integration_test/add_friends_test.js +++ b/integration_test/add_friends_test.js @@ -43,9 +43,8 @@ describe('Add friends', function() { await app.client.element(ConversationPage.contactsButtonSection).click(); await app.client.element(ConversationPage.addContactButton).click(); - await app.client - .isExisting(ConversationPage.leftPaneOverlay) - .should.eventually.be.equal(true); + await app.client.isExisting(ConversationPage.leftPaneOverlay).should + .eventually.be.true; await app.client .element(ConversationPage.sessionIDInput) @@ -71,9 +70,8 @@ describe('Add friends', function() { ); // assure friend request message has been sent await common.timeout(3000); - await app.client - .isExisting(ConversationPage.retrySendButton) - .should.eventually.be.equal(false); + await app.client.isExisting(ConversationPage.retrySendButton).should + .eventually.be.false; // wait for left notification Friend Request count to go to 1 and click it await app2.client.waitForExist( @@ -86,7 +84,7 @@ describe('Add friends', function() { // open the dropdown from the top friend request count await app2.client.isExisting( ConversationPage.oneNotificationFriendRequestTop - ); + ).should.eventually.be.true; await app2.client .element(ConversationPage.oneNotificationFriendRequestTop) .click(); @@ -97,8 +95,9 @@ describe('Add friends', function() { common.TEST_DISPLAY_NAME1, common.TEST_PUBKEY1 ) - ); - await app2.client.isExisting(ConversationPage.acceptFriendRequestButton); + ).should.eventually.be.true; + await app2.client.isExisting(ConversationPage.acceptFriendRequestButton) + .should.eventually.be.true; // accept the friend request and validate that on both side the "accepted FR" message is shown await app2.client diff --git a/integration_test/closed_group_test.js b/integration_test/closed_group_test.js index 414e81bfb..42db71fbc 100644 --- a/integration_test/closed_group_test.js +++ b/integration_test/closed_group_test.js @@ -59,15 +59,14 @@ describe('Closed groups', function() { ); await app.client.isExisting( ConversationPage.headerTitleGroupName(common.VALID_CLOSED_GROUP_NAME1) - ); + ).should.eventually.be.true; await app.client .element(ConversationPage.headerTitleMembers(2)) .isVisible(); // validate overlay is closed - await app.client - .isExisting(ConversationPage.leftPaneOverlay) - .should.eventually.be.equal(false); + await app.client.isExisting(ConversationPage.leftPaneOverlay).should + .eventually.be.false; // move back to the conversation section await app.client @@ -79,7 +78,7 @@ describe('Closed groups', function() { ConversationPage.rowOpenGroupConversationName( common.VALID_CLOSED_GROUP_NAME1 ) - ); + ).should.eventually.be.true; // next check app2 has been invited and has the group in its conversations await app2.client.waitForExist( diff --git a/integration_test/common.js b/integration_test/common.js index cda7f29e8..692416fb3 100644 --- a/integration_test/common.js +++ b/integration_test/common.js @@ -244,7 +244,7 @@ module.exports = { // open the dropdown from the top friend request count await app2.client.isExisting( ConversationPage.oneNotificationFriendRequestTop - ); + ).should.eventually.be.true; await app2.client .element(ConversationPage.oneNotificationFriendRequestTop) .click(); @@ -307,7 +307,8 @@ module.exports = { 2000 ); - await app1.client.isExisting(ConversationPage.unpairDeviceButton); + await app1.client.isExisting(ConversationPage.unpairDeviceButton).should + .eventually.be.true; await app1.client.isExisting(ConversationPage.linkDeviceButtonDisabled) .should.eventually.be.true; @@ -325,7 +326,8 @@ module.exports = { async triggerUnlinkApp2FromApp(app1, app2) { // check app2 is loggedin - await app2.client.isExisting(RegistrationPage.conversationListContainer); + await app2.client.isExisting(RegistrationPage.conversationListContainer) + .should.eventually.be.true; await app1.client.element(ConversationPage.settingsButtonSection).click(); await app1.client.element(ConversationPage.deviceSettingsRow).click(); @@ -340,7 +342,7 @@ module.exports = { 2000 ); await app1.client.element(ConversationPage.linkDeviceButton).isEnabled() - .should.eventually.be.false; + .should.eventually.be.true; // let time to app2 to catch the event and restart dropping its data await this.timeout(5000); @@ -349,7 +351,8 @@ module.exports = { // (did not find a better way than checking the app no longer being accessible) let isApp2Joinable = true; try { - await app2.client.isExisting(RegistrationPage.registrationTabSignIn); + await app2.client.isExisting(RegistrationPage.registrationTabSignIn) + .should.eventually.be.true; } catch (err) { // if we get an error here, it means Spectron is lost. // this is a good thing because it means app2 restarted @@ -413,6 +416,7 @@ module.exports = { if (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/open_group_test.js b/integration_test/open_group_test.js index 53ea93dc8..486a5256b 100644 --- a/integration_test/open_group_test.js +++ b/integration_test/open_group_test.js @@ -37,16 +37,16 @@ describe('Open groups', function() { await app.client.element(ConversationPage.joinOpenGroupButton).click(); // validate session loader is shown - await app.client.isExisting(ConversationPage.sessionLoader); + await app.client.isExisting(ConversationPage.sessionLoader).should + .eventually.be.true; await app.client.waitForExist( ConversationPage.sessionToastJoinOpenGroupSuccess, 9000 ); // validate overlay is closed - await app.client - .isExisting(ConversationPage.leftPaneOverlay) - .should.eventually.be.equal(false); + await app.client.isExisting(ConversationPage.leftPaneOverlay).should + .eventually.be.false; // validate open chat has been added await app.client.waitForExist( @@ -81,9 +81,8 @@ describe('Open groups', function() { .setValue(common.VALID_GROUP_URL2); await app.client.element(ConversationPage.joinOpenGroupButton).click(); // validate session loader is not shown - await app.client - .isExisting(ConversationPage.sessionLoader) - .should.eventually.be.equal(false); + await app.client.isExisting(ConversationPage.sessionLoader).should + .eventually.be.false; await app.client.waitForExist( ConversationPage.sessionToastJoinOpenGroupAlreadyExist, @@ -91,9 +90,8 @@ describe('Open groups', function() { ); // validate overlay is still opened - await app.client - .isExisting(ConversationPage.leftPaneOverlay) - .should.eventually.be.equal(true); + await app.client.isExisting(ConversationPage.leftPaneOverlay).should + .eventually.be.true; }); it('can send message to open group', async () => { diff --git a/integration_test/page-objects/common.page.js b/integration_test/page-objects/common.page.js index 05e6ca5b6..9a3a77573 100644 --- a/integration_test/page-objects/common.page.js +++ b/integration_test/page-objects/common.page.js @@ -8,7 +8,7 @@ module.exports = { divRoleButtonWithTextDisabled: text => `//div[contains(string(), "${text}")][contains(@role, "button")][contains(@class, "disabled")]`, divRoleButtonDangerWithText: text => - `${module.exports.divRoleButtonWithText(text)}`, + `${module.exports.divRoleButtonWithText(text)}[contains(@class, "danger")]`, inputWithPlaceholder: placeholder => `//input[contains(@placeholder, "${placeholder}")]`, textAreaWithPlaceholder: placeholder => diff --git a/integration_test/page-objects/conversation.page.js b/integration_test/page-objects/conversation.page.js index df879c66c..a58b5b9e0 100644 --- a/integration_test/page-objects/conversation.page.js +++ b/integration_test/page-objects/conversation.page.js @@ -77,7 +77,7 @@ module.exports = { oneNotificationFriendRequestLeft: '//*[contains(@class,"session-icon-button") and .//*[contains(@class, "users")] and .//*[contains(@class, "notification-count") and contains(string(), "1")] ]', oneNotificationFriendRequestTop: - '//*[contains(@class,"contact-notification-count-bubble") and contains(string(), "1")]', + '//*[contains(@class,"notification-count hover") and contains(string(), "1")]', friendRequestFromUser: (displayName, pubkey) => `//*[contains(@class,"module-left-pane__list-popup") and .//*[contains(@class, "module-conversation__user") and .//*[contains(string(), "${displayName}")] and .//*[contains(string(), "(...${pubkey.substring( 60 @@ -99,23 +99,23 @@ module.exports = { ), validateDeleteAccount: commonPage.divRoleButtonDangerWithText('OK'), - // device pairing + // device linking noPairedDeviceMessage: - '//*[contains(@class, "session-settings-item__title")][contains(string(), "No paired devices")]', + '//*[contains(@class, "session-settings-item__title")][contains(string(), "No linked devices")]', linkDeviceButton: commonPage.divRoleButtonWithText('Link New Device'), linkDeviceButtonDisabled: commonPage.divRoleButtonWithTextDisabled( 'Link New Device' ), devicePairingDialog: '//*[contains(@class,"device-pairing-dialog")]', qrImageDiv: commonPage.divWithClass('qr-image'), - allowPairingButton: commonPage.divRoleButtonWithText('Allow Pairing'), + allowPairingButton: commonPage.divRoleButtonWithText('Allow Linking'), okButton: commonPage.divRoleButtonWithText('OK'), devicePairedDescription: secretWords => commonPage.divWithClassAndText( 'session-settings-item__description', secretWords ), - unpairDeviceButton: commonPage.divRoleButtonDangerWithText('Unpair Device'), + unpairDeviceButton: commonPage.divRoleButtonDangerWithText('Unlink Device'), deleteAccountButton: commonPage.divRoleButtonDangerWithText('Delete Account'), - validateUnpairDevice: commonPage.divRoleButtonDangerWithText('Unpair'), + validateUnpairDevice: commonPage.divRoleButtonDangerWithText('Unlink'), }; diff --git a/integration_test/registration_test.js b/integration_test/registration_test.js index 53a90d14c..3e0a57aa7 100644 --- a/integration_test/registration_test.js +++ b/integration_test/registration_test.js @@ -82,7 +82,8 @@ describe('Window Test and Login', function() { pubkeyGenerated.should.have.lengthOf(66); pubkeyGenerated.substr(0, 2).should.be.equal('05'); await app.client.element(RegistrationPage.continueButton).click(); - await app.client.isExisting(RegistrationPage.displayNameInput); + await app.client.isExisting(RegistrationPage.displayNameInput).should + .eventually.be.true; await app.client .element(RegistrationPage.displayNameInput) .setValue(common.TEST_DISPLAY_NAME1); @@ -117,7 +118,8 @@ describe('Window Test and Login', function() { // delete account await app.client.element(ConversationPage.settingsButtonSection).click(); await app.client.element(ConversationPage.deleteAccountButton).click(); - await app.client.isExisting(ConversationPage.descriptionDeleteAccount); + await app.client.isExisting(ConversationPage.descriptionDeleteAccount) + .should.eventually.be.true; // click on the modal OK button to delete the account await app.client.element(ConversationPage.validateDeleteAccount).click(); // wait for the app restart diff --git a/preload.js b/preload.js index 08c73ed67..92837f488 100644 --- a/preload.js +++ b/preload.js @@ -432,3 +432,10 @@ if ( buildNewOnionPaths: () => [], }; } +if (config.environment.includes('test-integration')) { + window.lokiFeatureFlags = { + multiDeviceUnpairing: true, + privateGroupChats: true, + useSnodeProxy: !process.env.USE_STUBBED_NETWORK, + }; +}