From 4a63d7df46050a793da300aff0761b789ecab573 Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Sat, 30 Nov 2019 11:47:16 +0100 Subject: [PATCH] BES-26 | adding new test --- test/config/base.conf.js | 1 + test/specs/components/subject.js | 14 +++++++++++ test/specs/suites/desktop/loginpage.test.js | 23 ++++++++++++++++++- test/specs/suites/desktop/subjectpage.test.js | 0 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/specs/components/subject.js create mode 100644 test/specs/suites/desktop/subjectpage.test.js diff --git a/test/config/base.conf.js b/test/config/base.conf.js index 2becf10..8421d4d 100644 --- a/test/config/base.conf.js +++ b/test/config/base.conf.js @@ -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' diff --git a/test/specs/components/subject.js b/test/specs/components/subject.js new file mode 100644 index 0000000..dd47c4b --- /dev/null +++ b/test/specs/components/subject.js @@ -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; \ No newline at end of file diff --git a/test/specs/suites/desktop/loginpage.test.js b/test/specs/suites/desktop/loginpage.test.js index 4c6c673..19cbee9 100644 --- a/test/specs/suites/desktop/loginpage.test.js +++ b/test/specs/suites/desktop/loginpage.test.js @@ -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; +}) }); \ No newline at end of file diff --git a/test/specs/suites/desktop/subjectpage.test.js b/test/specs/suites/desktop/subjectpage.test.js new file mode 100644 index 0000000..e69de29