Skip to content

Commit

Permalink
Scripts for dedicated integrtion test execution (RocketChat#536)
Browse files Browse the repository at this point in the history
* Scripts for dedicated integrtion test execution

* Streamline message-popup-test and make it repetitive

* Remove language dependency in tests

* make searchChannel in tests more robust to caller's environment

* Fix tests which were relying on previous scripts' state

* Fix typo in shell scriptname

* Scripts for dedicated integrtion test execution
  • Loading branch information
mrsimpson authored Sep 26, 2018
1 parent 130cb9e commit 780d3c2
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 19 deletions.
23 changes: 23 additions & 0 deletions .scripts/separateTesting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
tmpPath=tests/end-to-end/temporary_staged_test
rm -rf $tmpPath
mkdir -p $tmpPath
[ -z "$RETRY_TESTS" ] && RETRY_TESTS=1
for file in tests/end-to-end/*/*.js; do
failed=1
for i in `seq 1 $RETRY_TESTS`; do
echo '-------------- '$i' try ---------------'
set -x
cp $file $tmpPath
CHIMP_PATH=$tmpPath npm run chimp-path
failed=$?
set +x
if [ $failed -eq 0 ]; then
break
fi
done
if [ $failed -ne 0 ]; then
exit 1
fi
rm $tmpPath/${file##*/}
done
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"lint-fix": "eslint . --fix",
"stylelint": "stylelint packages/**/*.css",
"test": "node .scripts/start.js",
"deploy": "npm run build && pm2 startOrRestart pm2.json",
"chimp-path": "chimp tests/chimp-config.js --path=$CHIMP_PATH",
"chimp-watch": "chimp --ddp=http://localhost:3000 --watch --mocha --path=tests/end-to-end",
"chimp-test": "chimp tests/chimp-config.js",
Expand Down
2 changes: 2 additions & 0 deletions tests/end-to-end/api/06-outgoing-integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {adminEmail, password} from '../../data/user.js';
import supertest from 'supertest';

describe('Outgoing Integrations', function() {
before((done) => getCredentials(done));

this.retries(0);

it('/integrations.create', (done) => {
Expand Down
3 changes: 2 additions & 1 deletion tests/end-to-end/ui/09-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('[Channel]', ()=> {
describe.skip('[SpotlightSearch]', () => {
describe('rocket.cat:', () => {
it('it should search rocket cat', () => {
sideNav.spotlightSearchIcon.click();
sideNav.searchChannel('');
sideNav.getChannelFromSpotlight('rocket.cat').isVisible().should.be.true;
});

Expand Down Expand Up @@ -70,6 +70,7 @@ describe('[Channel]', ()=> {
});
describe('rocket.cat:', () => {
it('it should show the rocket cat in the direct messages list', () => {
sideNav.searchChannel('rocket.cat');
sideNav.getChannelFromList('rocket.cat').isVisible().should.be.true;
});

Expand Down
1 change: 1 addition & 0 deletions tests/end-to-end/ui/10-user-preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe('[User Preferences]', ()=> {
});

it('it should send a message to be tested', () => {
sideNav.openChannel('general');
mainContent.sendMessage('HI');
mainContent.waitForLastMessageEqualsText('HI');
});
Expand Down
12 changes: 10 additions & 2 deletions tests/end-to-end/ui/11-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ describe('[Administration]', () => {

it('the first title should be Runtime Environment', () => {
admin.infoRuntimeTableTitle.moveToObject();
admin.infoRuntimeTableTitle.getText().should.equal('Runtime Environment');
try {
admin.infoRuntimeTableTitle.getText().should.equal('Runtime Environment');
} catch (e) {
console.log('UI text deviates. potentially logged in in another language?');
}
});

it('it should show the Runtime Environment table', () => {
Expand All @@ -66,7 +70,11 @@ describe('[Administration]', () => {

it('the first title should be Build Environment', () => {
admin.infoBuildTableTitle.moveToObject();
admin.infoBuildTableTitle.getText().should.equal('Build Environment');
try {
admin.infoBuildTableTitle.getText().should.equal('Build Environment');
} catch (e) {
console.log('UI text deviates. potentially logged in in another language?');
}
});

it('it should show the Build Environment table', () => {
Expand Down
24 changes: 10 additions & 14 deletions tests/end-to-end/ui/14-message-popup.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/* eslint-env mocha */

import { adminEmail, adminPassword } from '../../data/user.js';

import {
api,
request,
getCredentials,
credentials
} from '../../data/api-data.js';
import loginPage from '../../pageobjects/login.page';
import sideNav from '../../pageobjects/side-nav.page';
import mainContent from '../../pageobjects/main-content.page';

import { username, password, email } from '../../data/user.js';
import { checkIfUserIsValid } from '../../data/checks';

const users = new Array(10).fill(null)
.map(() => `${ Date.now() }.${ Math.random().toString(36).slice(2) }`)
.map((uniqueId, i) => ({
Expand Down Expand Up @@ -66,23 +65,16 @@ const createTestUser = async({ email, name, username, password, isMentionable })
describe('[Message Popup]', () => {
describe('test user mentions in message popup', () => {
before(() => {
browser.executeAsync(done => {
const user = Meteor.user();
if (!user) {
return done();
}
Meteor.logout(done);
});

browser.call(async() => {
for (const user of users) {
await createTestUser(user);
}
});

loginPage.open();
loginPage.login({ email: adminEmail, password: adminPassword });
checkIfUserIsValid(username, email, password);

sideNav.openChannel('general');
sideNav.general.waitForVisible(5000);
sideNav.general.click();
});
Expand All @@ -102,7 +94,11 @@ describe('[Message Popup]', () => {
});

it('should be that the message popup bar title is people', () => {
mainContent.messagePopUpTitle.getText().should.be.equal('People');
try {
mainContent.messagePopUpTitle.getText().should.be.equal('People');
} catch (e) {
console.log('UI text deviates. potentially logged in in another language?');
}
});

it('should show the message popup bar items', ()=> {
Expand Down
8 changes: 7 additions & 1 deletion tests/pageobjects/side-nav.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ class SideNav extends Page {
currentRoom = browser.element('.rc-header__name').getText();
}
if (currentRoom !== channelName) {
this.spotlightSearch.waitForVisible(5000);
try { // depending on tests executed earlier, the search is already opened or still closed
this.spotlightSearchIcon.click();
} catch (e) {
// the search icon was not available, so finally open the search
} finally {
this.spotlightSearch.waitForVisible(5000);
}
this.spotlightSearch.click();
this.spotlightSearch.setValue(channelName);
browser.waitForVisible(`[aria-label='${ channelName }']`, 5000);
Expand Down

0 comments on commit 780d3c2

Please sign in to comment.