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