parent
5f100dc2b8
commit
4b1c771c4c
@ -0,0 +1,10 @@ |
||||
class Page { |
||||
get body() { return browser.element('body'); } |
||||
|
||||
open(path) { |
||||
browser.url('http://localhost:3000/' + path); |
||||
this.body.waitForExist(); |
||||
} |
||||
} |
||||
|
||||
module.exports = Page; |
@ -0,0 +1,54 @@ |
||||
import Page from './Page'; |
||||
|
||||
class LoginPage extends Page { |
||||
get registerButton() { return browser.element('button.register'); } |
||||
get forgotPasswordButton() { return browser.element('button.forgot-password'); } |
||||
get backToLoginButton() { return browser.element('button.back-to-login'); } |
||||
get submitButton() { return browser.element('.submit > button'); } |
||||
|
||||
get emailOrUsernameField() { return browser.element('[name=emailOrUsername]'); } |
||||
get nameField() { return browser.element('[name=name]'); } |
||||
get emailField() { return browser.element('[name=email]'); } |
||||
get passwordField() { return browser.element('[name=pass]'); } |
||||
get confirmPasswordField() { return browser.element('[name=confirm-pass]'); } |
||||
|
||||
get emailOrUsernameInvalidText() { return browser.element('[name=emailOrUsername]~.input-error'); } |
||||
get nameInvalidText() { return browser.element('[name=name]~.input-error'); } |
||||
get emailInvalidText() { return browser.element('[name=email]~.input-error'); } |
||||
get passwordInvalidText() { return browser.element('[name=pass]~.input-error'); } |
||||
get confirmPasswordInvalidText() { return browser.element('[name=confirm-pass]~.input-error'); } |
||||
|
||||
open() { |
||||
super.open(''); |
||||
} |
||||
|
||||
gotToRegister() { |
||||
this.registerButton.click(); |
||||
} |
||||
|
||||
gotToForgotPassword() { |
||||
this.forgotPasswordButton.click(); |
||||
} |
||||
|
||||
registerNewUser({username, email, password}) { |
||||
this.nameField.setValue(username); |
||||
this.emailField.setValue(email); |
||||
this.passwordField.setValue(password); |
||||
this.confirmPasswordField.setValue(password); |
||||
|
||||
this.submit(); |
||||
} |
||||
|
||||
login({email, password}) { |
||||
this.emailOrUsernameField.setValue(email); |
||||
this.passwordField.setValue(password); |
||||
|
||||
this.submit(); |
||||
} |
||||
|
||||
submit() { |
||||
this.submitButton.click(); |
||||
} |
||||
} |
||||
|
||||
module.exports = new LoginPage(); |
@ -0,0 +1,63 @@ |
||||
/* eslint-env mocha */ |
||||
|
||||
import loginPage from '../pageobjects/login.page'; |
||||
|
||||
describe('login', () => { |
||||
it('load page', () => { |
||||
loginPage.open(); |
||||
}); |
||||
|
||||
describe('render', () => { |
||||
it('should show email / username field', () => { |
||||
loginPage.emailOrUsernameField.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should show password field', () => { |
||||
loginPage.passwordField.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should show submit button', () => { |
||||
loginPage.submitButton.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should show register button', () => { |
||||
loginPage.registerButton.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should show forgot password button', () => { |
||||
loginPage.forgotPasswordButton.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should not show name field', () => { |
||||
loginPage.nameField.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should not show email field', () => { |
||||
loginPage.emailField.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should not show confirm password field', () => { |
||||
loginPage.confirmPasswordField.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should not show back to login button', () => { |
||||
loginPage.backToLoginButton.isVisible().should.be.false; |
||||
}); |
||||
}); |
||||
|
||||
describe('email / username', () => { |
||||
it('it should be required', () => { |
||||
loginPage.submit(); |
||||
loginPage.emailOrUsernameField.getAttribute('class').should.contain('error'); |
||||
loginPage.emailOrUsernameInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
}); |
||||
|
||||
describe('password', () => { |
||||
it('it should be required', () => { |
||||
loginPage.submit(); |
||||
loginPage.passwordField.getAttribute('class').should.contain('error'); |
||||
loginPage.passwordInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
}); |
||||
}); |
@ -0,0 +1,109 @@ |
||||
/* eslint-env mocha */ |
||||
|
||||
import loginPage from '../pageobjects/login.page'; |
||||
|
||||
describe('register', () => { |
||||
it('load page', () => { |
||||
loginPage.open(); |
||||
loginPage.gotToRegister(); |
||||
}); |
||||
|
||||
describe('render', () => { |
||||
it('should show name field', () => { |
||||
loginPage.nameField.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should show email field', () => { |
||||
loginPage.emailField.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should show password field', () => { |
||||
loginPage.passwordField.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should show confirm password field', () => { |
||||
loginPage.confirmPasswordField.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should not show email / username field', () => { |
||||
loginPage.emailOrUsernameField.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should show submit button', () => { |
||||
loginPage.submitButton.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should not show register button', () => { |
||||
loginPage.registerButton.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should not show forgot password button', () => { |
||||
loginPage.forgotPasswordButton.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should show back to login button', () => { |
||||
loginPage.backToLoginButton.isVisible().should.be.true; |
||||
}); |
||||
}); |
||||
|
||||
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', () => { |
||||
it('it should be required', () => { |
||||
loginPage.submit(); |
||||
loginPage.emailField.getAttribute('class').should.contain('error'); |
||||
loginPage.emailInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
|
||||
it('it should be invalid for email without domain', () => { |
||||
loginPage.emailField.setValue('invalid-email'); |
||||
loginPage.submit(); |
||||
loginPage.emailField.getAttribute('class').should.contain('error'); |
||||
loginPage.emailInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
|
||||
it('it should be invalid for email with invalid domain', () => { |
||||
loginPage.emailField.setValue('invalid-email@mail'); |
||||
loginPage.submit(); |
||||
loginPage.emailField.getAttribute('class').should.contain('error'); |
||||
loginPage.emailInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
|
||||
it.skip('it should be invalid for email space', () => { |
||||
loginPage.emailField.setValue('invalid email@mail.com'); |
||||
loginPage.submit(); |
||||
loginPage.emailField.getAttribute('class').should.contain('error'); |
||||
loginPage.emailInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
}); |
||||
|
||||
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', () => { |
||||
it('it should be invalid if different from password', () => { |
||||
loginPage.passwordField.setValue('password'); |
||||
loginPage.submit(); |
||||
loginPage.confirmPasswordField.getAttribute('class').should.contain('error'); |
||||
loginPage.confirmPasswordInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
|
||||
it('it should be valid if equal to password', () => { |
||||
loginPage.confirmPasswordField.setValue('password'); |
||||
loginPage.submit(); |
||||
loginPage.passwordField.getAttribute('class').should.not.contain('error'); |
||||
loginPage.passwordInvalidText.getText().should.be.empty; |
||||
}); |
||||
}); |
||||
}); |
@ -0,0 +1,77 @@ |
||||
/* eslint-env mocha */ |
||||
|
||||
import loginPage from '../pageobjects/login.page'; |
||||
|
||||
describe('register', () => { |
||||
it('load page', () => { |
||||
loginPage.open(); |
||||
loginPage.gotToForgotPassword(); |
||||
}); |
||||
|
||||
describe('render', () => { |
||||
it('should not show name field', () => { |
||||
loginPage.nameField.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should show email field', () => { |
||||
loginPage.emailField.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should not show password field', () => { |
||||
loginPage.passwordField.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should not show confirm password field', () => { |
||||
loginPage.confirmPasswordField.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should not show email / username field', () => { |
||||
loginPage.emailOrUsernameField.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should show submit button', () => { |
||||
loginPage.submitButton.isVisible().should.be.true; |
||||
}); |
||||
|
||||
it('should not show register button', () => { |
||||
loginPage.registerButton.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should not show forgot password button', () => { |
||||
loginPage.forgotPasswordButton.isVisible().should.be.false; |
||||
}); |
||||
|
||||
it('should show back to login button', () => { |
||||
loginPage.backToLoginButton.isVisible().should.be.true; |
||||
}); |
||||
}); |
||||
|
||||
describe('email', () => { |
||||
it('it should be required', () => { |
||||
loginPage.submit(); |
||||
loginPage.emailField.getAttribute('class').should.contain('error'); |
||||
loginPage.emailInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
|
||||
it('it should be invalid for email without domain', () => { |
||||
loginPage.emailField.setValue('invalid-email'); |
||||
loginPage.submit(); |
||||
loginPage.emailField.getAttribute('class').should.contain('error'); |
||||
loginPage.emailInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
|
||||
it('it should be invalid for email with invalid domain', () => { |
||||
loginPage.emailField.setValue('invalid-email@mail'); |
||||
loginPage.submit(); |
||||
loginPage.emailField.getAttribute('class').should.contain('error'); |
||||
loginPage.emailInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
|
||||
it.skip('it should be invalid for email space', () => { |
||||
loginPage.emailField.setValue('invalid email@mail.com'); |
||||
loginPage.submit(); |
||||
loginPage.emailField.getAttribute('class').should.contain('error'); |
||||
loginPage.emailInvalidText.getText().should.not.be.empty; |
||||
}); |
||||
}); |
||||
}); |
@ -0,0 +1,271 @@ |
||||
/* eslint-env mocha */ |
||||
/* eslint-disable func-names, prefer-arrow-callback */ |
||||
|
||||
import loginPage from '../pageobjects/login.page'; |
||||
|
||||
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(); |
||||
|
||||
describe('Basic usage', function() { |
||||
it('load page', () => { |
||||
loginPage.open(); |
||||
// browser.windowHandleSize({width:1280, height:800});
|
||||
}); |
||||
|
||||
it('crate user', function(done) { |
||||
loginPage.gotToRegister(); |
||||
|
||||
loginPage.registerNewUser({username, email, password}); |
||||
|
||||
browser.waitForExist('form#login-card input#username', 5000); |
||||
|
||||
browser.click('.submit > button'); |
||||
|
||||
browser.waitForExist('.main-content', 5000); |
||||
|
||||
done(); |
||||
}); |
||||
|
||||
it('logout', function(done) { |
||||
browser.waitForVisible('.account-box'); |
||||
browser.click('.account-box'); |
||||
browser.pause(200); |
||||
|
||||
browser.waitForVisible('#logout'); |
||||
browser.click('#logout'); |
||||
|
||||
done(); |
||||
}); |
||||
|
||||
it('login', function(done) { |
||||
loginPage.login({email, password}); |
||||
browser.waitForExist('.main-content', 5000); |
||||
|
||||
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); |
||||
|
||||
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'); |
||||
|
||||
browser.waitUntil(function() { |
||||
return browser.getText('.message:last-child .body') === message; |
||||
}, 2000); |
||||
|
||||
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'); |
||||
|
||||
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); |
||||
|
||||
done(); |
||||
}); |
||||
|
||||
it('send a direct 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'); |
||||
|
||||
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); |
||||
|
||||
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); |
||||
|
||||
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(); |
||||
}); |
||||
|
||||
it('add people to the room', function(done) { |
||||
const targetUser = 'rocket.cat'; |
||||
browser.waitForExist('.icon-users'); |
||||
browser.click('.icon-users'); |
||||
|
||||
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'); |
||||
|
||||
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)'); |
||||
|
||||
browser.waitForVisible('.clearfix:last-child .icon-pencil', 50000); |
||||
browser.click('.clearfix:last-child .icon-pencil'); |
||||
|
||||
browser.waitForVisible('.editing', 50000); |
||||
browser.click('.editing'); |
||||
|
||||
browser.waitForVisible('.save', 50000); |
||||
browser.click('.save'); |
||||
|
||||
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); |
||||
|
||||
done(); |
||||
}); |
||||
|
||||
//Private Channel
|
||||
|
||||
it('create a private channel', function(done) { |
||||
browser.click('.add-room:nth-of-type(1)'); |
||||
browser.waitForVisible('#channel-name', 50000); |
||||
|
||||
browser.setValue(' #channel-name', privatechannelname); |
||||
|
||||
browser.click('#channel-type'); |
||||
|
||||
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'); |
||||
|
||||
browser.waitUntil(function() { |
||||
return browser.getText('.message:last-child .body') === message; |
||||
}, 2000); |
||||
|
||||
done(); |
||||
}); |
||||
|
||||
it('add people to the room', function(done) { |
||||
const targetUser = 'rocket.cat'; |
||||
browser.waitForExist('.icon-users'); |
||||
browser.click('.icon-users'); |
||||
|
||||
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'); |
||||
|
||||
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)'); |
||||
|
||||
browser.waitForVisible('.clearfix:last-child .icon-pencil', 50000); |
||||
browser.click('.clearfix:last-child .icon-pencil'); |
||||
|
||||
browser.waitForVisible('.editing', 50000); |
||||
browser.click('.editing'); |
||||
|
||||
browser.waitForVisible('.save', 50000); |
||||
browser.click('.save'); |
||||
|
||||
done(); |
||||
}); |
||||
}); |
@ -1,87 +0,0 @@ |
||||
/* eslint-env mocha */ |
||||
/* eslint-disable func-names, prefer-arrow-callback */ |
||||
|
||||
// These are Chimp globals
|
||||
/* globals browser */ |
||||
|
||||
const username = 'user-test-'+Date.now(); |
||||
|
||||
describe('Basic usage', function() { |
||||
before(function() { |
||||
browser.url('http://localhost:3000'); |
||||
}); |
||||
|
||||
it('load page', function(done) { |
||||
browser.waitForExist('body'); |
||||
done(); |
||||
}); |
||||
|
||||
it('crate user', function(done) { |
||||
browser.waitForExist('.register'); |
||||
browser.click('.register'); |
||||
|
||||
browser.waitForExist('[name=name]'); |
||||
|
||||
browser.setValue('[name=name]', username); |
||||
browser.setValue('[name=email]', username+'@rocket.chat'); |
||||
browser.setValue('[name=pass]', 'rocket.chat'); |
||||
browser.setValue('[name=confirm-pass]', 'rocket.chat'); |
||||
|
||||
browser.click('.submit > button'); |
||||
|
||||
browser.waitForExist('form#login-card input#username', 5000); |
||||
|
||||
browser.click('.submit > button'); |
||||
|
||||
browser.waitForExist('.main-content', 5000); |
||||
|
||||
done(); |
||||
}); |
||||
|
||||
it('logout', function(done) { |
||||
browser.waitForVisible('.account-box'); |
||||
browser.click('.account-box'); |
||||
browser.pause(200); |
||||
|
||||
browser.waitForVisible('#logout'); |
||||
browser.click('#logout'); |
||||
|
||||
done(); |
||||
}); |
||||
|
||||
it('login', function(done) { |
||||
browser.waitForExist('[name=emailOrUsername]'); |
||||
|
||||
browser.setValue('[name=emailOrUsername]', username+'@rocket.chat'); |
||||
browser.setValue('[name=pass]', 'rocket.chat'); |
||||
|
||||
browser.click('.submit > button'); |
||||
|
||||
browser.waitForExist('.main-content', 5000); |
||||
|
||||
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); |
||||
|
||||
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'); |
||||
|
||||
browser.waitUntil(function() { |
||||
return browser.getText('.message:last-child .body') === message; |
||||
}, 2000); |
||||
|
||||
done(); |
||||
}); |
||||
}); |
Loading…
Reference in new issue