-
Notifications
You must be signed in to change notification settings - Fork 16
Cypress #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ChrissyDev
wants to merge
8
commits into
sttaran:master
Choose a base branch
from
ChrissyDev:cypress
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Cypress #10
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
081984c
check
ChrissyDev 1d6a66a
homework 14
ChrissyDev 883df62
homework 15
ChrissyDev 909b9fc
fixed authTab to authPage
ChrissyDev f5ae26b
updated homework 15, moved user to code instead of POM
ChrissyDev 96d0324
fixed verifyCreatedUserData method
ChrissyDev 2308399
forgot to rename 1 file
ChrissyDev c647f11
Homework 16
ChrissyDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| describe('API Tests', () => { | ||
| const baseUrl = 'https://jsonplaceholder.typicode.com'; | ||
|
|
||
| it('should get a post by id', () => { | ||
| cy.request(`${baseUrl}/posts/1`) | ||
| .its('status') | ||
| .should('eq', 200); | ||
| }); | ||
|
|
||
| it('should get a list of posts', () => { | ||
| cy.request(`${baseUrl}/posts`) | ||
| .its('status') | ||
| .should('eq', 200); | ||
| cy.request(`${baseUrl}/posts`) | ||
| .its('body') | ||
| .should('not.be.empty') | ||
| }); | ||
|
|
||
| it('should create a new post', () => { | ||
| const newPost = { | ||
| title: 'New Post', | ||
| body: 'This is a new post.', | ||
| userId: 1 | ||
| }; | ||
| cy.request('POST', `${baseUrl}/posts`, newPost) | ||
| .its('status') | ||
| .should('eq', 201); | ||
| }); | ||
|
|
||
| it('should update a post by id', () => { | ||
| const updatedPost = { | ||
| title: 'Updated Post', | ||
| body: 'This post has been updated.', | ||
| userId: 1 | ||
| }; | ||
| cy.request('PUT', `${baseUrl}/posts/1`, updatedPost) | ||
| .its('status') | ||
| .should('eq', 200); | ||
| }); | ||
|
|
||
| it('should delete a post by id', () => { | ||
| cy.request('DELETE', `${baseUrl}/posts/1`) | ||
| .its('status') | ||
| .should('eq', 200); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import AuthPage from "../../page-Objects/AuthTab.js"; | ||
|
|
||
| const authPage = new AuthPage(); | ||
|
|
||
| describe("Auth page functionality", () => { | ||
| it("Login to dashboard", () => { | ||
| cy.visit("/auth/login"); | ||
| authPage.login(); | ||
| cy.url({timeout: 6000}).should("contains", "/pages/dashboard") | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| describe("Dialog page functionality", () => { | ||
| it("Opening 'Enter your name' modal window", () => { | ||
| cy.visit("/pages/modal-overlays/dialog"); | ||
| cy.get(".result-from-dialog").find("button").click(); | ||
| cy.get(".ng-star-inserted > nb-card") | ||
| .should("be.visible") | ||
| .within(() => { | ||
| cy.get("nb-card-header").should("contain", "Enter your name"); | ||
| cy.get("nb-card-body > .size-medium").should("exist"); | ||
| cy.get(".cancel").should("be.visible"); | ||
| cy.get(".status-success").should("be.visible"); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| describe("stepper functionality", () => { | ||
| it("after click on next button moves to following step", () => { | ||
| const stepperSelector = ".col-lg-12 > nb-card-body"; | ||
| cy.visit("/pages/layout/stepper"); | ||
| cy.get(`${stepperSelector} h3`).contains("Step content #1"); | ||
| cy.get(`${stepperSelector} button`).contains("next").click(); | ||
| cy.get(`${stepperSelector} h3`).contains("Step content #2"); | ||
| cy.get(`${stepperSelector} button`).contains("next").click(); | ||
| cy.get(`${stepperSelector} h3`).contains("Step content #3"); | ||
| cy.get(`${stepperSelector} button`).contains("next").click(); | ||
| cy.get(`${stepperSelector} h3`).contains("Step content #4"); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import SmartTablePage from "../../page-Objects/SmartTablePage.js"; | ||
| import { faker } from '@faker-js/faker'; | ||
|
|
||
| const smartTablePage = new SmartTablePage(); | ||
|
|
||
| describe("Smart tables functionality", () => { | ||
| beforeEach(() => { | ||
| cy.visit("pages/tables/smart-table"); | ||
| }); | ||
|
|
||
| it("Creates new user and checks if it's added to the table", () => { | ||
| cy.get(".ng2-smart-actions-title").should("be.visible").click(); | ||
|
|
||
| const user = { | ||
| id: faker.number.int(), | ||
| firstName: faker.person.firstName(), | ||
| lastName: faker.person.lastName(), | ||
| username: faker.internet.userName(), | ||
| email: faker.internet.email(), | ||
| age: faker.number.int({ min: 18, max: 100 }) | ||
| }; | ||
|
|
||
| smartTablePage.createUser(user); | ||
| smartTablePage.filterCreatedUser(user); | ||
| cy.get("tbody") | ||
| .should("be.visible") | ||
| .within(() => { | ||
| cy.get(".ng2-smart-row").should("have.length", 1); | ||
| smartTablePage.verifyCreatedUserData(user); | ||
| }); | ||
| }); | ||
|
|
||
| it("Creates new user, edits it and checks if edited values are added to the table", () => { | ||
| cy.get(".ng2-smart-actions-title").should("be.visible").click(); | ||
|
|
||
| const user = { | ||
| id: faker.number.int(), | ||
| firstName: faker.person.firstName(), | ||
| lastName: faker.person.lastName(), | ||
| username: faker.internet.userName(), | ||
| email: faker.internet.email(), | ||
| age: faker.number.int({ min: 18, max: 100 }) | ||
| }; | ||
|
|
||
| smartTablePage.createUser(user); | ||
| smartTablePage.filterCreatedUser(user); | ||
| smartTablePage.verifyCreatedUserData(user); | ||
| cy.wait(1000); | ||
| cy.get(".nb-edit").click(); | ||
| smartTablePage.clearEditFields(); | ||
| const editedUser = smartTablePage.editUser(user); | ||
| smartTablePage.verifyEditedUserData(editedUser); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { faker } from '@faker-js/faker'; | ||
|
|
||
| class AuthPage { | ||
| login() { | ||
| cy.get('#input-email').type("somerandomemail@gmail.com"); | ||
| cy.get('#input-password').type("12345678"); | ||
| cy.get('.custom-checkbox').click(); | ||
| cy.get('.appearance-filled').click(); | ||
| } | ||
| } | ||
|
|
||
| export default AuthPage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { faker } from '@faker-js/faker'; | ||
|
|
||
| class SmartTablePage { | ||
| createUser(user) { | ||
| cy.get('[ng2-st-thead-form-row=""] > :nth-child(2)').should("be.visible").type(user.id.toString()); | ||
| cy.get('[ng2-st-thead-form-row=""] > :nth-child(3)').should("be.visible").type(user.firstName); | ||
| cy.get('[ng2-st-thead-form-row=""] > :nth-child(4)').should("be.visible").type(user.lastName); | ||
| cy.get('[ng2-st-thead-form-row=""] > :nth-child(5)').should("be.visible").type(user.username); | ||
| cy.get('[ng2-st-thead-form-row=""] > :nth-child(6)').should("be.visible").type(user.email); | ||
| cy.get('[ng2-st-thead-form-row=""] > :nth-child(7)').should("be.visible").type(user.age.toString()); | ||
| cy.get('.nb-checkmark').click(); | ||
| } | ||
|
|
||
| filterCreatedUser(user) { | ||
| cy.get('.ng2-smart-filters > .id').should("be.visible").type(user.id.toString()); | ||
| cy.get('.ng2-smart-filters > .firstName').should("be.visible").type(user.firstName); | ||
| cy.get('.ng2-smart-filters > .lastName').should("be.visible").type(user.lastName); | ||
| cy.get('.ng2-smart-filters > .username').should("be.visible").type(user.username); | ||
| cy.get('.ng2-smart-filters > .email').should("be.visible").type(user.email); | ||
| cy.get('.ng2-smart-filters > .age').should("be.visible").type(user.age.toString()); | ||
| } | ||
|
|
||
| verifyCreatedUserData(newUser) { | ||
| cy.get(".ng2-smart-row").should("have.length", 1); | ||
| cy.get(':nth-child(2)').should("contain.text", newUser.id); | ||
| cy.get(':nth-child(3)').should("contain.text", newUser.firstName); | ||
| cy.get(':nth-child(4)').should("contain.text", newUser.lastName); | ||
| cy.get(':nth-child(5)').should("contain.text", newUser.username); | ||
| cy.get(':nth-child(6)').should("contain.text", newUser.email); | ||
| cy.get(':nth-child(7)').should("contain.text", newUser.age); | ||
| } | ||
|
|
||
| clearEditFields() { | ||
| cy.get('[ng-reflect-name="id"]').clear(); | ||
| cy.get('[ng-reflect-name="firstName"]').clear(); | ||
| cy.get('[ng-reflect-name="lastName"]').clear(); | ||
| cy.get('[ng-reflect-name="username"]').clear(); | ||
| cy.get('[ng-reflect-name="email"]').clear(); | ||
| cy.get('[ng-reflect-name="age"]').clear(); | ||
| } | ||
|
|
||
| editUser(user) { | ||
| const editedUser = { | ||
| editedId: "edited" + user.id, | ||
| editedFirstName: "edited" + user.firstName, | ||
| editedLastName: "edited" + user.lastName, | ||
| editedUsername: "edited" + user.username, | ||
| editedEmail: "edited" + user.email, | ||
| editedAge: "edited" + user.age | ||
| }; | ||
|
|
||
| cy.get('[ng-reflect-name="id"]').type(editedUser.editedId); | ||
| cy.get('[ng-reflect-name="firstName"]').type(editedUser.editedFirstName); | ||
| cy.get('[ng-reflect-name="lastName"]').type(editedUser.editedLastName); | ||
| cy.get('[ng-reflect-name="username"]').type(editedUser.editedUsername); | ||
| cy.get('[ng-reflect-name="email"]').type(editedUser.editedEmail); | ||
| cy.get('[ng-reflect-name="age"]').type(editedUser.editedAge); | ||
|
|
||
| cy.get('.ng2-smart-action-edit-save').click(); | ||
|
|
||
| return editedUser; | ||
| } | ||
|
|
||
| verifyEditedUserData(user) { | ||
| cy.get('.ng2-smart-row > :nth-child(2)').should("contain.text", user.editedId); | ||
| cy.get('.ng2-smart-row > :nth-child(3)').should("contain.text", user.editedFirstName); | ||
| cy.get('.ng2-smart-row > :nth-child(4)').should("contain.text", user.editedLastName); | ||
| cy.get('.ng2-smart-row > :nth-child(5)').should("contain.text", user.editedUsername); | ||
| cy.get('.ng2-smart-row > :nth-child(6)').should("contain.text", user.editedEmail); | ||
| cy.get('.ng2-smart-row > :nth-child(7)').should("contain.text", user.editedAge); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| export default SmartTablePage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move it to describe