-
Notifications
You must be signed in to change notification settings - Fork 318
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
base: main
Are you sure you want to change the base?
DemoBlaze e2e #287
Changes from 1 commit
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 |
---|---|---|
@@ -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'; | ||
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(); | ||
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. 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(); | ||
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. 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. 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. This line seems to be calling |
||
cartPage | ||
.fillOrderFields(orderName, userCountry, creditCard, month, city, year); | ||
|
||
cartPage.confirmOrder(); | ||
|
||
cartPage.assertEnteredDataOnModal(orderName, creditCard); | ||
|
||
cartPage.clickOk(); | ||
}); | ||
}); |
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(); | ||
}; | ||
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. 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'); | ||
}; | ||
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. 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(); | ||
}; | ||
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. 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); | ||
}; | ||
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. 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(); | ||
}; | ||
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. 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 | ||
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. There is a syntax error here. The method name |
||
(orderName, creditCard) { | ||
cy.get('.lead.text-muted').should('contain', orderName) | ||
.and('contain', creditCard); | ||
}; | ||
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. 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(); | ||
}; | ||
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. 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; |
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; |
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.
There is a typo in the variable name 'catagoryName'. It should be 'categoryName' to match the correct spelling of 'category'.