Skip to content
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

Solution #296

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
97 changes: 73 additions & 24 deletions cypress/e2e/article.cy.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,73 @@
/// <reference types='cypress' />
/// <reference types='../support' />

describe('Article', () => {
before(() => {

});

beforeEach(() => {
cy.task('db:clear');
});

it('should be created using New Article form', () => {

});

it('should be edited using Edit button', () => {

});

it('should be deleted using Delete button', () => {

});
});
/// <reference types='cypress' />
/// <reference types='../support' />

import { faker } from "@faker-js/faker";

import ArticlePageObject from "../support/pages/article.pageObject";
const articlePage = new ArticlePageObject();

describe("Article", () => {
let user;
let article;
let newArticle;

before(() => {
cy.task("generateUser").then((generateUser) => {
user = generateUser;
});
cy.task("generateArticle").then((generatedArticle) => {
article = generatedArticle;
newArticle = {
title: "Edited " + generatedArticle.title,
description: "Edited " + generatedArticle.description,
body: "Edited " + generatedArticle.body,
tag: "edited-tag",
};
});
});

beforeEach(() => {
cy.task("db:clear");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.task('db:clear') command is used to clear the database before each test. Ensure that this task is correctly defined in your Cypress support files and that it performs the intended database clearing operation. If not all tests require a fresh database state, consider moving this to specific tests that need it.

cy.visit("/");
cy.registerAndLogin(user.email, user.username, user.password);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.registerAndLogin function is called before each test. Ensure that this function is correctly defined and that it performs the registration and login operations as expected. If not all tests require a user to be registered and logged in, consider moving this to specific tests that need it.

articlePage.visit();
});

it("should be created using New Article form", () => {
articlePage.typeTitle(article.title);
articlePage.typeDescription(article.description);
articlePage.typeBodyArticle(article.body);
articlePage.typeTag(article.tag);
articlePage.clickPublishBtn();
articlePage.assertArticlePage(article.title);
});

it("should be edited using Edit button", () => {
cy.createArticle(
article.title,
article.description,
article.body,
article.tag
);
Comment on lines +46 to +51

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.createArticle function is used to create an article before editing and deleting tests. Ensure that this function is correctly defined and that it performs the article creation operation as expected. This setup is necessary for the edit and delete tests, so it should be verified for correctness.

articlePage.assertArticlePage(article.title);
articlePage.clickEditArticleBtn();
articlePage.typeNewTitle(newArticle.title);
articlePage.typeNewDescription(newArticle.description);
articlePage.typeNewBodyArticle(newArticle.body);
articlePage.typeTag(newArticle.tag);
articlePage.clickPublishBtn();
articlePage.assertTitleArticlePage(newArticle.title);
});

it("should be deleted using Delete button", () => {
cy.createArticle(
article.title,
article.description,
article.body,
article.tag
);
articlePage.assertArticlePage(article.title);
articlePage.clickDeleteArticleBtn();
cy.url().should("not.include", article.title);
});
});
81 changes: 49 additions & 32 deletions cypress/e2e/settings.cy.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,49 @@
/// <reference types='cypress' />
/// <reference types='../support' />

describe('Settings page', () => {
before(() => {

});

beforeEach(() => {

});

it('should provide an ability to update username', () => {

});

it('should provide an ability to update bio', () => {

});

it('should provide an ability to update an email', () => {

});

it('should provide an ability to update password', () => {

});

it('should provide an ability to log out', () => {

});
});
/// <reference types='cypress' />
/// <reference types='../support' />
import SettingsPageObject from "../support/pages/settings.PageObject";
import HomePageObject from "../support/pages/home.pageObject";

const settingsPage = new SettingsPageObject();
const homePage = new HomePageObject();

