Skip to content

Commit

Permalink
Merge pull request RocketChat#7049 from RocketChat/tests-improvements-2
Browse files Browse the repository at this point in the history
[FIX] Improve Tests
  • Loading branch information
karlprieb authored May 23, 2017
2 parents 362ac8e + c0d248b commit 1a04c3f
Show file tree
Hide file tree
Showing 23 changed files with 716 additions and 705 deletions.
30 changes: 14 additions & 16 deletions tests/end-to-end/api/01-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {getCredentials, api, login, request, credentials, apiEmail, apiUsername,
import {adminEmail, password} from '../../data/user.js';
import {imgURL} from '../../data/interactions.js';

describe('Users', function() {
describe('[Users]', function() {
this.retries(0);

before(done => getCredentials(done));

it('/users.create', (done) => {
it('/users.create:', (done) => {
request.post(api('users.create'))
.set(credentials)
.send({
Expand All @@ -37,7 +37,7 @@ describe('Users', function() {
.end(done);
});

it('/users.info', (done) => {
it('/users.info:', (done) => {
request.get(api('users.info'))
.set(credentials)
.query({
Expand All @@ -55,7 +55,7 @@ describe('Users', function() {
.end(done);
});

it('/users.getPresence', (done) => {
it('/users.getPresence:', (done) => {
request.get(api('users.getPresence'))
.set(credentials)
.query({
Expand All @@ -70,7 +70,7 @@ describe('Users', function() {
.end(done);
});

it('/users.list', (done) => {
it('/users.list:', (done) => {
request.get(api('users.list'))
.set(credentials)
.expect('Content-Type', 'application/json')
Expand All @@ -83,7 +83,7 @@ describe('Users', function() {
.end(done);
});

it.skip('/users.list', (done) => {
it.skip('/users.list:', (done) => {
//filtering user list
request.get(api('users.list'))
.set(credentials)
Expand All @@ -103,9 +103,7 @@ describe('Users', function() {
.end(done);
});



it.skip('/users.setAvatar', (done) => {
it.skip('/users.setAvatar:', (done) => {
request.post(api('users.setAvatar'))
.set(credentials)
.attach('avatarUrl', imgURL)
Expand All @@ -117,7 +115,7 @@ describe('Users', function() {
.end(done);
});

it('/users.update', (done) => {
it('/users.update:', (done) => {
request.post(api('users.update'))
.set(credentials)
.send({
Expand All @@ -143,7 +141,7 @@ describe('Users', function() {
.end(done);
});

describe('/users.createToken', () => {
describe('[/users.createToken]', () => {
let user;
beforeEach((done) => {
const username = `user.test.${ Date.now() }`;
Expand Down Expand Up @@ -180,7 +178,7 @@ describe('Users', function() {
user = undefined;
});

describe('logged as admin', () => {
describe('logged as admin:', () => {
it('should return the user id and a new token', (done) => {
request.post(api('users.createToken'))
.set(credentials)
Expand All @@ -198,7 +196,7 @@ describe('Users', function() {
});
});

describe('logged as itself', () => {
describe('logged as itself:', () => {
it('should return the user id and a new token', (done) => {
request.post(api('users.createToken'))
.set(userCredentials)
Expand All @@ -216,7 +214,7 @@ describe('Users', function() {
});
});

describe('As an user not allowed', () => {
describe('As an user not allowed:', () => {
it('should return 401 unauthorized', (done) => {
request.post(api('users.createToken'))
.set(userCredentials)
Expand All @@ -233,7 +231,7 @@ describe('Users', function() {
});
});

describe('Not logged in', () => {
describe('Not logged in:', () => {
it('should return 401 unauthorized', (done) => {
request.post(api('users.createToken'))
.send({
Expand All @@ -248,7 +246,7 @@ describe('Users', function() {
});
});

describe('Testing if the returned token is valid', (done) => {
describe('Testing if the returned token is valid:', (done) => {
it('should return 200', (done) => {
return request.post(api('users.createToken'))
.set(credentials)
Expand Down
4 changes: 2 additions & 2 deletions tests/end-to-end/api/02-channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getRoomInfo(roomId) {
});
}

describe('channels', function() {
describe('[Channels]', function() {
this.retries(0);

before(done => getCredentials(done));
Expand Down Expand Up @@ -518,7 +518,7 @@ describe('channels', function() {
.end(done);
});

describe('/channels.delete', () => {
describe('/channels.delete:', () => {
let testChannel;
it('/channels.create', (done) => {
request.post(api('channels.create'))
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/api/04-direct-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {getCredentials, api, login, request, credentials, directMessage, log } f
import {adminEmail, password} from '../../data/user.js';
import supertest from 'supertest';

describe('direct messages', function() {
describe('[Direct Messages]', function() {
this.retries(0);

before(done => getCredentials(done));
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/api/05-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {getCredentials, api, login, request, credentials, message, log, apiPriva
import {adminEmail, password} from '../../data/user.js';
import supertest from 'supertest';

describe('chat', function() {
describe('[Chat]', function() {
this.retries(0);

before(done => getCredentials(done));
Expand Down
34 changes: 18 additions & 16 deletions tests/end-to-end/ui/00-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,65 @@

import loginPage from '../../pageobjects/login.page';

describe('login', () => {
describe('[Login]', () => {
before(()=>{
loginPage.open();
// This Can Cause Timeouts erros if the server is slow so it should have a big wait
loginPage.emailOrUsernameField.waitForVisible(15000);
});

describe('render', () => {
it('should show email / username field', () => {
describe('[Render]', () => {
it('it should show email / username field', () => {
loginPage.emailOrUsernameField.isVisible().should.be.true;
});

it('should show password field', () => {
it('it should show password field', () => {
loginPage.passwordField.isVisible().should.be.true;
});

it('should show submit button', () => {
it('it should show submit button', () => {
loginPage.submitButton.isVisible().should.be.true;
});

it('should show register button', () => {
it('it should show register button', () => {
loginPage.registerButton.isVisible().should.be.true;
});

it('should show forgot password button', () => {
it('it should show forgot password button', () => {
loginPage.forgotPasswordButton.isVisible().should.be.true;
});

it('should not show name field', () => {
it('it should not show name field', () => {
loginPage.nameField.isVisible().should.be.false;
});

it('should not show email field', () => {
it('it should not show email field', () => {
loginPage.emailField.isVisible().should.be.false;
});

it('should not show confirm password field', () => {
it('it should not show confirm password field', () => {
loginPage.confirmPasswordField.isVisible().should.be.false;
});

it('should not show back to login button', () => {
it('it should not show back to login button', () => {
loginPage.backToLoginButton.isVisible().should.be.false;
});
});

describe('required fields', () => {
describe('[Required Fields]', () => {
before(() => {
loginPage.submit();
});

describe('email / username', () => {
it('should be required', () => {
describe('email / username: ', () => {
it('it should be required', () => {
loginPage.emailOrUsernameField.getAttribute('class').should.contain('error');
loginPage.emailOrUsernameInvalidText.getText().should.not.be.empty;
});
});

describe('password', () => {
it('should be required', () => {
describe('password: ', () => {
it('it should be required', () => {
loginPage.passwordField.getAttribute('class').should.contain('error');
loginPage.passwordInvalidText.getText().should.not.be.empty;
});
Expand Down
30 changes: 15 additions & 15 deletions tests/end-to-end/ui/01-register.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,59 @@

import loginPage from '../../pageobjects/login.page';

describe('register', () => {
describe('[Register]', () => {
before(() => {
loginPage.open();
loginPage.gotToRegister();
});

describe('render', () => {
it('should show name field', () => {
describe('render:', () => {
it('it should show name field', () => {
loginPage.nameField.isVisible().should.be.true;
});

it('should show email field', () => {
it('it should show email field', () => {
loginPage.emailField.isVisible().should.be.true;
});

it('should show password field', () => {
it('it should show password field', () => {
loginPage.passwordField.isVisible().should.be.true;
});

it('should show confirm password field', () => {
it('it should show confirm password field', () => {
loginPage.confirmPasswordField.isVisible().should.be.true;
});

it('should not show email / username field', () => {
it('it should not show email / username field', () => {
loginPage.emailOrUsernameField.isVisible().should.be.false;
});

it('should show submit button', () => {
it('it should show submit button', () => {
loginPage.submitButton.isVisible().should.be.true;
});

it('should not show register button', () => {
it('it should not show register button', () => {
loginPage.registerButton.isVisible().should.be.false;
});

it('should not show forgot password button', () => {
it('it should not show forgot password button', () => {
loginPage.forgotPasswordButton.isVisible().should.be.false;
});

it('should show back to login button', () => {
it('it should show back to login button', () => {
loginPage.backToLoginButton.isVisible().should.be.true;
});
});

describe('name', () => {
describe('name:', () => {
it('it should be required', () => {
loginPage.submit();
loginPage.nameField.getAttribute('class').should.contain('error');
loginPage.nameInvalidText.getText().should.not.be.empty;
});
});

describe('email', () => {
describe('email:', () => {
it('it should be required', () => {
loginPage.submit();
loginPage.emailField.getAttribute('class').should.contain('error');
Expand Down Expand Up @@ -83,15 +83,15 @@ describe('register', () => {
});
});

describe('password', () => {
describe('password:', () => {
it('it should be required', () => {
loginPage.submit();
loginPage.passwordField.getAttribute('class').should.contain('error');
loginPage.passwordInvalidText.getText().should.not.be.empty;
});
});

describe('confirm-password', () => {
describe('confirm-password:', () => {
it('it should be invalid if different from password', () => {
loginPage.passwordField.setValue('password');
loginPage.submit();
Expand Down
24 changes: 12 additions & 12 deletions tests/end-to-end/ui/02-forgot-password.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,51 @@

import loginPage from '../../pageobjects/login.page';

describe('register', () => {
describe('[Forgot Password]', () => {
before(() => {
loginPage.open();
loginPage.gotToForgotPassword();
});

describe('render', () => {
it('should not show name field', () => {
describe('render:', () => {
it('it should not show name field', () => {
loginPage.nameField.isVisible().should.be.false;
});

it('should show email field', () => {
it('it should show email field', () => {
loginPage.emailField.isVisible().should.be.true;
});

it('should not show password field', () => {
it('it should not show password field', () => {
loginPage.passwordField.isVisible().should.be.false;
});

it('should not show confirm password field', () => {
it('it should not show confirm password field', () => {
loginPage.confirmPasswordField.isVisible().should.be.false;
});

it('should not show email / username field', () => {
it('it should not show email / username field', () => {
loginPage.emailOrUsernameField.isVisible().should.be.false;
});

it('should show submit button', () => {
it('it should show submit button', () => {
loginPage.submitButton.isVisible().should.be.true;
});

it('should not show register button', () => {
it('it should not show register button', () => {
loginPage.registerButton.isVisible().should.be.false;
});

it('should not show forgot password button', () => {
it('it should not show forgot password button', () => {
loginPage.forgotPasswordButton.isVisible().should.be.false;
});

it('should show back to login button', () => {
it('it should show back to login button', () => {
loginPage.backToLoginButton.isVisible().should.be.true;
});
});

describe('email', () => {
describe('email:', () => {
it('it should be required', () => {
loginPage.submit();
loginPage.emailField.getAttribute('class').should.contain('error');
Expand Down
Loading

0 comments on commit 1a04c3f

Please sign in to comment.