attachment sending test complete

pull/1067/head
Vincent 6 years ago
parent 819d0c10e1
commit d3c934e119

@ -27,79 +27,8 @@ describe('Closed groups', function() {
await app.client.element(ConversationPage.globeButtonSection).click(); await app.client.element(ConversationPage.globeButtonSection).click();
await app.client.element(ConversationPage.createClosedGroupButton).click(); await app.client.element(ConversationPage.createClosedGroupButton).click();
// fill the groupname // create group and add new friend
await app.client await common.addFriendToNewClosedGroup(app, app2);
.element(ConversationPage.closedGroupNameTextarea)
.setValue(common.VALID_CLOSED_GROUP_NAME1);
await app.client
.element(ConversationPage.closedGroupNameTextarea)
.getValue()
.should.eventually.equal(common.VALID_CLOSED_GROUP_NAME1);
await app.client
.element(ConversationPage.createClosedGroupMemberItem)
.isVisible();
// select the first friend as a member of the groups being created
await app.client
.element(ConversationPage.createClosedGroupMemberItem)
.click();
await app.client
.element(ConversationPage.createClosedGroupMemberItemSelected)
.isVisible();
// trigger the creation of the group
await app.client
.element(ConversationPage.validateCreationClosedGroupButton)
.click();
await app.client.waitForExist(
ConversationPage.sessionToastGroupCreatedSuccess,
1000
);
await app.client.isExisting(
ConversationPage.headerTitleGroupName(common.VALID_CLOSED_GROUP_NAME1)
);
await app.client
.element(ConversationPage.headerTitleMembers(2))
.isVisible();
// validate overlay is closed
await app.client
.isExisting(ConversationPage.leftPaneOverlay)
.should.eventually.be.equal(false);
// move back to the conversation section
await app.client
.element(ConversationPage.conversationButtonSection)
.click();
// validate open chat has been added
await app.client.isExisting(
ConversationPage.rowOpenGroupConversationName(
common.VALID_CLOSED_GROUP_NAME1
)
);
// next check app2 has been invited and has the group in its conversations
await app2.client.waitForExist(
ConversationPage.rowOpenGroupConversationName(
common.VALID_CLOSED_GROUP_NAME1
),
6000
);
// open the closed group conversation on app2
await app2.client
.element(ConversationPage.conversationButtonSection)
.click();
await common.timeout(500);
await app2.client
.element(
ConversationPage.rowOpenGroupConversationName(
common.VALID_CLOSED_GROUP_NAME1
)
)
.click();
// send a message from app and validate it is received on app2 // send a message from app and validate it is received on app2
const textMessage = common.generateSendMessageText(); const textMessage = common.generateSendMessageText();

@ -269,6 +269,81 @@ module.exports = {
return [app1, app2]; return [app1, app2];
}, },
async addFriendToNewClosedGroup(app, app2) {
await app.client
.element(ConversationPage.closedGroupNameTextarea)
.setValue(this.VALID_CLOSED_GROUP_NAME1);
await app.client
.element(ConversationPage.closedGroupNameTextarea)
.getValue()
.should.eventually.equal(this.VALID_CLOSED_GROUP_NAME1);
await app.client
.element(ConversationPage.createClosedGroupMemberItem)
.isVisible();
// select the first friend as a member of the groups being created
await app.client
.element(ConversationPage.createClosedGroupMemberItem)
.click();
await app.client
.element(ConversationPage.createClosedGroupMemberItemSelected)
.isVisible();
// trigger the creation of the group
await app.client
.element(ConversationPage.validateCreationClosedGroupButton)
.click();
await app.client.waitForExist(
ConversationPage.sessionToastGroupCreatedSuccess,
1000
);
await app.client.isExisting(
ConversationPage.headerTitleGroupName(this.VALID_CLOSED_GROUP_NAME1)
);
await app.client
.element(ConversationPage.headerTitleMembers(2))
.isVisible();
// validate overlay is closed
await app.client
.isExisting(ConversationPage.leftPaneOverlay)
.should.eventually.be.equal(false);
// move back to the conversation section
await app.client
.element(ConversationPage.conversationButtonSection)
.click();
// validate open chat has been added
await app.client.isExisting(
ConversationPage.rowOpenGroupConversationName(
this.VALID_CLOSED_GROUP_NAME1
)
);
// next check app2 has been invited and has the group in its conversations
await app2.client.waitForExist(
ConversationPage.rowOpenGroupConversationName(
this.VALID_CLOSED_GROUP_NAME1
),
6000
);
// open the closed group conversation on app2
await app2.client
.element(ConversationPage.conversationButtonSection)
.click();
await this.timeout(500);
await app2.client
.element(
ConversationPage.rowOpenGroupConversationName(
this.VALID_CLOSED_GROUP_NAME1
)
)
.click();
},
async linkApp2ToApp(app1, app2) { async linkApp2ToApp(app1, app2) {
// app needs to be logged in as user1 and app2 needs to be logged out // app needs to be logged in as user1 and app2 needs to be logged out
// start the pairing dialog for the first app // start the pairing dialog for the first app
@ -367,6 +442,27 @@ module.exports = {
} }
}, },
async sendMessage(app, messageText, fileLocation = undefined){
await app.client
.element(ConversationPage.sendMessageTextarea)
.setValue(messageText);
await app.client
.element(ConversationPage.sendMessageTextarea)
.getValue()
.should.eventually.equal(messageText);
// attach a file
if (fileLocation) {
await app.client
.element(ConversationPage.attachmentInput)
.setValue(fileLocation);
}
// send message
await app.client.element(ConversationPage.sendMessageTextarea).click();
await app.client.keys('Enter');
},
generateSendMessageText: () => generateSendMessageText: () =>
`Test message from integration tests ${Date.now()}`, `Test message from integration tests ${Date.now()}`,

