BestNotes/test/specs/suites/desktop/loginpage.test.js

57 lines
2.2 KiB
JavaScript
Raw Normal View History

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-12-08 22:46:26 +01:00
const Note = require('../../components/note');
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 ');
2019-12-08 22:46:26 +01:00
expect(browser.getUrl(), 'Login page URL is the same as expected').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');
2019-12-08 22:46:26 +01:00
login.fillCredentials(login.emailField, common.testName);
login.fillCredentials(login.passwordField, common.testName);
2019-11-29 22:51:45 +01:00
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-12-08 22:46:26 +01:00
login.fillCredentials(login.emailField, common.correctName);
login.fillCredentials(login.passwordField, common.correctName);
2019-11-30 11:47:16 +01:00
login.clickLoginButton();
addStep('Check if the page is displayed and URL matches');
2019-12-08 22:46:26 +01:00
expect(browser.getUrl(), 'Subject page URL is the same as expected').to.equal(common.bestNotesLink + 'subject/');
expect(new Note().isNavbarDisplayed(), 'Subject page should be displayed').to.be.true;
2019-11-30 11:47:16 +01:00
})
2019-11-29 22:16:18 +01:00
});