BES-26 | adding new test

This commit is contained in:
Dawid Majsnerowski 2019-11-30 11:47:16 +01:00
parent e43b6d9709
commit 4a63d7df46
4 changed files with 37 additions and 1 deletions

View File

@ -3,6 +3,7 @@ exports.config = {
path: '/',
suites: {
login: ['./test/specs/suites/desktop/loginpage.test.js'],
subject: ['./test/specs/suites/desktop/subjectpage.test.js'],
},
specs: [
'./test/specs/**/*.js'

View File

@ -0,0 +1,14 @@
const path = require('path');
const base = require('../base/base');
class Subject {
constructor() {
this.subjectNavbar = '.navbar';
}
isNavbarDisplayed() {
base.waitForDisplayed(this.subjectNavbar);
return base.isDisplayed(this.subjectNavbar);
}
}
module.exports = Subject;

View File

@ -4,9 +4,11 @@ const { expect } = require('chai');
const common = require('../../base/common');
const navigate = require('../../base/navigation');
const Login = require('../../components/login');
const Subject = require('../../components/subject');
const testName = 'test';
const corrrectName = 'admin';
describe('Login page in BestNotes', () => {
it('should be displayed', () => {
const login = new Login();
@ -36,4 +38,23 @@ describe('Login page in BestNotes', () => {
addStep('Check if the error message is displayed');
expect(login.getErrorMessage(), 'Message about wrong credentials should be displayed').to.equal(common.errorLoginMessage);
})
it('should logged user with correct credentials', () => {
const login = new Login();
addStep('Redirect to Login Page');
navigate.toLoginPage();
addStep('Check if Login Form is displayed');
expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true;
addStep('Fill credentials and try to login');
login.fillCredentials(login.emailField, corrrectName);
login.fillCredentials(login.passwordField, corrrectName);
login.clickLoginButton();
addStep('Check if the page is displayed and URL matches');
expect(browser.getUrl(), 'Post details URL should include post ID').to.equal(common.bestNotesLink + 'subject/');
expect(new Subject().isNavbarDisplayed(), 'Subject page should be displayed').to.be.true;
})
});