Skip to content

Commit bd3d2b7

Browse files
committed
Added new test on Cypress Demo App
Demo App - https://github.com/cypress-io/cypress-realworld-app
1 parent b21ad76 commit bd3d2b7

File tree

13 files changed

+165
-61
lines changed

13 files changed

+165
-61
lines changed

cypress.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esb
66
module.exports = defineConfig({
77
projectId: "nvh163",
88
e2e: {
9-
baseUrl: "https://pro.missiongraph.io/",
9+
baseUrl: "http://localhost:3000/",
1010
setupNodeEvents(on, config) {
1111
on("file:preprocessor", createBundler({plugins: [createEsbuildPlugin.default(config)],}));
1212
preprocessor.addCucumberPreprocessorPlugin(on, config);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Feature: Login
2+
3+
Scenario Outline: Signup with new user details
4+
Given I am on the login page
5+
When I click on sigh up link
6+
Then I should be on the sign up page
7+
When I type in my first name "<first_name>"
8+
When I type in my last name "<last_name>"
9+
When I type in my username "<username>"
10+
When I type in my password "<password>"
11+
When I type in my password again "<confirm_password>"
12+
When I click on the sign up button
13+
Then I should be on the login page
14+
15+
Examples:
16+
| first_name | last_name | username | password | confirm_password |
17+
| John | Doe | johndoe | Pass123 | Pass123 |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Feature: Login
2+
3+
Scenario Outline: Login with created user
4+
Given I am on the login page
5+
When I type in my username "<username>"
6+
When I type in my password "<password>"
7+
When I click on the sign up button
8+
Then I should be on the home page
9+
Then I should see username - "<username>" on homepage
10+
11+
Examples:
12+
| username | password |
13+
| johndoe | Pass123 |

cypress/e2e/features/Login.feature

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var elements = require('./elements')
2+
3+
class HomePage {
4+
verifyOnHomePage() {
5+
return cy.get(elements.HOMEPAGE.HOME_PAGE_HEADING).should('be.visible')
6+
}
7+
8+
verifyUsernameOnHomePage(value) {
9+
return cy.get(elements.HOMEPAGE.USERNAME_LABEL)
10+
.should('be.visible')
11+
.and('include.text', value)
12+
}
13+
}
14+
15+
export default HomePage
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
HOMEPAGE:{
3+
HOME_PAGE_HEADING: "h1[data-test='app-name-logo']",
4+
USERNAME_LABEL: "h6[data-test='sidenav-username']"
5+
}
6+
}

cypress/e2e/pages/landingPage/LandingPage.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

cypress/e2e/pages/landingPage/elements.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

cypress/e2e/pages/loginPage/LoginPage.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,30 @@ var elements = require('./elements')
22

33
class LoginPage {
44

5-
typeInEmailField(value) {
6-
return cy.get(elements.LOGINPAGE.EMAIL_TEXT).type(value)
5+
verifyOnLoginPage() {
6+
return cy.get(elements.LOGINPAGE.LOGIN_PAGE_HEADING)
7+
.should('be.visible')
8+
.and('have.text', 'Sign in')
79
}
810

9-
typeInPasswordField(value) {
11+
typeInUsernameTextbox(value) {
12+
return cy.get(elements.LOGINPAGE.USERNAME_TEXT).type(value)
13+
}
14+
15+
typeInPasswordTextbox(value) {
1016
return cy.get(elements.LOGINPAGE.PASSWORD_TEXT).type(value)
1117
}
1218

13-
clickLoginButton() {
14-
return cy.get(elements.LOGINPAGE.LOGIN_BUTTON).click()
19+
checkRememberMeCheckbox() {
20+
return cy.get(elements.LOGINPAGE.REMEMBER_ME_CHECKBOX).check()
21+
}
22+
23+
clickOnSignInButton() {
24+
return cy.get(elements.LOGINPAGE.SIGN_IN_BUTTON).click()
25+
}
26+
27+
clickOnSignUpLink() {
28+
return cy.get(elements.LOGINPAGE.SIGN_UP_LINK).click()
1529
}
1630
}
1731

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
module.exports = {
22
LOGINPAGE:{
3-
LOGIN_PAGE_HEADING: "h2",
4-
EMAIL_TEXT: "#login",
3+
LOGIN_PAGE_HEADING: "h1",
4+
USERNAME_TEXT: "#username",
55
PASSWORD_TEXT: "#password",
6-
LOGIN_BUTTON: "#submit-login"
6+
REMEMBER_ME_CHECKBOX: "input[type='checkbox']",
7+
SIGN_IN_BUTTON: "button[type='submit']",
8+
SIGN_UP_LINK: "a[data-test='signup']"
79
}
810
}

0 commit comments

Comments
 (0)