mirror of
https://github.com/IT4Change/boilerplate-e2e-cypress-cucumber.git
synced 2025-12-12 20:55:48 +00:00
add test example
This commit is contained in:
parent
681e2d2915
commit
8982c206de
22
cypress/e2e/features/Login.feature
Normal file
22
cypress/e2e/features/Login.feature
Normal 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"
|
||||
21
cypress/e2e/step_definitions/login.ts
Normal file
21
cypress/e2e/step_definitions/login.ts
Normal 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')
|
||||
})
|
||||
13
cypress/pages/LoginPage.ts
Normal file
13
cypress/pages/LoginPage.ts
Normal 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()
|
||||
7
cypress/pages/WelcomePage.ts
Normal file
7
cypress/pages/WelcomePage.ts
Normal file
@ -0,0 +1,7 @@
|
||||
class WelcomePage {
|
||||
successMessage: string = '.flash.success'
|
||||
WelcomeHeader:string = '.subheader'
|
||||
logoutBtn: string = 'a[href="/logout"]'
|
||||
}
|
||||
|
||||
export const welcomePage = new WelcomePage()
|
||||
Loading…
x
Reference in New Issue
Block a user