@ -6,14 +6,13 @@
const { before } = require('mocha'); const { before } = require('mocha');
const common = require('./common'); const common = require('./common');
require('./registration_test'); // require('./registration_test');
require('./open_group_test'); // require('./open_group_test');
require('./add_friends_test'); // require('./add_friends_test');
// require('./link_device_test'); // require('./link_device_test');
// require('./closed_group_test'); // require('./closed_group_test');
require('./message_functions_test');
require('./message_sync_test');
before(async () => { before(async () => {

@ -3,46 +3,70 @@
/* eslint-disable func-names */ /* eslint-disable func-names */
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
const common = require('./common'); const common = require('./common');
const { afterEach, beforeEach, describe, it } = require('mocha'); const path = require('path');
describe('Link Device', function() { const { after, before, describe, it } = require('mocha');
const ConversationPage = require('./page-objects/conversation.page');
describe('Message Functions', function() {
let app; let app;
let app2; let app2;
this.timeout(60000); this.timeout(60000);
this.slow(15000); this.slow(15000);
beforeEach(async () => { before(async () => {
await common.killallElectron(); await common.killallElectron();
await common.stopStubSnodeServer(); await common.stopStubSnodeServer();
const app1Props = { [app, app2] = await common.startAppsAsFriends();
mnemonic: common.TEST_MNEMONIC1,
displayName: common.TEST_DISPLAY_NAME1,
stubSnode: true,
};
const app2Props = {
stubSnode: true,
};
[app, app2] = await Promise.all([
common.startAndStub(app1Props),
common.startAndStubN(app2Props, 2),
]);
}); });
afterEach(async () => { after(async () => {
await common.killallElectron(); // await common.stopApp(app);
await common.stopStubSnodeServer(); // await common.killallElectron();
// await common.stopStubSnodeServer();
}); });
it('link two desktop devices', async () => { it('can send attachment', async () => {
await common.linkApp2ToApp(app, app2); await app.client.element(ConversationPage.globeButtonSection).click();
await app.client.element(ConversationPage.createClosedGroupButton).click();
// create group and add new friend
await common.addFriendToNewClosedGroup(app, app2);
// send attachment from app1 to closed group
const fileLocation = path.join(__dirname, '/test_attachment');
const messageText = 'test_attachment';
common.sendMessage(app, messageText, fileLocation);
// validate attachment sent
await app.client.waitForExist(
ConversationPage.existingSendMessageText(messageText),
3000
);
// validate attachment recieved
await app2.client.waitForExist(
ConversationPage.existingReceivedMessageText(messageText),
5000
);
}); });
it('unlink two devices', async () => { it('can delete message', async () => {
await common.linkApp2ToApp(app, app2); const messageText = 'delete me';
await common.timeout(1000); common.sendMessage(app, messageText);
await common.triggerUnlinkApp2FromApp(app, app2);
await app.client.waitForExist(
ConversationPage.existingSendMessageText(messageText),
3000
);
await app2.client.waitForExist(
ConversationPage.existingReceivedMessageText(messageText),
5000
);
}); });
}); });

@ -9,11 +9,11 @@ module.exports = {
'Send your first message' 'Send your first message'
), ),
existingSendMessageText: textMessage => existingSendMessageText: textMessage =>
`//*[contains(@class, "module-message__text--outgoing")and .//span[contains(@class, "text-selectable")][contains(string(), '${textMessage}')]]`, `//*[contains(@class, "module-message__text--outgoing") and .//span[contains(@class, "text-selectable")][contains(string(), '${textMessage}')]]`,
existingFriendRequestText: textMessage => existingFriendRequestText: textMessage =>
`//*[contains(@class, "module-message-friend-request__container")and .//span[contains(@class, "text-selectable")][contains(string(), '${textMessage}')]]`, `//*[contains(@class, "module-message-friend-request__container")and .//span[contains(@class, "text-selectable")][contains(string(), '${textMessage}')]]`,
existingReceivedMessageText: textMessage => existingReceivedMessageText: textMessage =>
`//*[contains(@class, "module-message__text--incoming")and .//span[contains(@class, "text-selectable")][contains(string(), '${textMessage}')]]`, `//*[contains(@class, "module-message__text--incoming") and .//span[contains(@class, "text-selectable")][contains(string(), '${textMessage}')]]`,
// conversations // conversations
conversationButtonSection: conversationButtonSection:
@ -28,6 +28,9 @@ module.exports = {
`${number} members` `${number} members`
), ),
attachmentInput: '//*[contains(@class, "choose-file")]/input[@type="file"]',
attachmentButton: '//*[contains(@class, "choose-file")]/button',
// channels // channels
globeButtonSection: globeButtonSection:
'//*[contains(@class,"session-icon-button") and .//*[contains(@class, "globe")]]', '//*[contains(@class,"session-icon-button") and .//*[contains(@class, "globe")]]',
@ -77,7 +80,7 @@ module.exports = {
oneNotificationFriendRequestLeft: oneNotificationFriendRequestLeft:
'//*[contains(@class,"session-icon-button") and .//*[contains(@class, "users")] and .//*[contains(@class, "notification-count") and contains(string(), "1")] ]', '//*[contains(@class,"session-icon-button") and .//*[contains(@class, "users")] and .//*[contains(@class, "notification-count") and contains(string(), "1")] ]',
oneNotificationFriendRequestTop: oneNotificationFriendRequestTop:
'//*[contains(@class,"contact-notification-count-bubble") and contains(string(), "1")]', '//*[contains(@class,"module-left-pane__header")] //*[contains(@class, "notification-count") and contains(string(), "1")]',
friendRequestFromUser: (displayName, pubkey) => 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( `//*[contains(@class,"module-left-pane__list-popup") and .//*[contains(@class, "module-conversation__user") and .//*[contains(string(), "${displayName}")] and .//*[contains(string(), "(...${pubkey.substring(
60 60

Binary file not shown.

@ -140,15 +140,16 @@ a {
} }
input[type='file'] { input[type='file'] {
display: none; // Must be displayed in order to programmatically
// insert file paths)
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
opacity: 0;
top: 0; top: 0;
left: 0; left: 0;
cursor: pointer; cursor: pointer;
z-index: 1; z-index: -100;
} }
} }

Loading…
Cancel
Save