describe("Settings page", () => {
let user;
before(() => {
cy.task("generateUser").then((generateUser) => {
user = generateUser;
});
});

beforeEach(() => {
cy.task("db:clear");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.task('db:clear') command is used to clear the database before each test. Ensure that this task is correctly defined in your Cypress support files and that it performs the intended database clearing operation. If not all tests require a fresh database state, consider moving this to specific tests that need it.

cy.visit("/#/register");
cy.registerAndLogin(user.email, user.username, user.password);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.registerAndLogin function is called before each test. Ensure that this function is correctly defined and that it performs the registration and login operations as expected. If not all tests require a user to be registered and logged in, consider moving this to specific tests that need it.

settingsPage.visit();
});

it("should provide an ability to update username", () => {
settingsPage.typeUsername(user.username);
settingsPage.clickUpdateSettingsBtn();
homePage.assertHeaderContainUsername(user.username);
});

it("should provide an ability to update bio", () => {
settingsPage.typeBio(user.bio);
settingsPage.clickUpdateSettingsBtn();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating the bio, consider adding an assertion to verify that the bio has been updated correctly. This will ensure that the update operation is successful.

});

it("should provide an ability to update an email", () => {
settingsPage.typeEmail(user.email);
settingsPage.clickUpdateSettingsBtn();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating the email, consider adding an assertion to verify that the email has been updated correctly. This will ensure that the update operation is successful.

});

it("should provide an ability to update password", () => {
settingsPage.typePassword(user.password);
settingsPage.clickUpdateSettingsBtn();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating the password, consider adding an assertion to verify that the password has been updated correctly. This will ensure that the update operation is successful.

});

it("should provide an ability to log out", () => {
settingsPage.clickLogoutBtn();
settingsPage.assertLogout("/#/");
});
});
75 changes: 41 additions & 34 deletions cypress/e2e/signIn.cy.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
/// <reference types='cypress' />
/// <reference types='../support' />

import SignInPageObject from '../support/pages/signIn.pageObject';
import HomePageObject from '../support/pages/home.pageObject';

const signInPage = new SignInPageObject();
const homePage = new HomePageObject();

describe('Sign In page', () => {
let user;

before(() => {
cy.task('db:clear');
cy.task('generateUser').then((generateUser) => {
user = generateUser;
});
});

it('should provide an ability to log in with existing credentials', () => {
signInPage.visit();
cy.register(user.email, user.username, user.password);

signInPage.typeEmail(user.email);
signInPage.typePassword(user.password);
signInPage.clickSignInBtn();

homePage.assertHeaderContainUsername(user.username);
});

it('should not provide an ability to log in with wrong credentials', () => {

});
});
/// <reference types='cypress' />
/// <reference types='../support' />

import { faker } from "@faker-js/faker";

import SignInPageObject from "../support/pages/signIn.pageObject";
import HomePageObject from "../support/pages/home.pageObject";

const signInPage = new SignInPageObject();
const homePage = new HomePageObject();

describe("Sign In page", () => {
let user;

beforeEach(() => {
cy.task("db:clear");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.task('db:clear') command is used to clear the database before each test. Ensure that this task is correctly defined in your Cypress support files and that it performs the intended database clearing operation. If not all tests require a fresh database state, consider moving this to specific tests that need it.

cy.task("generateUser").then((generateUser) => {
user = generateUser;
});
});

it("should provide an ability to log in with existing credentials", () => {
signInPage.visit();
cy.register(user.email, user.username, user.password);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.register function is used to register a user before testing the login functionality. Ensure that this function is correctly defined and that it performs the registration operation as expected. This setup is necessary for the login test, so it should be verified for correctness.


signInPage.typeEmail(user.email);
signInPage.typePassword(user.password);
signInPage.clickSignInBtn();

homePage.assertHeaderContainUsername(user.username);
});

it("should not provide an ability to log in with wrong credentials", () => {
signInPage.visit();
signInPage.typeEmail(user.email);
signInPage.typePassword(user.password + "123");
signInPage.clickSignInBtn();
signInPage.assertErrorMessage();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the assertErrorMessage function is correctly implemented to verify that the appropriate error message is displayed when login fails with incorrect credentials.

signInPage.assertLoginPage();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the assertLoginPage function is correctly implemented to verify that the user remains on the login page when login fails with incorrect credentials.

});
});
57 changes: 45 additions & 12 deletions cypress/e2e/signUp.cy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
/// <reference types='cypress' />
/// <reference types='../support' />

describe('Sign Up page', () => {
before(() => {

});

it('should ...', () => {

});
});
/// <reference types='cypress' />
/// <reference types='../support' />

import SignUpPageObject from "../support/pages/signUp.PageObject";
import HomePageObject from "../support/pages/home.pageObject";

