add test example

This commit is contained in:
mahula 2024-02-19 13:34:03 +01:00
parent 681e2d2915
commit 8982c206de
4 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,22 @@
Feature: Login
As a user
I want to sign in
I want to benoticed when sign in fails
Background:
Given The web browser is at the login page
Scenario: Successful Login
When I submit the credentials 'tomsmith' 'SuperSecretPassword!'
Then I am on the welcome page
# Scenario: Refresh and stay logged in
# Given I am logged in as "peter-pan"
# When I refresh the page
# Then I am logged in with username "Peter Pan"
# Scenario: Log out
# Given I am logged in as "peter-pan"
# When I navigate to page "/"
# And I log out
# Then I am on page "login"

View File

@ -0,0 +1,21 @@
import {
Given,
When,
Then,
} from '@badeball/cypress-cucumber-preprocessor'
import {loginPage} from '../../pages/LoginPage'
import {welcomePage} from '../../pages/WelcomePage'
Given('The web browser is at the login page', () => {
cy.visit('/login')
})
When('I submit the credentials {string} {string}', (username:string, password: string) => {
loginPage.submitLogin(username, password)
})
Then('I am on the welcome page', () => {
cy.get(welcomePage.successMessage).should('be.visible')
cy.get(welcomePage.WelcomeHeader).should('be.visible')
cy.get(welcomePage.logoutBtn).should('be.visible')
})

View File

@ -0,0 +1,13 @@
class LoginPage {
usernameInput: string = '#username'
passwordInput:string = '#password'
submitBtn: string = 'button[type=submit]'
submitLogin(username: string, password: string){
cy.get(this.usernameInput).type(username)
cy.get(this.passwordInput).type(password)
cy.get(this.submitBtn).click()
}
}
export const loginPage = new LoginPage()

View File

@ -0,0 +1,7 @@
class WelcomePage {
successMessage: string = '.flash.success'
WelcomeHeader:string = '.subheader'
logoutBtn: string = 'a[href="/logout"]'
}
export const welcomePage = new WelcomePage()