Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Improve Tests #7049

Merged
merged 5 commits into from May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 14 additions & 16 deletions tests/end-to-end/api/01-users.js
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
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
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
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
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
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
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