Flextab tests (#4506)

* Organized Tests

organized tests in diferent classes for diferent components

* added render tests and removed done callback

* added flextab tests
pull/4518/head
Martin Schoeler 9 years ago committed by Rodrigo Nascimento
parent 0937d59fbf
commit dfce4f64af
  1. 1
      tests/pageobjects/Page.js
  2. 93
      tests/pageobjects/flex-tab.page.js
  3. 17
      tests/pageobjects/main-content.page.js
  4. 88
      tests/pageobjects/side-nav.page.js
  5. 415
      tests/steps/basic-usage.js

@ -4,6 +4,7 @@ class Page {
open(path) {
browser.url('http://localhost:3000/' + path);
this.body.waitForExist();
browser.windowHandleSize({width:1280, height:800});
}
}

@ -0,0 +1,93 @@
import Page from './Page';
class FlexTab extends Page {
get membersTab() { return browser.element('[title~=Members]'); }
get membersTabContent() { return browser.element('.animated'); }
get userSearchBar() { return browser.element('#user-add-search'); }
get removeUserBtn() { return browser.element('.remove-user'); }
get startVideoCall() { return browser.element('.start-video-call'); }
get startAudioCall() { return browser.element('.start-audio-call'); }
get showAll() { return browser.element('.see-all'); }
get channelTab() { return browser.element('[title="Room Info"]'); }
get channelSettings() { return browser.element('.channel-settings'); }
get searchTab() { return browser.element('[title="Search"]'); }
get searchTabContent() { return browser.element('.search-messages-list'); }
get messageSearchBar() { return browser.element('#message-search'); }
get searchResult() { return browser.element('.new-day'); }
get notificationsTab() { return browser.element('[title="Notifications"]'); }
get notificationsSettings() { return browser.element('.push-notifications'); }
get filesTab() { return browser.element('[title="Files List"]'); }
get fileItem() { return browser.element('.uploaded-files-list ul:first-child'); }
get filesTabContent() { return browser.element('.uploaded-files-list'); }
get fileDelete() { return browser.element('.uploaded-files-list ul:first-child .file-delete'); }
get fileDownload() { return browser.element('.uploaded-files-list ul:first-child .file-download'); }
get fileName() { return browser.element('.uploaded-files-list ul:first-child .room-file-item'); }
get mentionsTab() { return browser.element('[title="Mentions"]'); }
get mentionsTabContent() { return browser.element('.mentioned-messages-list'); }
get starredTab() { return browser.element('[title="Starred Messages"]'); }
get starredTabContent() { return browser.element('.starred-messages-list'); }
get pinnedTab() { return browser.element('[title="Pinned Messages"]'); }
get pinnedTabContent() { return browser.element('.pinned-messages-list'); }
get archiveBtn() { return browser.element('.clearfix:last-child .icon-pencil'); }
get archiveRadio() { return browser.element('.editing'); }
get archiveSave() { return browser.element('.save'); }
get confirmBtn() { return browser.element('.confirm'); }
closeTabs() {
this.channelTab.click();
browser.pause(500);
this.channelTab.click();
}
confirmPopup() {
this.confirmBtn.click();
}
archiveChannel() {
browser.pause(3000);
this.channelTab.click();
this.archiveBtn.waitForVisible();
this.archiveBtn.click();
this.archiveRadio.waitForVisible();
this.archiveRadio.click();
this.archiveSave.click();
}
addPeopleToChannel(user) {
this.membersTab.click();
this.userSearchBar.waitForVisible();
this.userSearchBar.setValue(user);
browser.waitForVisible('.-autocomplete-item');
browser.click('.-autocomplete-item');
}
removePeopleFromChannel(user) {
this.membersTab.click();
browser.waitForVisible('[title="'+user+'"]');
browser.click('[title="'+user+'"]');
this.removeUserBtn.click();
}
}
module.exports = new FlexTab();

@ -0,0 +1,17 @@
import Page from './Page';
class MainContent extends Page {
get messageInput() { return browser.element('.input-message'); }
get sendBtn() { return browser.element('.message-buttons.send-button'); }
sendMessage(text) {
this.messageInput.setValue(text);
this.sendBtn.click();
browser.waitUntil(function() {
return browser.getText('.message:last-child .body') === text;
}, 2000);
}
}
module.exports = new MainContent();

@ -0,0 +1,88 @@
import Page from './Page';
class SideNav extends Page {
get directMessageTarget() { return browser.element('#who'); }
get saveDirectMessageBtn() { return browser.element('.save-direct-message'); }
get channelType() { return browser.element('#channel-type'); }
get channelReadOnly() { return browser.element('#channel-ro'); }
get channelName() { return browser.element('#channel-name'); }
get saveChannelBtn() { return browser.element('.save-channel'); }
get messageInput() { return browser.element('.input-message'); }
get accountBoxUserName() { return browser.element('.account-box .data h4'); }
get accountBoxUserAvatar() { return browser.element('.account-box .avatar-image'); }
get newChannelBtn() { return browser.element('.rooms-list .add-room:nth-of-type(1)'); }
get newChannelIcon() { return browser.element('.rooms-list .add-room:nth-of-type(1) .icon-plus'); }
get moreChannels() { return browser.element('.rooms-list .more-channels'); }
get newDirectMessageBtn() { return browser.element('.rooms-list .add-room:nth-of-type(2)'); }
get newDirectMessageIcon() { return browser.element('.rooms-list .add-room:nth-of-type(2) .icon-plus'); }
get moreDirectMessages() { return browser.element('.rooms-list .more-direct-messages'); }
get general() { return browser.element('[title="general"]'); }
get channelHoverIcon() { return browser.element('[title="general"] .icon-eye-off'); }
get userOptions() { return browser.element('.options'); }
get statusOnline() { return browser.element('.online'); }
get statusAway() { return browser.element('.away'); }
get statusBusy() { return browser.element('.busy'); }
get statusOffline() { return browser.element('.offline'); }
get account() { return browser.element('#account'); }
get logout() { return browser.element('#logout'); }
openChannel(channelName) {
browser.click('[title="'+channelName+'"]');
this.messageInput.waitForExist();
}
createChannel(channelName, isPrivate, isReadOnly) {
this.newChannelBtn.click();
this.channelType.waitForVisible(10000);
this.channelName.setValue(channelName);
if (isPrivate) {
this.channelType.click();
}
if (isReadOnly) {
this.channelReadOnly.click();
}
this.saveChannelBtn.click();
browser.waitForExist('[title="'+channelName+'"]');
}
addPeopleToChannel(user) {
this.membersTab.click();
this.userSearchBar.waitForVisible();
this.userSearchBar.setValue(user);
browser.waitForVisible('.-autocomplete-item');
browser.click('.-autocomplete-item');
}
removePeopleFromChannel(user) {
this.membersTab.click();
browser.waitForVisible('[title="'+user+'"]');
browser.click('[title="'+user+'"]');
this.removeUserBtn.click();
}
startDirectMessage(user) {
this.newDirectMessageBtn.click();
this.directMessageTarget.waitForVisible(1000);
this.directMessageTarget.setValue(user);
browser.waitForVisible('.-autocomplete-item', 1000);
browser.click('.-autocomplete-item');
this.saveDirectMessageBtn.click();
browser.waitForExist('[title="'+user+'"]');
}
}
module.exports = new SideNav();

@ -2,21 +2,35 @@
/* eslint-disable func-names, prefer-arrow-callback */
import loginPage from '../pageobjects/login.page';
import flexTab from '../pageobjects/flex-tab.page';
import mainContent from '../pageobjects/main-content.page';
import sideNav from '../pageobjects/side-nav.page';
//Login info from the test user
const username = 'user-test-'+Date.now();
const email = username+'@rocket.chat';
const password = 'rocket.chat';
const channelname = 'channel-test-'+Date.now();
const privatechannelname = 'private-channel-test-'+Date.now();
//Names of the test channels
const PublicChannelName = 'channel-test-'+Date.now();
const privateChannelName = 'private-channel-test-'+Date.now();
//User interactions(direct messages, add, remove...)
const targetUser = 'rocket.cat';
//Test data
const message = 'message from '+username;
//Basic usage test start
describe('Basic usage', function() {
it('load page', () => {
loginPage.open();
// browser.windowHandleSize({width:1280, height:800});
});
it('crate user', function(done) {
it('crate user', function() {
loginPage.gotToRegister();
loginPage.registerNewUser({username, email, password});
@ -27,10 +41,10 @@ describe('Basic usage', function() {
browser.waitForExist('.main-content', 5000);
done();
});
it('logout', function(done) {
it('logout', function() {
browser.waitForVisible('.account-box');
browser.click('.account-box');
browser.pause(200);
@ -38,234 +52,315 @@ describe('Basic usage', function() {
browser.waitForVisible('#logout');
browser.click('#logout');
done();
});
it('login', function(done) {
it('login', function() {
loginPage.login({email, password});
browser.waitForExist('.main-content', 5000);
done();
});
describe('side nav bar', function() {
describe('render', function() {
it('should show the logged username', () => {
sideNav.accountBoxUserName.isVisible().should.be.true;
});
it('should show the logged user avatar', function() {
sideNav.accountBoxUserAvatar.isVisible().should.be.true;
});
it('should show the new channel button', function() {
sideNav.newChannelBtn.isVisible().should.be.true;
});
it('should show the plus icon', function() {
sideNav.newChannelIcon.isVisible().should.be.true;
});
it('should show the "More Channels" button', function() {
sideNav.moreChannels.isVisible().should.be.true;
});
it('should show the new direct message button', function() {
sideNav.newDirectMessageBtn.isVisible().should.be.true;
});
it('should show the plus icon', function() {
sideNav.newDirectMessageIcon.isVisible().should.be.true;
});
it('should show the "More Direct Messages" buton', function() {
sideNav.moreDirectMessages.isVisible().should.be.true;
});
it('should show "general" channel', function() {
sideNav.general.isVisible().should.be.true;
});
it('should not show eye icon on general', function() {
sideNav.channelHoverIcon.isVisible().should.be.false;
});
it('should show eye icon on hover', function() {
sideNav.general.moveToObject();
sideNav.channelHoverIcon.isVisible().should.be.true;
});
});
describe('user options', function() {
describe('render', function() {
it('should show user options', function() {
sideNav.accountBoxUserName.click();
sideNav.userOptions.waitForVisible();
sideNav.userOptions.isVisible().should.be.true;
});
it('should show online button', function() {
sideNav.statusOnline.isVisible().should.be.true;
});
it('should show away button', function() {
sideNav.statusAway.isVisible().should.be.true;
});
it('should show busy button', function() {
sideNav.statusBusy.isVisible().should.be.true;
});
it('should show offline button', function() {
sideNav.statusOffline.isVisible().should.be.true;
});
it('should show settings button', function() {
sideNav.account.isVisible().should.be.true;
});
it('should show logout button', function() {
sideNav.logout.isVisible().should.be.true;
});
});
});
});
it('open GENERAL', function(done) {
it('open GENERAL', function() {
browser.waitForExist('.wrapper > ul .link-room-GENERAL', 50000);
browser.click('.wrapper > ul .link-room-GENERAL');
browser.waitForExist('.input-message', 5000);
done();
});
it('send a message', function(done) {
const message = 'message from '+username;
browser.setValue('.input-message', message);
});
browser.waitForExist('.message-buttons.send-button');
browser.click('.message-buttons.send-button');
describe('flextab usage', function() {
describe('render', function() {
it('should show the room info button', function() {
flexTab.channelTab.isVisible().should.be.true;
});
it('should show the room info tab content', function() {
flexTab.channelTab.click();
flexTab.channelSettings.isVisible().should.be.true;
});
it('should show the message search button', function() {
flexTab.searchTab.isVisible().should.be.true;
});
it('should show the message tab content', function() {
flexTab.searchTab.click();
flexTab.searchTabContent.isVisible().should.be.true;
});
it('should show the members tab button', function() {
flexTab.membersTab.isVisible().should.be.true;
});
it('should show the members content', function() {
flexTab.membersTab.click();
flexTab.membersTabContent.isVisible().should.be.true;
});
it('should show the members search bar', function() {
flexTab.userSearchBar.isVisible().should.be.true;
});
it('should show the show all link', function() {
flexTab.showAll.isVisible().should.be.true;
});
it('should show the start video call button', function() {
flexTab.startVideoCall.isVisible().should.be.true;
});
it('should show the start audio call', function() {
flexTab.startAudioCall.isVisible().should.be.true;
});
it('should show the notifications button', function() {
flexTab.notificationsTab.isVisible().should.be.true;
});
it('should show the notifications Tab content', function() {
flexTab.notificationsTab.click();
flexTab.notificationsSettings.isVisible().should.be.true;
});
it('should show the files button', function() {
flexTab.filesTab.isVisible().should.be.true;
});
it('should show the files Tab content', function() {
flexTab.filesTab.click();
flexTab.filesTabContent.isVisible().should.be.true;
});
it('should show the mentions button', function() {
flexTab.mentionsTab.isVisible().should.be.true;
});
it('should show the mentions Tab content', function() {
flexTab.mentionsTab.click();
flexTab.mentionsTabContent.isVisible().should.be.true;
});
it('should show the starred button', function() {
flexTab.starredTab.isVisible().should.be.true;
});
it('should show the starred Tab content', function() {
flexTab.starredTab.click();
flexTab.starredTabContent.isVisible().should.be.true;
});
it('should show the pinned button', function() {
flexTab.pinnedTab.isVisible().should.be.true;
});
it('should show the pinned messages Tab content', function() {
flexTab.pinnedTab.click();
flexTab.pinnedTabContent.isVisible().should.be.true;
});
});
});
browser.waitUntil(function() {
return browser.getText('.message:last-child .body') === message;
}, 2000);
it('send a message', function() {
mainContent.sendMessage(message);
done();
});
//DIRECT MESAGE
it('start a direct message with rocket.cat', function(done) {
//User to send a private message
const targetUser = 'rocket.cat';
browser.click('.add-room:nth-of-type(2)');
browser.waitForVisible('#who', 50000);
browser.setValue(' #who', targetUser);
browser.waitForExist('.-autocomplete-item', 50000);
browser.click('.-autocomplete-item');
it('start a direct message with rocket.cat', function() {
sideNav.startDirectMessage(targetUser);
browser.waitForVisible('.save-direct-message', 50000);
browser.click('.save-direct-message');
done();
});
it('open the direct message', function(done) {
browser.waitForExist('ul:nth-of-type(2)');
browser.click('ul:nth-of-type(2):last-child');
browser.waitForExist('.input-message', 5000);
it('open the direct message', function() {
sideNav.openChannel(targetUser);
done();
});
it('send a direct message', function(done) {
const message = 'message from '+username;
browser.setValue('.input-message', message);
it('send a direct message', function() {
mainContent.sendMessage(message);
browser.waitForExist('.message-buttons.send-button');
browser.click('.message-buttons.send-button');
browser.waitUntil(function() {
return browser.getText('.message:last-child .body') === message;
}, 2000);
done();
});
//CHANNEL
it('create a public channel', function(done) {
browser.click('.add-room:nth-of-type(1)');
browser.waitForVisible('#channel-name', 50000);
browser.setValue(' #channel-name', channelname);
it('create a public channel', function() {
sideNav.createChannel(PublicChannelName, false, false);
sideNav.openChannel(PublicChannelName);
browser.waitForVisible('.save-channel', 50000);
browser.click('.save-channel');
browser.waitForExist('.input-message', 5000);
done();
});
it('send a message in the public channel', function(done) {
const message = 'message from '+username;
browser.waitForExist('.input-message');
browser.waitForVisible('.input-message');
browser.setValue('.input-message', message);
it('send a message in the public channel', function() {
mainContent.sendMessage(message);
browser.waitForExist('.message-buttons.send-button');
browser.click('.message-buttons.send-button');
});
browser.waitUntil(function() {
return browser.getText('.message:last-child .body') === message;
}, 2000);
it('add people to the room', function() {
flexTab.addPeopleToChannel(targetUser);
done();
});
it('add people to the room', function(done) {
const targetUser = 'rocket.cat';
browser.waitForExist('.icon-users');
browser.click('.icon-users');
it('remove people from room', function() {
flexTab.closeTabs();
flexTab.removePeopleFromChannel(targetUser);
flexTab.confirmPopup();
browser.waitForVisible('#user-add-search', 50000);
browser.setValue('#user-add-search', targetUser);
browser.waitForExist('.-autocomplete-item', 50000);
browser.click('.-autocomplete-item');
done();
});
it('remove people from room', function(done) {
browser.waitForVisible('.user-card-room');
browser.click('.user-card-room');
browser.waitForVisible('.remove-user');
browser.click('.remove-user');
it('archive the room', function() {
flexTab.archiveChannel();
flexTab.closeTabs();
browser.waitForExist('.confirm');
browser.click('.confirm');
browser.pause(3000);
done();
});
it('archive the room', function(done) {
browser.waitForExist('.tab-button', 50000);
browser.waitForVisible('.tab-button', 50000);
browser.click('.tab-button:nth-of-type(2)');
it('open GENERAL', function() {
sideNav.openChannel('general');
browser.waitForVisible('.clearfix:last-child .icon-pencil', 50000);
browser.click('.clearfix:last-child .icon-pencil');
});
browser.waitForVisible('.editing', 50000);
browser.click('.editing');
//Private Channel
browser.waitForVisible('.save', 50000);
browser.click('.save');
it('create a private channel', function() {
sideNav.createChannel(privateChannelName, true, false);
done();
});
it('open GENERAL', function(done) {
browser.waitForExist('.wrapper > ul .link-room-GENERAL', 50000);
browser.click('.wrapper > ul .link-room-GENERAL');
browser.waitForExist('.input-message', 5000);
it('send a message in the private channel', function() {
mainContent.sendMessage(message);
done();
});
//Private Channel
it('add people to the room', function() {
flexTab.addPeopleToChannel(targetUser);
});
it('create a private channel', function(done) {
browser.click('.add-room:nth-of-type(1)');
browser.waitForVisible('#channel-name', 50000);
it('remove people from room', function() {
flexTab.closeTabs();
flexTab.removePeopleFromChannel(targetUser);
flexTab.confirmPopup();
browser.setValue(' #channel-name', privatechannelname);
});
browser.click('#channel-type');
it('archive the room', function() {
flexTab.archiveChannel();
flexTab.closeTabs();
browser.waitForVisible('.save-channel', 50000);
browser.click('.save-channel');
browser.waitForExist('.input-message', 5000);
done();
});
});
it('send a message in the private channel', function(done) {
const message = 'message from '+username;
browser.setValue('.input-message', message);
browser.waitForVisible('.message-buttons.send-button');
browser.click('.message-buttons.send-button');
/* get membersTab() { return browser.element('[title=Members]'); }
get userSearchBar() { return browser.element('.animated'); }
get userSearchBar() { return browser.element('#user-add-search'); }
get removeUserBtn() { return browser.element('.remove-user'); }
get startVideoCall() { return browser.element('start-video-call'); }
get startAudioCall() { return browser.element('start-audio-call'); }
get showAll() { return browser.element('.see-all'); }
browser.waitUntil(function() {
return browser.getText('.message:last-child .body') === message;
}, 2000);
done();
});
get channelTab() { return browser.element('[title="Room Info"]'); }
get channelSettings() { return browser.element('.channel-settings'); }
it('add people to the room', function(done) {
const targetUser = 'rocket.cat';
browser.waitForExist('.icon-users');
browser.click('.icon-users');
get searchTab() { return browser.element('[title="Search"]'); }
get searchTabContent() { return browser.element('.search-messages-list'); }
get messageSearchBar() { return browser.element('#message-search'); }
get searchResult() { return browser.element('.new-day'); }
browser.waitForVisible('#user-add-search', 50000);
browser.setValue('#user-add-search', targetUser);
browser.waitForExist('.-autocomplete-item', 50000);
browser.click('.-autocomplete-item');
done();
});
get notificationsTab() { return browser.element('[title="Notifications"]'); }
get notificationsSettings() { return browser.element('.push-notifications'); }
it('remove people from room', function(done) {
browser.waitForVisible('.user-card-room');
browser.click('.user-card-room');
get filesTab() { return browser.element('[title="Files List"]'); }
get fileItem() { return browser.element('.uploaded-files ul:first-child'); }
get filesTabContent() { return browser.element('.uploaded-files'); }
get fileDelete() { return browser.element('.uploaded-files ul:first-child .file-delete'); }
get fileDownload() { return browser.element('.uploaded-files ul:first-child .file-download'); }
get fileName() { return browser.element('.uploaded-files ul:first-child .room-file-item'); }
browser.waitForVisible('.remove-user');
browser.click('.remove-user');
get mentionsTab() { return browser.element('[title="Mentions"]'); }
get mentionsTabContent() { return browser.element('.mentioned-messages-list'); }
browser.waitForExist('.confirm');
browser.click('.confirm');
browser.pause(3000);
done();
});
get starredTab() { return browser.element('[title="Starred Messages"]'); }
get starredTabContent() { return browser.element('.starred-messages-list'); }
it('archive the room', function(done) {
browser.waitForExist('.tab-button', 50000);
browser.waitForVisible('.tab-button', 50000);
browser.click('.tab-button:nth-of-type(2)');
browser.waitForVisible('.clearfix:last-child .icon-pencil', 50000);
browser.click('.clearfix:last-child .icon-pencil');
get pinnedTab() { return browser.element('[title="Pinned Messages"]'); }
get pinnedTabContent() { return browser.element('pinned-messages-list'); }
browser.waitForVisible('.editing', 50000);
browser.click('.editing');
browser.waitForVisible('.save', 50000);
browser.click('.save');
done();
});
});
get archiveBtn() { return browser.element('.clearfix:last-child .icon-pencil'); }
get archiveRadio() { return browser.element('.editing'); }
get archiveSave() { return browser.element('.save'); }
get confirmBtn() { return browser.element('.confirm'); }
*/
Loading…
Cancel
Save