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

DemoBlaze e2e #287

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
47 changes: 44 additions & 3 deletions cypress/e2e/checkout.cy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,52 @@

import HomeAndCataloguePageObject
from '../support/pages/homeCatalogue.pageObject';
import ProductPageObject
from '../support/pages/productPageObject';
import CartPage
from '../support/pages/cartPageObject';

const { faker } = require('@faker-js/faker');

/// <reference types='cypress' />

describe('', () => {
before(() => {
const homePage = new HomeAndCataloguePageObject();
const productPage = new ProductPageObject();
const cartPage = new CartPage();

const catagoryName = 'Laptops';

Choose a reason for hiding this comment

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

There is a typo in the variable name 'catagoryName'. It should be 'categoryName' to match the correct spelling of 'category'.

const productName = 'Sony vaio i7';
const orderName = faker.person.firstName();
const userCountry = faker.location.country();
const creditCard = faker.finance.creditCardNumber();

const month = faker.number.int({ min: 1, max: 12 });
const city = faker.location.city();
const year = faker.number.int({ min: 1900, max: 2024 });

describe('Demoblaze Checkout Flow', () => {
before(() => {
homePage.visit();
});

it('', () => {
it('should complete the checkout process', () => {
homePage.clickOnCategory(catagoryName);
homePage.clickOnProduct(productName);

productPage.addToCartBtn.click();

Choose a reason for hiding this comment

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

The method 'addToCartBtn.click()' seems to be directly accessing a button element. Ensure that 'addToCartBtn' is a method that performs the click action, or if it's a property, it should be a function call to perform the click.

productPage.assertAllert('Product added');

cartPage.visitCart();
cartPage.assertProductInCart(productName);

cartPage.placeOrderBtn();

Choose a reason for hiding this comment

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

The method 'placeOrderBtn()' should be checked to ensure it performs the intended action. If 'placeOrderBtn' is a button element, it should be a function call to perform the click.

Choose a reason for hiding this comment

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

This line seems to be calling placeOrderBtn as if it were a function, but it might be a property or element. Ensure that placeOrderBtn is a function if you intend to call it this way, or adjust the syntax if it's a property.

cartPage
.fillOrderFields(orderName, userCountry, creditCard, month, city, year);

cartPage.confirmOrder();

cartPage.assertEnteredDataOnModal(orderName, creditCard);

cartPage.clickOk();
});
});
39 changes: 39 additions & 0 deletions cypress/support/pages/cartPageObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import PageObject from '../PageObject';

class CartPage extends PageObject {
visitCart() {
cy.contains('#cartur', 'Cart').click();
};

Choose a reason for hiding this comment

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

There's an unnecessary semicolon at the end of the method definition. In JavaScript, semicolons are not required after method definitions within a class.


assertProductInCart(productName) {
cy.contains(productName).should('be.visible');
};

Choose a reason for hiding this comment

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

There's an unnecessary semicolon at the end of the method definition. In JavaScript, semicolons are not required after method definitions within a class.


placeOrderBtn() {
cy.contains('.btn-success', 'Place Order').click();
};

Choose a reason for hiding this comment

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

There's an unnecessary semicolon at the end of the method definition. In JavaScript, semicolons are not required after method definitions within a class.


fillOrderFields(orderName, userCountry, creditCard, month, city, year) {
cy.get('#name').type(orderName);
cy.get('#country').type(userCountry);
cy.get('#card').type(creditCard);
cy.get('#month').type(month);
cy.get('#city').type(city);
cy.get('#year').type(year);
};

Choose a reason for hiding this comment

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

There's an unnecessary semicolon at the end of the method definition. In JavaScript, semicolons are not required after method definitions within a class.


confirmOrder() {
cy.contains('.btn', 'Purchase').click();
};

Choose a reason for hiding this comment

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

There's an unnecessary semicolon at the end of the method definition. In JavaScript, semicolons are not required after method definitions within a class.


assertEnteredDataOnModal

Choose a reason for hiding this comment

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

There is a syntax error here. The method name assertEnteredDataOnModal should be followed by parentheses () to define it as a function.

(orderName, creditCard) {
cy.get('.lead.text-muted').should('contain', orderName)
.and('contain', creditCard);
};

Choose a reason for hiding this comment

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

There's an unnecessary semicolon at the end of the method definition. In JavaScript, semicolons are not required after method definitions within a class.


clickOk() {
cy.contains('OK').click();
};

Choose a reason for hiding this comment

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

There's an unnecessary semicolon at the end of the method definition. In JavaScript, semicolons are not required after method definitions within a class.

}
export default CartPage;
9 changes: 9 additions & 0 deletions cypress/support/pages/productPageObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import PageObject from '../PageObject';

class ProductPageObject extends PageObject {
get addToCartBtn() {
return cy.get('.btn.btn-success.btn-lg');
}
}

export default ProductPageObject;