Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Mar 8, 2019
1 parent 30900b7 commit 82141fa
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Meteor.startup(function() {
});
},
condition({ rid, u: { _id: uid }, attachments }) {
if (attachments && attachments[0].fields && attachments[0].fields[0].type === 'messageCounter') {
if (attachments && attachments[0] && attachments[0].fields && attachments[0].fields[0].type === 'messageCounter') {
return false;
}
return condition(rid, uid);
Expand Down
10 changes: 9 additions & 1 deletion packages/rocketchat-lib/lib/roomTypes/direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ export class DirectMessageRoomType extends RoomTypeConfig {
}
}

roomName(subscription) {
roomName(roomData) {

// this function can receive different types of data
// if it doesn't have fname and name properties, should be a Room object
// so, need to find the related subscription
const subscription = !roomData.fname && !roomData.fname ?
Subscriptions.findOne({ rid: roomData._id }) :
roomData;

if (settings.get('UI_Use_Real_Name') && subscription.fname) {
return subscription.fname;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/rocketchat-lib/server/functions/createRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,8 @@ export const createRoom = function(type, name, owner, members, readOnly, extraDa
Apps.getBridges().getListenerBridge().roomEvent('IPostRoomCreate', room);
}

return room;
return {
rid: room._id, // backwards compatible
...room,
};
};
5 changes: 3 additions & 2 deletions tests/end-to-end/ui/15-threading.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { threading } from '../../pageobjects/threading.page';
import { username, email, password } from '../../data/user.js';
import { checkIfUserIsValid } from '../../data/checks';
const parentChannelName = 'unit-testing';
const threadName = 'Lorem ipsum dolor sit amet';
const message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';

describe('[Threading]', function () {
Expand All @@ -30,13 +31,13 @@ describe('[Threading]', function () {

describe('via creation screen', function() {
it('Create a thread', function () {
threading.createThread(parentChannelName, message);
threading.createThread(parentChannelName, threadName, message);
});
});

describe('from context menu', function() {
before(() => {
sideNav.openChannel(parentChannelName);
// sideNav.openChannel(parentChannelName);
mainContent.sendMessage(message);
});

Expand Down
14 changes: 11 additions & 3 deletions tests/pageobjects/side-nav.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SideNav extends Page {
get channelType() { return browser.element('.create-channel__content .rc-switch__button'); }
get channelReadOnly() { return browser.elements('.create-channel__switches .rc-switch__button').value[1]; }
get channelName() { return browser.element('.create-channel__content input[name="name"]'); }
get saveChannelBtn() { return browser.element('.create-channel__content [data-button="create"]'); }
get saveChannelBtn() { return browser.element('.rc-modal__content [data-button="create"]'); }

// Account box
getPopOverContent() { return browser.element('.rc-popover__content'); }
Expand All @@ -29,7 +29,11 @@ class SideNav extends Page {
get spotlightSearchIcon() { return browser.element('.sidebar__toolbar-button-icon--magnifier'); }
get spotlightSearch() { return browser.element('.toolbar__search input'); }
get spotlightSearchPopUp() { return browser.element('.rooms-list__toolbar-search'); }
get newChannelBtn() { return browser.element('.sidebar__toolbar-button-icon--edit-rounded'); }
get newChannelBtnToolbar() { return browser.element('.sidebar__toolbar-button-icon--edit-rounded'); }

get newChannelBtn() { return browser.element('.rc-popover__item-text=Channel'); }
get newThreadBtn() { return browser.element('.rc-popover__item-text=Thread'); }

get newChannelIcon() { return browser.element('.toolbar__icon.toolbar__search-create-channel'); }

// Rooms List
Expand Down Expand Up @@ -106,15 +110,19 @@ class SideNav extends Page {
}

createChannel(channelName, isPrivate, /* isReadOnly*/) {
this.newChannelBtnToolbar.waitForVisible(10000);
this.newChannelBtnToolbar.click();

this.newChannelBtn.waitForVisible(10000);
this.newChannelBtn.click();

this.channelName.waitForVisible(10000);

// workaround for incomplete setvalue bug
this.channelName.setValue(channelName);

browser.waitUntil(function() {
return browser.isEnabled('.create-channel__content [data-button="create"]');
return browser.isEnabled('.rc-modal__content [data-button="create"]');
}, 5000);

this.channelType.waitForVisible(10000);
Expand Down
45 changes: 25 additions & 20 deletions tests/pageobjects/threading.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Page from './Page';
import sideNav from './side-nav.page';
import flexTab from './flex-tab.page';
import global from './global';
import { sendEscape } from './keyboard';

class Threading extends Page {
// Sidebar - this should actually be part of the sidebar-file - leaving it here for mergability
Expand All @@ -27,40 +26,46 @@ class Threading extends Page {

// Modal
get createThreadModal() {
return browser.element('.create-thread');
return browser.element('#create-thread');
}

get selectChannelAction() {
return browser.element('.create-thread .js-select-parent');
get threadName() {
return browser.element('#create-thread #thread_name');
}

get firstQuestion() {
return browser.element('.create-thread #thread_message');
get threadMessage() {
return browser.element('#create-thread #thread_message');
}

// get parentChannelName() {
// return browser.element('.create-thread #parentChannel-search');
// }
get parentChannelName() {
return browser.element('#create-thread #parentChannel');
}

get saveThreadButton() {
return browser.element('.create-channel .js-save-thread');
return browser.element('.js-save-thread');
}

// Sequences

createThread(parentChannelName, message) {
this.newThreadButton.waitForVisible(1000);
this.newThreadButton.click();
createThread(parentChannelName, name, message) {
sideNav.newChannelBtnToolbar.waitForVisible(1000);
sideNav.newChannelBtnToolbar.click();
sideNav.newThreadBtn.waitForVisible(1000);
sideNav.newThreadBtn.click();
this.createThreadModal.waitForVisible(1000);
this.firstQuestion.setValue(message);
this.selectChannelAction.click();
// this.parentChannelName.waitForVisible(1000);
// this.parentChannelName.setValue(parentChannelName);
sendEscape();
browser.pause(4000); // wait for the autocompete to vanish - for sure
this.threadName.setValue(name);
this.threadMessage.setValue(message);
this.parentChannelName.waitForVisible(1000);
this.parentChannelName.setValue(parentChannelName);

const list = browser.element('.rc-popup-list__list');
list.waitForVisible(2000);

list.element('.rc-popup-list__item').waitForVisible(10000);
list.element('.rc-popup-list__item').click();

browser.waitUntil(function() {
return browser.isEnabled('.create-channel .js-save-thread');
return browser.isEnabled('.js-save-thread');
}, 5000);

this.saveThreadButton.click();
Expand Down

0 comments on commit 82141fa

Please sign in to comment.