-
Notifications
You must be signed in to change notification settings - Fork 322
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
add solution #313
Open
modeltoIT
wants to merge
1
commit into
mate-academy:main
Choose a base branch
from
modeltoIT:testing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add solution #313
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,44 @@ | ||
/* eslint-disable max-len */ | ||
/// <reference types='cypress' /> | ||
|
||
import HomeAndCataloguePageObject from '../support/pages/homeCatalogue.pageObject'; | ||
import CartPageObject from '../support/pages/cart.pageObject'; | ||
|
||
const homeCalalogue = new HomeAndCataloguePageObject(); | ||
const cart = new CartPageObject(); | ||
const category = 'Laptops'; | ||
const item = 'Sony vaio i7'; | ||
const alertMessage = 'Product added'; | ||
|
||
describe('', () => { | ||
before(() => { | ||
let formData; | ||
|
||
before(() => { | ||
cy.task('generateOrderInfo').then((data) => { | ||
formData = data; | ||
homeCalalogue.visit(); | ||
}); | ||
}); | ||
|
||
it('', () => { | ||
|
||
homeCalalogue.clickOnCategory(category); | ||
homeCalalogue.clickOnProduct(item); | ||
homeCalalogue.addToCart(); | ||
homeCalalogue.assertAllert(alertMessage); | ||
homeCalalogue.clickOnLink('Cart'); | ||
cart.itemIsInCart(item); | ||
cart.placeOrderBtn(); | ||
cart.typeName(formData.name); | ||
cart.typeCountry(formData.country); | ||
cart.typeCity(formData.city); | ||
cart.typeCreditCardNum(formData.creditCardNumber); | ||
cart.typeYear(formData.year); | ||
cart.typeMonth(formData.month); | ||
cart.purchaseOrderBtn(); | ||
cart.assertSuccessfulPurchase(); | ||
cart.assertPurchaseInfo('Name', formData.name); | ||
cart.assertPurchaseInfo('Card Number', formData.creditCardNumber); | ||
cart.pressOkBtn(); | ||
cart.closePurchaseForm(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import PageObject from '../PageObject'; | ||
|
||
class CartPageObject extends PageObject { | ||
get creditCardField() { | ||
return cy.get('#card'); | ||
} | ||
|
||
get nameField() { | ||
return cy.get('#name'); | ||
} | ||
|
||
get countryField() { | ||
return cy.get('#country'); | ||
} | ||
|
||
get cityField() { | ||
return cy.get('#city'); | ||
} | ||
|
||
get yearField() { | ||
return cy.get('#year'); | ||
} | ||
|
||
get monthField() { | ||
return cy.get('#month'); | ||
} | ||
|
||
get purchaseBtn() { | ||
return cy.contains('.btn', 'Purchase'); | ||
} | ||
|
||
get okBtn() { | ||
return cy.contains('.confirm', 'OK'); | ||
} | ||
|
||
get closeBtn() { | ||
return cy.get('#orderModal .btn-secondary'); | ||
} | ||
|
||
itemIsInCart(productName) { | ||
cy.get('.success').within(() => { | ||
cy.contains('td', productName).should('be.visible'); | ||
}); | ||
} | ||
|
||
placeOrderBtn() { | ||
cy.contains('button', 'Place Order').click(); | ||
} | ||
|
||
purchaseOrderBtn() { | ||
this.purchaseBtn.click(); | ||
} | ||
|
||
typeName(name) { | ||
this.nameField.type(name, { force: true }); | ||
} | ||
|
||
typeCity(city) { | ||
this.cityField.type(city, { force: true }); | ||
} | ||
|
||
typeYear(year) { | ||
this.yearField.type(year, { force: true }); | ||
} | ||
|
||
typeMonth(month) { | ||
this.monthField.type(month, { force: true }); | ||
} | ||
|
||
typeCreditCardNum(number) { | ||
this.creditCardField.type(number, { force: true }); | ||
} | ||
|
||
typeCountry(country) { | ||
this.countryField.type(country, { force: true }); | ||
} | ||
|
||
pressOkBtn() { | ||
this.okBtn.click(); | ||
} | ||
|
||
closePurchaseForm() { | ||
this.closeBtn.click({ force: true }); | ||
} | ||
|
||
assertSuccessfulPurchase() { | ||
cy.contains('h2', 'Thank you for your purchase!').should('be.visible'); | ||
} | ||
|
||
assertPurchaseInfo(field, value) { | ||
cy.contains('.lead.text-muted ', `${field}: ${value}`); | ||
} | ||
} | ||
|
||
export default CartPageObject; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
homeCalalogue
. It should behomeCatalogue
to match the class nameHomeAndCataloguePageObject
and maintain consistency.