Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix integration tests #1038

Merged
merged 2 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 8 additions & 9 deletions integration_test/add_friends_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand All @@ -86,7 +84,7 @@ describe('Add friends', function() {
// open the dropdown from the top friend request count
await app2.client.isExisting(
ConversationPage.oneNotificationFriendRequestTop
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed all waitForExist to isExisting last commit. But it was not checking anything then. So I need to check the return of the await there

).should.eventually.be.true;
await app2.client
.element(ConversationPage.oneNotificationFriendRequestTop)
.click();
Expand All @@ -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
Expand Down
9 changes: 4 additions & 5 deletions integration_test/closed_group_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
16 changes: 10 additions & 6 deletions integration_test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module.exports = {
const killStr =
process.platform === 'win32'
? 'taskkill /im electron.exe /t /f'
: 'pkill -f "node_modules/.bin/electron"';
: 'pkill -f "node_modules/electron/dist/electron"';
return new Promise(resolve => {
exec(killStr, (err, stdout, stderr) => {
if (err) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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();
}
Expand Down
18 changes: 8 additions & 10 deletions integration_test/open_group_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -81,19 +81,17 @@ 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,
1000
);

// 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 () => {
Expand Down
2 changes: 1 addition & 1 deletion integration_test/page-objects/common.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
12 changes: 6 additions & 6 deletions integration_test/page-objects/conversation.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'),
};
6 changes: 4 additions & 2 deletions integration_test/registration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,3 +432,10 @@ if (
buildNewOnionPaths: () => [],
};
}
if (config.environment.includes('test-integration')) {
window.lokiFeatureFlags = {
multiDeviceUnpairing: true,
privateGroupChats: true,
useSnodeProxy: !process.env.USE_STUBBED_NETWORK,
};
}