update user authentication feature test

This commit is contained in:
mahula 2022-09-15 09:55:44 +02:00
parent 9890898191
commit 7e20531f39
6 changed files with 25 additions and 36 deletions

View File

@ -4,6 +4,7 @@ Feature: User authentication
In order to be able to posts and do other contributions as myself In order to be able to posts and do other contributions as myself
Furthermore I want to be able to stay logged in and logout again Furthermore I want to be able to stay logged in and logout again
# TODO for these pre-conditions utilize seeding or API check, if user exists in test system
# Background: # Background:
# Given the following "users" are in the database: # Given the following "users" are in the database:
# | email | password | name | # | email | password | name |
@ -14,4 +15,3 @@ Feature: User authentication
When the user submits the credentials "bibi@bloxberg.de" "Aa12345_" When the user submits the credentials "bibi@bloxberg.de" "Aa12345_"
Then the user is logged in with username "Bibi Bloxberg" Then the user is logged in with username "Bibi Bloxberg"

View File

@ -1,21 +0,0 @@
import users from '../fixtures/users'
import LoginPage from './models/LoginPage'
describe('Gradido', () => {
let userData;
before(() => {
cy.fixture('users').then((usersFixture) => {
userData = usersFixture;
});
});
it('login test (happy path)', () => {
const loginPage = new LoginPage();
loginPage.goto();
loginPage.enterEmail(userData.user.email);
loginPage.enterPassword(userData.user.password);
loginPage.submitLogin();
cy.url().should('be.equal', `${Cypress.config('baseUrl')}/overview`);
});
});

View File

@ -2,11 +2,11 @@
export class LoginPage { export class LoginPage {
// selectors // selectors
emailInputSelector = '[id=Email-input-field]'; emailInput = '#Email-input-field';
passwordInputSelector = '[id=Passwort-input-field]'; passwordInput = '#Passwort-input-field';
submitBtnSelector = '[type=submit]'; submitBtn = '[type=submit]';
emailHintSelector = '[id=vee_Email]'; emailHint = '#vee_Email';
passwordHintSelector = '[id=vee_Passwort]'; passwordHint = '#vee_Passwort';
goto() { goto() {
cy.visit('/'); cy.visit('/');
@ -14,17 +14,17 @@ export class LoginPage {
} }
enterEmail(email: string) { enterEmail(email: string) {
cy.get(this.emailInputSelector).clear().type(email); cy.get(this.emailInput).clear().type(email);
return this; return this;
} }
enterPassword(password: string) { enterPassword(password: string) {
cy.get(this.passwordInputSelector).clear().type(password); cy.get(this.passwordInput).clear().type(password);
return this; return this;
} }
submitLogin() { submitLogin() {
cy.get(this.submitBtnSelector).click(); cy.get(this.submitBtn).click();
return this; return this;
} }
} }

View File

@ -1,7 +1,7 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
export class OverviewPage { export class OverviewPage {
navbarNameSelector = '[data-test="navbar-item-username"]'; navbarName = '[data-test="navbar-item-username"]';
goto() { goto() {
cy.visit('/overview'); cy.visit('/overview');

View File

@ -0,0 +1,10 @@
import { Then } from "@badeball/cypress-cucumber-preprocessor";
import { OverviewPage } from "../../e2e/models/OverviewPage";
Then("the user is logged in with username {string}", (username: string) => {
const overviewPage = new OverviewPage();
cy.url().should('include', '/overview')
cy.get(overviewPage.navbarName).should('contain', username);
});

View File

@ -1,5 +1,5 @@
import { When } from "@badeball/cypress-cucumber-preprocessor"; import { When } from "@badeball/cypress-cucumber-preprocessor";
import { LoginPage } from "../models/LoginPage"; import { LoginPage } from "../../e2e/models/LoginPage";
When("the user submits the credentials {string} {string}", (email: string, password: string) => { When("the user submits the credentials {string} {string}", (email: string, password: string) => {
const loginPage = new LoginPage; const loginPage = new LoginPage;