-
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
develop #300
base: main
Are you sure you want to change the base?
develop #300
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,59 @@ | ||
/* eslint-disable */ | ||
import { faker } from '@faker-js/faker' | ||
import HomeAndCataloguePageObject from '../support/pages/homeСatalogue.pageObject' | ||
import CartPageObject from '../support/pages/cart.pageObject' | ||
/// <reference types='cypress' /> | ||
|
||
describe('', () => { | ||
const homePage = new HomeAndCataloguePageObject() | ||
const cartPage = new CartPageObject() | ||
|
||
const testData = { | ||
name: faker.name.firstName(), | ||
country: faker.address.country(), | ||
city: faker.address.city(), | ||
creditCard: faker.finance.creditCardNumber(), | ||
month: faker.date.month(), | ||
year: faker.date.future({ years: 5 }).getFullYear(), | ||
productName: 'Sony vaio i7', | ||
successMessage: 'Product added', | ||
} | ||
|
||
describe('Shopping Cart', () => { | ||
before(() => { | ||
homePage.visit() | ||
}) | ||
|
||
it('should allow a user to add a product to the cart', () => { | ||
homePage.clickOnLaptops() | ||
homePage.clickOnProduct(testData.productName) | ||
homePage.addToCart() | ||
|
||
cy.on('window:alert', (alertText) => { | ||
expect(alertText).to.contains(testData.successMessage) | ||
}) | ||
|
||
}); | ||
homePage.clickOnCart() | ||
cartPage.assertProductInCart(testData.productName) | ||
|
||
it('', () => { | ||
cartPage.clickOnPlaceOrder() | ||
cartPage.fillOrderDetails( | ||
testData.name, | ||
testData.country, | ||
testData.city, | ||
testData.creditCard, | ||
testData.month, | ||
testData.year | ||
) | ||
cartPage.clickOnPurchase() | ||
|
||
}); | ||
}); | ||
cartPage.assertModalData( | ||
testData.name, | ||
testData.country, | ||
testData.city, | ||
testData.creditCard, | ||
testData.month, | ||
testData.year | ||
) | ||
cartPage.clickOnOk() | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import ContactFormPageObject from '../support/pages/contactForm.pageObject'; | ||
import HomeAndCataloguePageObject | ||
from '../support/pages/homeCatalogue.pageObject'; | ||
import faker from 'faker'; | ||
/* eslint-disable */ | ||
import { faker } from '@faker-js/faker' | ||
import ContactFormPageObject from '../support/pages/contactForm.pageObject' | ||
import HomeAndCataloguePageObject from '../support/pages/homeСatalogue.pageObject' | ||
/// <reference types='cypress' /> | ||
|
||
const contactForm = new ContactFormPageObject(); | ||
const homePage = new HomeAndCataloguePageObject(); | ||
const contactForm = new ContactFormPageObject() | ||
const homePage = new HomeAndCataloguePageObject() | ||
|
||
const testData = { | ||
email: faker.internet.email(), | ||
name: faker.name.firstName(), | ||
message: faker.random.words(), | ||
successMessage: 'Thanks for the message!!' | ||
}; | ||
successMessage: 'Thanks for the message!!', | ||
} | ||
|
||
describe('Contact', () => { | ||
before(() => { | ||
homePage.visit(); | ||
}); | ||
homePage.visit() | ||
}) | ||
|
||
it('should provide the ability to send feedback', () => { | ||
homePage.clickOnLink('Contact'); | ||
contactForm.typeEmail(testData.email); | ||
contactForm.typeName(testData.name); | ||
contactForm.typeMessage(testData.message); | ||
contactForm.clickOnSendMessageBtn(); | ||
homePage.clickOnLink('Contact') | ||
contactForm.typeEmail(testData.email) | ||
contactForm.typeName(testData.name) | ||
contactForm.typeMessage(testData.message) | ||
contactForm.clickOnSendMessageBtn() | ||
|
||
contactForm.assertAllert(testData.successMessage); | ||
}); | ||
}); | ||
contactForm.assertAllert(testData.successMessage) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* eslint-disable */ | ||
|
||
import PageObject from '../PageObject' | ||
|
||
class CartPageObject { | ||
assertProductInCart(productName) { | ||
cy.contains('td', productName).should('be.visible') | ||
} | ||
|
||
clickOnPlaceOrder() { | ||
cy.contains('Place Order').click() | ||
} | ||
|
||
fillOrderDetails(name, country, city, creditCard, month, year) { | ||
cy.get('input[id^="name"]').type(name) | ||
cy.get('input[id^="country"]').type(country) | ||
cy.get('input[id^="city"]').type(city) | ||
cy.get('input[id^="card"]').type(creditCard) | ||
cy.get('input[id^="month"]').type(month) | ||
cy.get('input[id^="year"]').type(year) | ||
} | ||
|
||
clickOnPurchase() { | ||
cy.contains('Purchase').click() | ||
} | ||
|
||
assertModalData(name, country, city, creditCard, month, year) { | ||
cy.contains('Id').should('be.visible') | ||
cy.contains('Amount').should('be.visible') | ||
cy.contains('Card Number').should('be.visible') | ||
cy.contains('Name').should('exist') | ||
cy.contains('Date').should('be.visible') | ||
cy.contains('Country').should('be.visible') | ||
} | ||
Comment on lines
+27
to
+34
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 |
||
|
||
clickOnOk() { | ||
cy.contains('OK').click() | ||
} | ||
} | ||
|
||
export default CartPageObject |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
import PageObject from '../PageObject'; | ||
/* eslint-disable */ | ||
import PageObject from '../PageObject' | ||
|
||
class ContactFormPageObject extends PageObject { | ||
url = '/index.html'; | ||
url = '/index.html' | ||
|
||
get emailField() { | ||
return cy.get('#recipient-email'); | ||
return cy.get('#recipient-email') | ||
} | ||
|
||
get nameField() { | ||
return cy.get('#recipient-name'); | ||
return cy.get('#recipient-name') | ||
} | ||
|
||
get messageField() { | ||
return cy.get('#message-text'); | ||
return cy.get('#message-text') | ||
} | ||
|
||
get sendMessageBtn() { | ||
return cy.contains('.btn', 'Send message'); | ||
return cy.contains('.btn', 'Send message') | ||
} | ||
|
||
typeEmail(email) { | ||
this.emailField.type(email, { force: true }); | ||
this.emailField.type(email, { force: true }) | ||
} | ||
|
||
typeName(name) { | ||
this.nameField.type(name, { force: true }); | ||
this.nameField.type(name, { force: true }) | ||
} | ||
|
||
typeMessage(message) { | ||
this.messageField.type(message); | ||
this.messageField.type(message) | ||
} | ||
|
||
clickOnSendMessageBtn() { | ||
this.sendMessageBtn.click(); | ||
this.sendMessageBtn.click() | ||
} | ||
} | ||
|
||
export default ContactFormPageObject; | ||
export default ContactFormPageObject |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
import PageObject from '../PageObject'; | ||
/* eslint-disable */ | ||
|
||
import PageObject from '../PageObject' | ||
|
||
class HomeAndCataloguePageObject extends PageObject { | ||
url = '/index.html'; | ||
url = '/index.html' | ||
|
||
clickOnLink(linkName) { | ||
cy.contains('.nav-link', linkName) | ||
.click(); | ||
cy.contains('.nav-link', linkName).click() | ||
} | ||
|
||
clickOnCategory(categoryName) { | ||
cy.contains('#itemc', categoryName) | ||
.click(); | ||
cy.contains('#itemc', categoryName).click() | ||
} | ||
|
||
clickOnProduct(product) { | ||
cy.contains('.hrefch', product) | ||
.click(); | ||
cy.contains('.hrefch', product).click() | ||
} | ||
|
||
clickOnLaptops() { | ||
cy.contains('Laptops').click() | ||
} | ||
} | ||
|
||
export default HomeAndCataloguePageObject; | ||
addToCart() { | ||
cy.contains('Add to cart').click() | ||
} | ||
|
||
clickOnCart() { | ||
cy.contains('Cart').click() | ||
} | ||
} | ||
export default HomeAndCataloguePageObject |
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 method
faker.date.future
does not exist in the Faker.js library. You should use a valid method to generate a future year, such asnew Date().getFullYear() + 5
to get a year 5 years in the future.