-
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 #305
base: main
Are you sure you want to change the base?
solution #305
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,52 @@ | ||
import PlaceOrderFormPageObject from '../support/pages/orderForm.pageObject'; | ||
import HomeAndCataloguePageObject | ||
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 seems to be a missing |
||
from '../support/pages/homeСatalogue.pageObject'; | ||
// eslint-disable-next-line max-len | ||
import ConfirmationFormPageObject from '../support/pages/confirmForm.pageObject'; | ||
import CartFormPageObject from '../support/pages/cartForm.pageObject'; | ||
|
||
const orderForm = new PlaceOrderFormPageObject(); | ||
const homePage = new HomeAndCataloguePageObject(); | ||
const confirmWindowValue = new ConfirmationFormPageObject(); | ||
const cartWindow = new CartFormPageObject(); | ||
|
||
/// <reference types='cypress' /> | ||
|
||
describe('', () => { | ||
before(() => { | ||
describe('The order', () => { | ||
let user; | ||
|
||
before(() => { | ||
cy.task('generateUser').then((generateUser) => { | ||
user = generateUser; | ||
}); | ||
homePage.visit(); | ||
}); | ||
|
||
it('', () => { | ||
|
||
it('should be placed by purchase the form', () => { | ||
const confirmationMessage = 'Thank you for your purchase!'; | ||
homePage.clickOnCategory('Laptops'); | ||
homePage.clickOnProduct('Sony vaio i7'); | ||
homePage.clickOnBtnOnProductPage('Add to cart'); | ||
orderForm.handleConfirmWindow(); | ||
homePage.clickOnLink('Cart'); | ||
cartWindow.table.should('contain', 'Sony vaio i7'); | ||
homePage.clickOnBtnInCart('Place Order'); | ||
orderForm.typeName(user.username); | ||
orderForm.typeCountry(user.country); | ||
orderForm.typeCity(user.city); | ||
orderForm.typeCard(user.card); | ||
orderForm.typeMonth(user.month); | ||
orderForm.typeYear(user.year); | ||
homePage.clickOnBtnInOrderForm('Purchase'); | ||
confirmWindowValue.confirmWindow.should('exist'); | ||
confirmWindowValue.customerName | ||
.should('contain', user.username); | ||
confirmWindowValue.confirmMsg | ||
.should('contain', confirmationMessage); | ||
confirmWindowValue.customerCard | ||
.should('contain', user.card); | ||
confirmWindowValue.orderId | ||
.should('contain', 'Id'); | ||
homePage.clickOnOk(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import ContactFormPageObject from '../support/pages/contactForm.pageObject'; | ||
import HomeAndCataloguePageObject | ||
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 seems to be a missing |
||
from '../support/pages/homeCatalogue.pageObject'; | ||
from '../support/pages/homeAndCataloguePageObject'; | ||
import faker from 'faker'; | ||
/// <reference types='cypress' /> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import PageObject from '../PageObject'; | ||
|
||
class CartFormPageObject extends PageObject { | ||
url = '/cart.html'; | ||
|
||
get table() { | ||
return cy.get('.table-responsive'); | ||
} | ||
} | ||
|
||
export default CartFormPageObject; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import PageObject from '../PageObject'; | ||
|
||
class ConfirmationFormPageObject extends PageObject { | ||
url = '/cart.html'; | ||
|
||
get confirmWindow() { | ||
return cy.get('.sweet-alert'); | ||
} | ||
|
||
get customerName() { | ||
return cy.get('.lead'); | ||
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 selector |
||
} | ||
|
||
get confirmMsg() { | ||
return cy.get('.sweet-alert > h2'); | ||
} | ||
|
||
get customerCard() { | ||
return cy.get('.lead'); | ||
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 selector |
||
} | ||
|
||
get orderId() { | ||
return cy.get('.lead'); | ||
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 selector |
||
} | ||
} | ||
|
||
export default ConfirmationFormPageObject; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import PageObject from '../PageObject'; | ||
|
||
class PlaceOrderFormPageObject extends PageObject { | ||
url = '/cart.html'; | ||
|
||
get nameField() { | ||
return cy.get('#name'); | ||
} | ||
|
||
get countryField() { | ||
return cy.get('#country'); | ||
} | ||
|
||
get cityField() { | ||
return cy.get('#city'); | ||
} | ||
|
||
get creditCardField() { | ||
return cy.get('#card'); | ||
} | ||
|
||
get monthField() { | ||
return cy.get('#month'); | ||
} | ||
|
||
get yearField() { | ||
return cy.get('#year'); | ||
} | ||
|
||
handleConfirmWindow() { | ||
cy.on('window:alert', (alertText) => { | ||
expect(alertText).to.equal('Product added'); | ||
cy.contains('button', 'OK').click(); | ||
}); | ||
} | ||
|
||
typeName(name) { | ||
this.nameField.type(name, { force: true }); | ||
} | ||
|
||
typeCountry(country) { | ||
this.countryField.type(country, { force: true }); | ||
} | ||
|
||
typeCity(city) { | ||
this.cityField.type(city, { force: true }); | ||
} | ||
|
||
typeCard(card) { | ||
this.creditCardField.type(card, { force: true }); | ||
} | ||
|
||
typeMonth(month) { | ||
this.monthField.type(month, { force: true }); | ||
} | ||
|
||
typeYear(year) { | ||
this.yearField.type(year, { force: true }); | ||
} | ||
} | ||
|
||
export default PlaceOrderFormPageObject; |
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.
The
Math.random(1000)
function does not accept any arguments. To generate a random number between 1 and 1000, you should useMath.ceil(Math.random() * 1000)
.