Skip to content

Commit

Permalink
Merge pull request #34237 from Progi1984/byeByePPV1
Browse files Browse the repository at this point in the history
Functional Tests : Removed Product Page v1
  • Loading branch information
boubkerbribri committed Oct 19, 2023
2 parents 6483032 + 8e9f918 commit ef067b2
Show file tree
Hide file tree
Showing 100 changed files with 2,176 additions and 4,632 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cron_nightly_tests_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ jobs:
CAMPAIGN: 'functional:FO:08-12'
- BRANCH: develop
CAMPAIGN: 'sanity:productV2'
- BRANCH: develop
CAMPAIGN: 'functional:productV2'

env:
GH_BRANCH: ${{ matrix.BRANCH }} # Branch to test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ import {createCurrencyTest, deleteCurrencyTest} from '@commonTests/BO/internatio
import {enableEcoTaxTest, disableEcoTaxTest} from '@commonTests/BO/international/ecoTax';
import loginCommon from '@commonTests/BO/loginBO';
import deleteNonOrderedShoppingCarts from '@commonTests/BO/orders/shoppingCarts';
import {
resetNewProductPageAsDefault,
setFeatureFlag,
} from '@commonTests/BO/advancedParameters/newFeatures';

// Import BO pages
import featureFlagPage from '@pages/BO/advancedParameters/featureFlag';
import productsPage from '@pages/BO/catalog/products';
import addProductPage from '@pages/BO/catalog/products/add';
import pricingTab from '@pages/BO/catalog/products/add/pricingTab';
import stocksPage from '@pages/BO/catalog/stocks';
import dashboardPage from '@pages/BO/dashboard';
import ordersPage from '@pages/BO/orders';
Expand Down Expand Up @@ -89,14 +85,15 @@ describe('BO - Orders - Create order : Add a product to the cart', async () => {
// Variable used for available stock of customized product
let availableStockCustomizedProduct: number = 0;
let createProductMessage: string|null = '';
let updateProductMessage: string|null = '';

const pastDate: string = date.getDateFormat('yyyy-mm-dd', 'past');
// Constant used to add a prefix to created products
const prefixNewProduct: string = 'TOTEST';
// Data to create pack of products with minimum quantity = 2
const packOfProducts: ProductData = new ProductData({
name: `Pack of products ${prefixNewProduct}`,
type: 'Pack of products',
type: 'pack',
pack: [
{
reference: 'demo_13',
Expand All @@ -118,7 +115,7 @@ describe('BO - Orders - Create order : Add a product to the cart', async () => {
// Data to create product out of stock allowed
const productOutOfStockAllowed: ProductData = new ProductData({
name: `Out of stock allowed ${prefixNewProduct}`,
type: 'Standard product',
type: 'standard',
taxRule: 'No tax',
quantity: -12,
minimumQuantity: 1,
Expand All @@ -128,7 +125,7 @@ describe('BO - Orders - Create order : Add a product to the cart', async () => {
// Data to create product out of stock not allowed
const productOutOfStockNotAllowed: ProductData = new ProductData({
name: `Out of stock not allowed ${prefixNewProduct}`,
type: 'Standard product',
type: 'standard',
taxRule: 'No tax',
quantity: -15,
minimumQuantity: 1,
Expand All @@ -138,7 +135,7 @@ describe('BO - Orders - Create order : Add a product to the cart', async () => {
// Data to create product with specific price
const productWithSpecificPrice: ProductData = new ProductData({
name: `Product with specific price ${prefixNewProduct}`,
type: 'Standard product',
type: 'standard',
taxRule: 'No tax',
quantity: 20,
specificPrice: {
Expand All @@ -151,7 +148,7 @@ describe('BO - Orders - Create order : Add a product to the cart', async () => {
// Data to create product with ecotax
const productWithEcoTax: ProductData = new ProductData({
name: `Product with ecotax ${prefixNewProduct}`,
type: 'Standard product',
type: 'standard',
taxRule: 'No tax',
quantity: 20,
minimumQuantity: 1,
Expand All @@ -160,7 +157,7 @@ describe('BO - Orders - Create order : Add a product to the cart', async () => {
// Data to create product with cart rule
const productWithCartRule: ProductData = new ProductData({
name: `Product with cart rule ${prefixNewProduct}`,
type: 'Standard product',
type: 'standard',
taxRule: 'No tax',
quantity: 50,
minimumQuantity: 1,
Expand Down Expand Up @@ -199,9 +196,6 @@ describe('BO - Orders - Create order : Add a product to the cart', async () => {
// Pre-condition: Create currency
createCurrencyTest(Currencies.mad, `${baseContext}_preTest_2`);

// Pre-condition: Disable new product page
setFeatureFlag(featureFlagPage.featureFlagProductPageV2, false, `${baseContext}_disableNewProduct`);

before(async function () {
browserContext = await helper.createBrowserContext(this.browser);
page = await helper.newTab(browserContext);
Expand Down Expand Up @@ -235,32 +229,70 @@ describe('BO - Orders - Create order : Add a product to the cart', async () => {
productWithEcoTax,
productWithCartRule,
].forEach((product: ProductData, index: number) => {
it('should go to add product page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToAddProductPage${index}`, baseContext);
if (index === 0) {
it('should click on \'New product\' button and check new product modal', async function () {
await testContext.addContextItem(this, 'testIdentifier', `clickOnNewProductButton${index}`, baseContext);

const isModalVisible = await productsPage.clickOnNewProductButton(page);
expect(isModalVisible).to.be.eq(true);
});

it(`should choose '${product.type} product'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `chooseStandardProduct${index}`, baseContext);

await productsPage.selectProductType(page, product.type);

if (index === 0) {
await productsPage.goToAddProductPage(page);
const pageTitle = await addProductPage.getPageTitle(page);
expect(pageTitle).to.contains(addProductPage.pageTitle);
});
}

it('should go to new product page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToNewProductPage${index}`, baseContext);

if (index !== 0) {
await addProductPage.clickOnNewProductButton(page);
} else {
await addProductPage.goToAddProductPage(page);
await productsPage.clickOnAddNewProduct(page);
}

const pageTitle = await addProductPage.getPageTitle(page);
expect(pageTitle).to.contains(addProductPage.pageTitle);
});

if (index !== 0) {
it(`should choose '${product.type} product'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `chooseStandardProduct${index}`, baseContext);

await addProductPage.chooseProductType(page, product.type);

const pageTitle = await addProductPage.getPageTitle(page);
expect(pageTitle).to.contains(addProductPage.pageTitle);
});
}

it(`create product '${product.name}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `createProduct${index}`, baseContext);

createProductMessage = await addProductPage.setProduct(page, product);
expect(createProductMessage).to.equal(addProductPage.successfulUpdateMessage);

// Add specific price
if (product === productWithSpecificPrice) {
await addProductPage.createEditBasicProduct(page, product);
createProductMessage = await addProductPage.addSpecificPrices(page, productWithSpecificPrice.specificPrice);
} else {
createProductMessage = await addProductPage.setProduct(page, product);
await addProductPage.goToTab(page, 'pricing');
await pricingTab.clickOnAddSpecificPriceButton(page);

createProductMessage = await pricingTab.setSpecificPrice(page, productWithSpecificPrice.specificPrice);
expect(createProductMessage).to.equal(addProductPage.successfulCreationMessage);
}
// Add eco tax
if (product === productWithEcoTax) {
await addProductPage.addEcoTax(page, productWithEcoTax.ecoTax);
await addProductPage.goToTab(page, 'pricing');
await pricingTab.addEcoTax(page, productWithEcoTax.ecoTax);

updateProductMessage = await addProductPage.saveProduct(page);
expect(updateProductMessage).to.equal(addProductPage.successfulUpdateMessage);
}
expect(createProductMessage).to.equal(addProductPage.settingUpdatedMessage);
});
});
});
Expand Down Expand Up @@ -674,7 +706,4 @@ describe('BO - Orders - Create order : Add a product to the cart', async () => {

// Post-condition: Delete cart rule
deleteCartRuleTest(newCartRuleData.name, `${baseContext}_postTest_4`);

// Post-condition: Reset initial state
resetNewProductPageAsDefault(`${baseContext}_resetNewProduct`);
});

0 comments on commit ef067b2

Please sign in to comment.