-
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
Solution #281
base: main
Are you sure you want to change the base?
Solution #281
Changes from all commits
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,48 @@ | ||
/// <reference types='cypress' /> | ||
|
||
describe('', () => { | ||
before(() => { | ||
import { CartPageObject } from '../support/pages/cart.pageObject'; | ||
import HomeAndCataloguePageObject | ||
from '../support/pages/homeCatalogue.pageObject'; | ||
import { faker } from '@faker-js/faker'; | ||
|
||
const homePage = new HomeAndCataloguePageObject(); | ||
const cartPage = new CartPageObject(); | ||
|
||
const testData = { | ||
product: 'Sony vaio i7', | ||
category: 'Laptops', | ||
alertMessage: 'Product added', | ||
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 alert message 'Product added' should be consistent with the actual alert message displayed by the application. Ensure that this string matches exactly what the application shows. |
||
name: faker.person.firstName(), | ||
country: faker.location.country(), | ||
city: faker.location.city(), | ||
card: faker.finance.creditCardNumber(), | ||
month: faker.date.month(), | ||
year: Math.floor(Math.random() * (2024 - 1900 + 1)) + 1900, | ||
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 random year generation logic seems to be correct, but ensure that the range (1900 to 2024) is what you intend for your test case. If you need a specific range, adjust the logic accordingly. |
||
successMessage: 'Thanks for the message!!' | ||
}; | ||
|
||
describe('Demoblaze flow', () => { | ||
before(() => { | ||
homePage.visit(); | ||
}); | ||
|
||
it('', () => { | ||
it('should provide an opportunity to make a purchase', () => { | ||
homePage.clickOnCategory('Laptops'); | ||
homePage.clickOnProduct('Sony vaio i7'); | ||
homePage.clickOnButton('Add to cart'); | ||
|
||
homePage.verifyAlertMessage('Product added'); | ||
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. Ensure that the alert message 'Product added' used here matches the actual alert message from the application. Any discrepancy will cause this verification to fail. |
||
|
||
homePage.clickOnLink('Cart'); | ||
cartPage.verifyItemInCart('Sony vaio i7'); | ||
cartPage.clickOnButton('Place Order'); | ||
|
||
cartPage.fillOrderForm(testData.name, testData.country, testData.city, | ||
testData.card, testData.month, testData.year); | ||
|
||
cartPage.clickOnButton('Purchase'); | ||
cartPage.verifyEnteredDataOnModalWindow(testData.name, testData.card); | ||
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. Ensure that the method 'verifyEnteredDataOnModalWindow' correctly verifies the data on the modal window. If the modal displays data differently, you may need to adjust this method. |
||
|
||
cartPage.clickOnButton('OK'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
import PageObject from '../PageObject'; | ||
|
||
export class CartPageObject extends PageObject { | ||
verifyItemInCart(itemName) { | ||
cy.contains(itemName) | ||
.should('exist'); | ||
} | ||
|
||
clickOnButton(buttonText) { | ||
cy.contains(buttonText) | ||
.should('be.visible') | ||
.click(); | ||
} | ||
|
||
fillOrderForm(name, country, city, card, month, year) { | ||
cy.get('#name').type(name); | ||
cy.get('#country').type(country); | ||
cy.get('#city').type(city); | ||
cy.get('#card').type(card); | ||
cy.get('#month').type(month); | ||
cy.get('#year').type(year); | ||
} | ||
|
||
verifyEnteredDataOnModalWindow(name, card) { | ||
cy.get('.sweet-alert').should('contain', name); | ||
cy.get('.sweet-alert').should('contain', card); | ||
} | ||
} |
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 missing semicolon at the end of the import statement. This might cause issues depending on your project's configuration.