2019-11-29 22:16:18 +01:00
|
|
|
const { addStep } = require('@wdio/allure-reporter').default;
|
|
|
|
const { expect } = require('chai');
|
|
|
|
|
|
|
|
const common = require('../../base/common');
|
|
|
|
const navigate = require('../../base/navigation');
|
|
|
|
const Login = require('../../components/login');
|
2019-11-30 11:47:16 +01:00
|
|
|
const Subject = require('../../components/subject');
|
2019-11-29 22:16:18 +01:00
|
|
|
|
2019-11-29 22:51:45 +01:00
|
|
|
const testName = 'test';
|
2019-11-30 11:47:49 +01:00
|
|
|
const correctName = 'admin';
|
2019-11-30 11:47:16 +01:00
|
|
|
|
2019-11-29 22:51:45 +01:00
|
|
|
describe('Login page in BestNotes', () => {
|
2019-11-29 22:16:18 +01:00
|
|
|
it('should be displayed', () => {
|
|
|
|
const login = new Login();
|
2019-11-29 22:51:45 +01:00
|
|
|
|
|
|
|
addStep('Redirect to Login Page');
|
2019-11-29 22:16:18 +01:00
|
|
|
navigate.toLoginPage();
|
2019-11-29 22:51:45 +01:00
|
|
|
|
|
|
|
addStep('Check if Login Form is displayed and URL ');
|
|
|
|
expect(browser.getUrl(), 'Post details URL should include post ID').to.equal(common.bestNotesLink + 'accounts/login/');
|
2019-11-29 22:16:18 +01:00
|
|
|
expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true;
|
|
|
|
})
|
2019-11-29 22:51:45 +01:00
|
|
|
|
|
|
|
it('shouldnt logged user with incorrect 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, testName);
|
|
|
|
login.fillCredentials(login.passwordField, testName);
|
|
|
|
login.clickLoginButton();
|
|
|
|
|
|
|
|
addStep('Check if the error message is displayed');
|
|
|
|
expect(login.getErrorMessage(), 'Message about wrong credentials should be displayed').to.equal(common.errorLoginMessage);
|
|
|
|
})
|
2019-11-30 11:47:16 +01:00
|
|
|
|
|
|
|
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');
|
2019-11-30 11:47:49 +01:00
|
|
|
login.fillCredentials(login.emailField, correctName);
|
|
|
|
login.fillCredentials(login.passwordField, correctName);
|
2019-11-30 11:47:16 +01:00
|
|
|
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;
|
|
|
|
})
|
2019-11-29 22:16:18 +01:00
|
|
|
});
|