diff --git a/e2e-tests/cypress/tests/cypress/e2e/User.Authentication.feature b/e2e-tests/cypress/tests/cypress/e2e/User.Authentication.feature index 3f5129f1f..e2c459692 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/User.Authentication.feature +++ b/e2e-tests/cypress/tests/cypress/e2e/User.Authentication.feature @@ -4,14 +4,14 @@ Feature: User authentication 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 -# Background: -# Given the following "users" are in the database: -# | email | password | name | -# | bibi@bloxberg.de | Aa12345_ | Bibi Bloxberg | + # TODO for these pre-conditions utilize seeding or API check, if user exists in test system + # Background: + # Given the following "users" are in the database: + # | email | password | name | + # | bibi@bloxberg.de | Aa12345_ | Bibi Bloxberg | Scenario: Log in successfully Given the browser navigates to page "/login" When the user submits the credentials "bibi@bloxberg.de" "Aa12345_" Then the user is logged in with username "Bibi Bloxberg" - \ No newline at end of file diff --git a/e2e-tests/cypress/tests/cypress/e2e/gradido_login.cy.js b/e2e-tests/cypress/tests/cypress/e2e/gradido_login.cy.js deleted file mode 100644 index 2a2f8b8ce..000000000 --- a/e2e-tests/cypress/tests/cypress/e2e/gradido_login.cy.js +++ /dev/null @@ -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`); - }); -}); diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/LoginPage.ts b/e2e-tests/cypress/tests/cypress/e2e/models/LoginPage.ts index 065646543..9886a80ff 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/LoginPage.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/LoginPage.ts @@ -2,11 +2,11 @@ export class LoginPage { // selectors - emailInputSelector = '[id=Email-input-field]'; - passwordInputSelector = '[id=Passwort-input-field]'; - submitBtnSelector = '[type=submit]'; - emailHintSelector = '[id=vee_Email]'; - passwordHintSelector = '[id=vee_Passwort]'; + emailInput = '#Email-input-field'; + passwordInput = '#Passwort-input-field'; + submitBtn = '[type=submit]'; + emailHint = '#vee_Email'; + passwordHint = '#vee_Passwort'; goto() { cy.visit('/'); @@ -14,17 +14,17 @@ export class LoginPage { } enterEmail(email: string) { - cy.get(this.emailInputSelector).clear().type(email); + cy.get(this.emailInput).clear().type(email); return this; } enterPassword(password: string) { - cy.get(this.passwordInputSelector).clear().type(password); + cy.get(this.passwordInput).clear().type(password); return this; } submitLogin() { - cy.get(this.submitBtnSelector).click(); + cy.get(this.submitBtn).click(); return this; } } diff --git a/e2e-tests/cypress/tests/cypress/e2e/models/OverviewPage.ts b/e2e-tests/cypress/tests/cypress/e2e/models/OverviewPage.ts index 85dc97083..1de37abe2 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/models/OverviewPage.ts +++ b/e2e-tests/cypress/tests/cypress/e2e/models/OverviewPage.ts @@ -1,7 +1,7 @@ /// export class OverviewPage { - navbarNameSelector = '[data-test="navbar-item-username"]'; + navbarName = '[data-test="navbar-item-username"]'; goto() { cy.visit('/overview'); diff --git a/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_is_logged_in_with_username_{string}.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_is_logged_in_with_username_{string}.ts new file mode 100644 index 000000000..4a01a988f --- /dev/null +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_is_logged_in_with_username_{string}.ts @@ -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); +}); + + diff --git a/e2e-tests/cypress/tests/cypress/e2e/User.Authentication/the_user_submits_the_credentials_{string}_{string}.ts b/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_submits_the_credentials_{string}_{string}.ts similarity index 84% rename from e2e-tests/cypress/tests/cypress/e2e/User.Authentication/the_user_submits_the_credentials_{string}_{string}.ts rename to e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_submits_the_credentials_{string}_{string}.ts index 94a8f7593..d6766f837 100644 --- a/e2e-tests/cypress/tests/cypress/e2e/User.Authentication/the_user_submits_the_credentials_{string}_{string}.ts +++ b/e2e-tests/cypress/tests/cypress/support/step_definitions/the_user_submits_the_credentials_{string}_{string}.ts @@ -1,5 +1,5 @@ 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) => { const loginPage = new LoginPage;