const signUpPage = new SignUpPageObject();
const homePage = new HomePageObject();

describe("Sign Up page", () => {
let user;
let newUser;
beforeEach(() => {
cy.task("db:clear");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.task('db:clear') command is used to clear the database before each test. Ensure that this task is correctly defined in your Cypress support files and that it performs the intended database clearing operation. If not all tests require a fresh database state, consider moving this to specific tests that need it.

cy.task("generateUser").then((generatedUser) => {
user = generatedUser;
});
cy.task("generateUser").then((generatedUser) => {
newUser = generatedUser;
});
signUpPage.visit();
});

it("should provide an ability to sign up with valid credentials", () => {
signUpPage.visit();
cy.getByDataCy("signup-username-field").should("be.visible");
signUpPage.typeUsername(user.username);
signUpPage.typeEmail(user.email);
signUpPage.typePassword(user.password);
signUpPage.clickSignUpBtn();
signUpPage.assertSuccessfulMessage();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the assertSuccessfulMessage function is correctly implemented to verify that the appropriate success message is displayed when sign-up is successful.


homePage.assertHeaderContainUsername(user.username);
});

it("should not provide an ability to sign up with existing email", () => {
cy.register(user.email, user.username, user.password);
signUpPage.typeUsername(newUser.username);
signUpPage.typeEmail(user.email);
signUpPage.typePassword(newUser.password);
signUpPage.clickSignUpBtn();
signUpPage.assertErrorMessage();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the assertErrorMessage function is correctly implemented to verify that the appropriate error message is displayed when sign-up fails due to an existing email.

signUpPage.assertSignUpPage();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the assertSignUpPage function is correctly implemented to verify that the user remains on the sign-up page when sign-up fails due to an existing email.

});
});
66 changes: 54 additions & 12 deletions cypress/e2e/user.cy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,54 @@
/// <reference types='cypress' />
/// <reference types='../support' />

describe('User', () => {
before(() => {

});

it.skip('should be able to follow the another user', () => {

});
});
/// <reference types='cypress' />
/// <reference types='../support' />

import HomePageObject from '../support/pages/home.pageObject';
import SignInPageObject from '../support/pages/signIn.pageObject';
import UserPageObject from "../support/pages/user.PageObject";
const signInPage = new SignInPageObject();
const userPage = new UserPageObject();
const homePage = new HomePageObject();

describe("User", () => {
let user;
let secondUser;

before(() => {
cy.task('db:clear');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.task('db:clear') command is used to clear the database before setting up users. Ensure that this task is correctly defined in your Cypress support files and that it performs the intended database clearing operation.

// Generating first user
cy.task('generateUser').then((generatedUser) => {
user = generatedUser;
// Registering first user
cy.register(user.email, user.username, user.password);
});

// Generating second user
cy.task('generateUser').then((generatedUser) => {
secondUser = generatedUser;
// Registering second user
cy.register(secondUser.email, secondUser.username, secondUser.password);
});
});

beforeEach(() => {
signInPage.visit();
signInPage.typeEmail(user.email);
signInPage.typePassword(user.password);
signInPage.clickSignInBtn();
homePage.assertHeaderContainUsername(user.username);
});

it("should allow following a user", () => {
userPage.visitUserPage(secondUser.username);
userPage.assertCanFollowUser();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the assertCanFollowUser function is correctly implemented to verify that the follow button is available before attempting to follow a user.

userPage.clickFollowBtn();
userPage.assertFollowingUser(secondUser.username);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the assertFollowingUser function is correctly implemented to verify that the user is being followed after clicking the follow button.

});

it('should allow unfollowing a user', () => {
userPage.visitUserPage(secondUser.username);
userPage.assertFollowingUser(secondUser.username);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the assertFollowingUser function is correctly implemented to verify that the user is being followed before attempting to unfollow.

userPage.clickUnfollowBtn();
userPage.assertCanFollowUser();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the assertCanFollowUser function is correctly implemented to verify that the follow button is available after unfollowing a user.

});
});

14 changes: 7 additions & 7 deletions cypress/support/PageObject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class PageObject {
visit(url) {
cy.visit(url || this.url);
}
}

export default PageObject;
class PageObject {
visit(url) {
cy.visit(url || this.url);
}
}
export default PageObject;
Loading