-
Notifications
You must be signed in to change notification settings - Fork 16
Api #13
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
base: master
Are you sure you want to change the base?
Api #13
Changes from all commits
081984c
1d6a66a
883df62
909b9fc
f5ae26b
96d0324
2308399
c647f11
6a8f298
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check all objects in array have required fields |
||
| }); | ||
|
|
||
| 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); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check response body contains request body |
||
| }); | ||
|
|
||
| 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); | ||
|
Comment on lines
+36
to
+38
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check response body contains request body |
||
| }); | ||
|
|
||
| it('should delete a post by id', () => { | ||
| cy.request('DELETE', `${baseUrl}/posts/1`) | ||
| .its('status') | ||
| .should('eq', 200); | ||
| }); | ||
| }); | ||
| 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") | ||
| }); | ||
| }); |
| 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"); | ||
| }); | ||
| }); | ||
| }); |
| 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"); | ||
| }); | ||
| }); |
| 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); | ||
| }); | ||
| }); |
| 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; |
| 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; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
check response body