Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineConfig({
viewportWidth: 1920,
viewportHeight: 1080,
defaultCommandTimeout: 4000,
retries: { runMode: 1, openMode: 1 },
retries: { runMode: 1, openMode: 0 },
scrollBehavior: 'center',
setupNodeEvents(on, config) {
// implement node event listeners here
Expand Down
46 changes: 46 additions & 0 deletions cypress/e2e/api/api.spec.js
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);
});
});
11 changes: 11 additions & 0 deletions cypress/e2e/auth/login.spec.js
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();
Copy link
Owner

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


describe("Auth page functionality", () => {
it("Login to dashboard", () => {
cy.visit("/auth/login");
authPage.login();
cy.url({timeout: 6000}).should("contains", "/pages/dashboard")
});
});
14 changes: 14 additions & 0 deletions cypress/e2e/modal-and-overlays/dialog.spec.js
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");
});
});
});
13 changes: 13 additions & 0 deletions cypress/e2e/stepper/stepperHomework.spec.js
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");
});
});
54 changes: 54 additions & 0 deletions cypress/e2e/tables-and-data/smart-tables.spec.js
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);
});
});
12 changes: 12 additions & 0 deletions cypress/page-Objects/AuthPage.js
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;
75 changes: 75 additions & 0 deletions cypress/page-Objects/SmartTablePage.js
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;
2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
// }
30 changes: 26 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@angular/platform-browser-dynamic": "^15.2.10",
"@angular/router": "^15.2.10",
"@asymmetrik/ngx-leaflet": "3.0.1",
"@faker-js/faker": "^8.4.1",
"@nebular/auth": "11.0.1",
"@nebular/eva-icons": "11.0.1",
"@nebular/security": "11.0.1",
Expand All @@ -55,6 +56,7 @@
"core-js": "2.5.1",
"echarts": "^4.9.0",
"eva-icons": "^1.1.3",
"faker": "^6.6.6",
"intl": "1.2.5",
"ionicons": "2.0.1",
"leaflet": "1.2.0",
Expand Down Expand Up @@ -97,7 +99,7 @@
"@typescript-eslint/parser": "^5.43.0",
"codelyzer": "^6.0.2",
"conventional-changelog-cli": "1.3.4",
"cypress": "^13.6.6",
"cypress": "^13.7.0",
"eslint": "^8.28.0",
"husky": "0.13.3",
"jasmine-core": "~3.6.0",
Expand Down