forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request PrestaShop#35959 from nesrineabdmouleh/TEST-6970
Functional tests - Add new test to edit quantity in product page (Classic & Hummingbird)
- Loading branch information
Showing
5 changed files
with
361 additions
and
11 deletions.
There are no files selected for viewing
141 changes: 141 additions & 0 deletions
141
tests/UI/campaigns/functional/FO/classic/09_productPage/02_productPage/02_changeQuantity.ts
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,141 @@ | ||
// Import utils | ||
import helper from '@utils/helpers'; | ||
import testContext from '@utils/testContext'; | ||
|
||
// Import pages | ||
import {homePage} from '@pages/FO/classic/home'; | ||
import {productPage} from '@pages/FO/classic/product'; | ||
import {blockCartModal} from '@pages/FO/classic/modal/blockCart'; | ||
import {cartPage} from '@pages/FO/classic/cart'; | ||
|
||
// Import data | ||
import Products from '@data/demo/products'; | ||
|
||
import {expect} from 'chai'; | ||
import type {BrowserContext, Page} from 'playwright'; | ||
|
||
const baseContext: string = 'functional_FO_classic_productPage_productPage_changeQuantity'; | ||
|
||
/* | ||
Scenario: | ||
- Go to FO | ||
- Go to the third product in the list | ||
- Click up/down on quantity input | ||
- Set quantity input (good/bad value) | ||
*/ | ||
describe('FO - Product page : Change quantity', async () => { | ||
let browserContext: BrowserContext; | ||
let page: Page; | ||
|
||
// before and after functions | ||
before(async function () { | ||
browserContext = await helper.createBrowserContext(this.browser); | ||
page = await helper.newTab(browserContext); | ||
}); | ||
|
||
after(async () => { | ||
await helper.closeBrowserContext(browserContext); | ||
}); | ||
|
||
it('should go to FO home page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToFo', baseContext); | ||
|
||
await homePage.goToFo(page); | ||
|
||
const isHomePage = await homePage.isHomePage(page); | ||
expect(isHomePage).to.equal(true); | ||
}); | ||
|
||
it('should go to the third product page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToProductPage', baseContext); | ||
|
||
await homePage.goToProductPage(page, 3); | ||
|
||
const pageTitle = await productPage.getPageTitle(page); | ||
expect(pageTitle.toUpperCase()).to.contains(Products.demo_6.name.toUpperCase()); | ||
}); | ||
|
||
it('should change the quantity by using the arrow \'UP\' button', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'incrementQuantity', baseContext); | ||
|
||
await productPage.setQuantityByArrowUpDown(page, 5, 'up'); | ||
|
||
const productQuantity = await productPage.getProductQuantity(page); | ||
expect(productQuantity).to.equal(5); | ||
}); | ||
|
||
it('should change the quantity by using the arrow \'Down\' button', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'incrementQuantity2', baseContext); | ||
|
||
await productPage.setQuantityByArrowUpDown(page, 1, 'down'); | ||
|
||
const productQuantity = await productPage.getProductQuantity(page); | ||
expect(productQuantity).to.equal(1); | ||
}); | ||
|
||
it('should add quantity of the product by setting input value', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'updateQuantityByInput', baseContext); | ||
|
||
await productPage.setQuantity(page, 12); | ||
await productPage.clickOnAddToCartButton(page); | ||
|
||
const isVisible = await blockCartModal.isBlockCartModalVisible(page); | ||
expect(isVisible).to.equal(true); | ||
}); | ||
|
||
it('should click on continue shopping and check that the modal is not visible', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'clickOnContinueShopping', baseContext); | ||
|
||
const isNotVisible = await blockCartModal.continueShopping(page); | ||
expect(isNotVisible).to.equal(true); | ||
}); | ||
|
||
it('should check the cart notifications number', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'checkNotificationsNumber', baseContext); | ||
|
||
const notificationsNumber = await productPage.getCartNotificationsNumber(page); | ||
expect(notificationsNumber).to.equal(12); | ||
}); | ||
|
||
it('should set \'-24\' in the quantity input', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'updateQuantityByInput2', baseContext); | ||
|
||
await productPage.setQuantity(page, '-24'); | ||
await productPage.clickOnAddToCartButton(page); | ||
|
||
const isVisible = await blockCartModal.isBlockCartModalVisible(page); | ||
expect(isVisible).to.equal(true); | ||
}); | ||
|
||
it('should click on continue shopping and check that the modal is not visible', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'clickOnContinueShopping2', baseContext); | ||
|
||
const isNotVisible = await blockCartModal.continueShopping(page); | ||
expect(isNotVisible).to.equal(true); | ||
}); | ||
|
||
it('should check the cart notifications number', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'checkNotificationsNumber2', baseContext); | ||
|
||
const notificationsNumber = await homePage.getCartNotificationsNumber(page); | ||
expect(notificationsNumber).to.equal(13); | ||
}); | ||
|
||
it('should set \'Prestashop\' in the quantity input and proceed to checkout', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'updateQuantityByInput3', baseContext); | ||
|
||
await productPage.addProductToTheCart(page, 'Prestashop'); | ||
|
||
const notificationsNumber = await homePage.getCartNotificationsNumber(page); | ||
expect(notificationsNumber).to.equal(14); | ||
}); | ||
|
||
it('should remove product from shopping cart', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'removeProduct', baseContext); | ||
|
||
await cartPage.deleteProduct(page, 1); | ||
|
||
const notificationNumber = await cartPage.getCartNotificationsNumber(page); | ||
expect(notificationNumber).to.equal(0); | ||
}); | ||
}); |
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
171 changes: 171 additions & 0 deletions
171
...UI/campaigns/functional/FO/hummingbird/09_productPage/02_productPage/02_changeQuantity.ts
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,171 @@ | ||
// Import utils | ||
import helper from '@utils/helpers'; | ||
import testContext from '@utils/testContext'; | ||
|
||
// Import common tests | ||
import {installHummingbird, uninstallHummingbird} from '@commonTests/BO/design/hummingbird'; | ||
|
||
// Import pages | ||
import homePage from '@pages/FO/hummingbird/home'; | ||
import productPage from '@pages/FO/hummingbird/product'; | ||
import blockCartModal from '@pages/FO/hummingbird/modal/blockCart'; | ||
import cartPage from '@pages/FO/hummingbird/cart'; | ||
|
||
// Import data | ||
import Products from '@data/demo/products'; | ||
|
||
import {expect} from 'chai'; | ||
import type {BrowserContext, Page} from 'playwright'; | ||
|
||
const baseContext: string = 'functional_FO_hummingbird_productPage_productPage_changeQuantity'; | ||
|
||
/* | ||
Pre-condition: | ||
- Install hummingbird theme | ||
Scenario: | ||
- Go to FO | ||
- Go to the third product in the list | ||
- Click up/down on quantity input | ||
- Set quantity input (good/bad value) | ||
Post-condition: | ||
- Uninstall hummingbird theme | ||
*/ | ||
describe('FO - Product page : Change quantity', async () => { | ||
let browserContext: BrowserContext; | ||
let page: Page; | ||
|
||
// Pre-condition : Install Hummingbird | ||
installHummingbird(`${baseContext}_preTest`); | ||
|
||
// before and after functions | ||
before(async function () { | ||
browserContext = await helper.createBrowserContext(this.browser); | ||
page = await helper.newTab(browserContext); | ||
}); | ||
|
||
after(async () => { | ||
await helper.closeBrowserContext(browserContext); | ||
}); | ||
|
||
describe('Change quantity from product page', async () => { | ||
it('should go to FO home page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToFo', baseContext); | ||
|
||
await homePage.goToFo(page); | ||
|
||
const isHomePage = await homePage.isHomePage(page); | ||
expect(isHomePage).to.equal(true); | ||
}); | ||
|
||
it('should go to the third product page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToProductPage', baseContext); | ||
|
||
await homePage.goToProductPage(page, 3); | ||
|
||
const pageTitle = await productPage.getPageTitle(page); | ||
expect(pageTitle.toUpperCase()).to.contains(Products.demo_6.name.toUpperCase()); | ||
}); | ||
|
||
it('should change the quantity by using the arrow \'Down\' button', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'decrement', baseContext); | ||
|
||
await productPage.setQuantityByArrowUpDown(page, 1, 'down'); | ||
|
||
const productQuantity = await productPage.getProductQuantity(page); | ||
expect(productQuantity).to.equal(1); | ||
}); | ||
|
||
it('should change the quantity by using the arrow \'UP\' button', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'incrementQuantity', baseContext); | ||
|
||
await productPage.setQuantityByArrowUpDown(page, 2, 'increment'); | ||
|
||
const productQuantity = await productPage.getProductQuantity(page); | ||
expect(productQuantity).to.equal(2); | ||
}); | ||
|
||
it('should click on add to cart button then on continue shopping button', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'clickOnAddToCartButton', baseContext); | ||
|
||
await productPage.clickOnAddToCartButton(page); | ||
|
||
const isNotVisible = await blockCartModal.continueShopping(page); | ||
expect(isNotVisible).to.equal(true); | ||
}); | ||
|
||
// @todo : https://github.com/PrestaShop/hummingbird/pull/600 | ||
it('should set the quantity 0 and check that the add to cart button is disabled', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'checkAddToCartButtonIsDisabled', baseContext); | ||
|
||
this.skip(); | ||
await productPage.setQuantity(page, 0); | ||
|
||
const isButtonDisabled = await productPage.isAddToCartButtonEnabled(page); | ||
expect(isButtonDisabled).to.equal(false); | ||
}); | ||
|
||
it('should add quantity of the product by setting input value', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'updateQuantityByInput', baseContext); | ||
|
||
// @todo : https://github.com/PrestaShop/hummingbird/issues/615 | ||
await productPage.reloadPage(page); | ||
|
||
await productPage.setQuantity(page, 12); | ||
await productPage.clickOnAddToCartButton(page); | ||
|
||
const isVisible = await blockCartModal.isBlockCartModalVisible(page); | ||
expect(isVisible).to.equal(true); | ||
}); | ||
|
||
it('should click on continue shopping and check that the modal is not visible', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'clickOnContinueShopping', baseContext); | ||
|
||
const isNotVisible = await blockCartModal.continueShopping(page); | ||
expect(isNotVisible).to.equal(true); | ||
}); | ||
|
||
it('should check the cart notifications number', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'checkNotificationsNumber', baseContext); | ||
|
||
const notificationsNumber = await productPage.getCartNotificationsNumber(page); | ||
expect(notificationsNumber).to.equal(14); | ||
}); | ||
|
||
// @todo : https://github.com/PrestaShop/hummingbird/pull/600 | ||
it('should set \'-24\' in the quantity input', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'updateQuantityByInput2', baseContext); | ||
|
||
this.skip(); | ||
await productPage.setQuantity(page, '-24'); | ||
|
||
const isButtonDisabled = await productPage.isAddToCartButtonEnabled(page); | ||
expect(isButtonDisabled).to.equal(false); | ||
}); | ||
|
||
it('should set \'Prestashop\' in the quantity input and proceed to checkout', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'updateQuantityByInput3', baseContext); | ||
|
||
// @todo : https://github.com/PrestaShop/hummingbird/issues/615 | ||
await productPage.reloadPage(page); | ||
|
||
await productPage.setQuantity(page, 'Prestashop'); | ||
await productPage.clickOnAddToCartButton(page); | ||
|
||
const errorAlert = await productPage.getWarningMessage(page); | ||
expect(errorAlert).to.equal('Null quantity.'); | ||
}); | ||
|
||
it('should remove product from shopping cart', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'removeProduct', baseContext); | ||
|
||
await productPage.goToCartPage(page); | ||
await cartPage.deleteProduct(page, 1); | ||
|
||
const notificationNumber = await cartPage.getCartNotificationsNumber(page); | ||
expect(notificationNumber).to.equal(0); | ||
}); | ||
}); | ||
|
||
// Post-condition : Uninstall Hummingbird | ||
uninstallHummingbird(`${baseContext}_postTest`); | ||
}); |
Oops, something went wrong.