Skip to content

Commit

Permalink
Rebase and adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nesrineabdmouleh committed Nov 14, 2024
1 parent 311ef7c commit 11263aa
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 71 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ui-test/sanity.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"include": [
{
"comment": "1.7.0.6 -> 1.7.8.11 PHP 7.1 online"
},
{
"PS_VERSION_START": "1.7.0.6",
"PS_VERSION_END": "1.7.8.11",
"PHP_VERSION": "7.1",
"UPGRADE_CHANNEL": "online"
},
{
"comment": "1.7.6.0 -> 1.7.8.11 PHP 7.1 online"
},
Expand Down
57 changes: 38 additions & 19 deletions tests/UI/campaigns/sanity/02_productsBO/01_filterProducts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,25 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name,
expect(isVisible, 'Reset button is visible!').toEqual(false);
});

if (semver.lt(psVersion, '8.1.0') || isProductPageV1) {
test('should get the number of products', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'getNumberOfProduct', baseContext);
test('should get the number of products', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'getNumberOfProduct', baseContext);

if (semver.lt(psVersion, '8.1.0') || isProductPageV1) {
numberOfProducts = await boProductsPage.getNumberOfProductsFromList(page);
expect(numberOfProducts).toBeGreaterThan(0);
});
} else {
test('should get number of products', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'getNumberOfProduct', baseContext);

} else {
numberOfProducts = await boProductsPage.getNumberOfProductsFromHeader(page);
expect(numberOfProducts).toBeGreaterThan(0);
});
}
}
expect(numberOfProducts).toBeGreaterThan(0);
});

[
const data = [
{
args: {
identifier: 'filterIDMinMax',
filterBy: 'id_product',
filterValue: {min: 5, max: 10},
// For PS version <= 1.7.2
oldFilterValue: {min: 3, max: 7},
filterType: 'input',
},
},
Expand All @@ -151,6 +148,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name,
identifier: 'filterName',
filterBy: 'product_name',
filterValue: dataProducts.demo_14.name,
// For PS version <= 1.7.2
oldFilterValue: dataProducts.old_demo_4.name,
filterType: 'input',
},
},
Expand All @@ -159,6 +158,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name,
identifier: 'filterReference',
filterBy: 'reference',
filterValue: dataProducts.demo_14.reference,
// For PS version <= 1.7.2
oldFilterValue: dataProducts.old_demo_7.reference,
filterType: 'input',
},
},
Expand All @@ -167,6 +168,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name,
identifier: 'filterCategory',
filterBy: 'category',
filterValue: dataCategories.art.name,
// For PS version <= 1.7.2
oldFilterValue: dataProducts.old_demo_3.category,
filterType: 'input',
},
},
Expand All @@ -175,6 +178,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name,
identifier: 'filterPriceMinMax',
filterBy: 'price',
filterValue: {min: 5, max: 10},
// For PS version <= 1.7.2
oldFilterValue: {min: 20, max: 30},
filterType: 'input',
},
},
Expand All @@ -183,6 +188,8 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name,
identifier: 'filterQuantityMinMax',
filterBy: 'quantity',
filterValue: {min: 1300, max: 1500},
// For PS version <= 1.7.2
oldFilterValue: {min: 900, max: 1500},
filterType: 'input',
},
},
Expand All @@ -191,17 +198,29 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name,
identifier: 'filterStatus',
filterBy: 'active',
filterValue: 'Yes',
// For PS version <= 1.7.2
oldFilterValue: 'Yes',
filterType: 'select',
},
},
].forEach((tst) => {
test(`should filter list by '${tst.args.filterBy}' and check result`, async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', `${tst.args.identifier}`, baseContext);

let filterValue: any = '';

if (numberOfProducts > 7) {
// For PS version > 1.7.2
filterValue = tst.args.filterValue;
} else {
// For PS version <= 1.7.2
filterValue = tst.args.oldFilterValue
}

if (semver.lt(psVersion, '8.1.0') && tst.args.filterBy === 'active') {
await boProductsPage.filterProducts(page, tst.args.filterBy, 'Active', tst.args.filterType);
} else {
await boProductsPage.filterProducts(page, tst.args.filterBy, tst.args.filterValue, tst.args.filterType);
await boProductsPage.filterProducts(page, tst.args.filterBy, filterValue, tst.args.filterType);
}
const numberOfProductsAfterFilter = await boProductsPage.getNumberOfProductsFromList(page);

Expand All @@ -214,20 +233,20 @@ test.describe('BO - Catalog - Products : Filter the products table by ID, Name,
for (let i = 1; i <= numberOfProductsAfterFilter; i++) {
const textColumn = await boProductsPage.getTextColumn(page, tst.args.filterBy, i);

if (typeof tst.args.filterValue !== 'string') {
expect(textColumn).toBeGreaterThanOrEqual(tst.args.filterValue.min);
expect(textColumn).toBeLessThanOrEqual(tst.args.filterValue.max);
if (typeof filterValue !== 'string') {
expect(textColumn).toBeGreaterThanOrEqual(filterValue.min);
expect(textColumn).toBeLessThanOrEqual(filterValue.max);
} else if (tst.args.filterBy === 'active') {
expect(textColumn).toEqual(true);
} else {
expect(textColumn).toContain(tst.args.filterValue);
expect(textColumn).toContain(filterValue);
}
}
});

test(`should reset filter by '${tst.args.filterBy}'`, async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', `resetFilter${tst.args.identifier}`, baseContext);

const numberOfProductsAfterReset = await boProductsPage.resetAndGetNumberOfLines(page);
expect(numberOfProductsAfterReset).toEqual(numberOfProducts);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ test.describe('BO - Catalog - Products : CRUD standard product', async () => {
});

// @todo : https://github.com/PrestaShop/PrestaShop/issues/36097
if (semver.lte(psVersion, '8.1.6')) {
if (semver.lte(psVersion, '8.1.6') && semver.gte(psVersion, '7.3.0')) {
test('should close the menu', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'closeMenu', baseContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async
},
{
name: 'size',
values: ['L', 'XL'],
values: ['L'],
},
],
});
Expand Down Expand Up @@ -103,7 +103,7 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async
});

// @todo : https://github.com/PrestaShop/PrestaShop/issues/36097
if (semver.lte(psVersion, '8.1.6')) {
if (semver.lte(psVersion, '8.1.6') && semver.gte(psVersion, '7.3.0')) {
test('should close the menu', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'closeMenu', baseContext);

Expand Down Expand Up @@ -248,7 +248,7 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async
);

if (semver.gte(psVersion, '8.1.0')) {
expect(textResult).toEqual('Generate 6 combinations');
expect(textResult).toEqual('Generate 3 combinations');
} else {
expect(textResult).toEqual(boProductsCreatePage.successfulUpdateMessage);
}
Expand All @@ -259,7 +259,7 @@ test.describe('BO - Catalog - Products : CRUD product with combinations', async
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'generateCombinations2', baseContext);

const successMessage = await boProductsCreateTabCombinationsPage.generateCombinations(page);
expect(successMessage).toEqual('Successfully generated 6 combinations.');
expect(successMessage).toEqual('Successfully generated 3 combinations.');
});

test('should check that combinations generation modal is closed', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test.describe('BO - Catalog - Products : CRUD virtual product', async () => {
});

// @todo : https://github.com/PrestaShop/PrestaShop/issues/36097
if (semver.lte(psVersion, '8.1.6')) {
if (semver.lte(psVersion, '8.1.6') && semver.gte(psVersion, '7.3.0')) {
test('should close the menu', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'closeMenu', baseContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ test.describe('BO - Catalog - Products : Delete product', async () => {
});

// @todo : https://github.com/PrestaShop/PrestaShop/issues/36097
if (semver.lte(psVersion, '8.1.6')) {
if (semver.lte(psVersion, '8.1.6') && semver.gte(psVersion, '7.3.0')) {
test('should close the menu', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'closeMenu', baseContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ test.describe('BO - Catalog - Products : Delete products with bulk actions', asy
});

// @todo : https://github.com/PrestaShop/PrestaShop/issues/36097
if (semver.lte(psVersion, '8.1.6')) {
if (semver.lte(psVersion, '8.1.6') && semver.gte(psVersion, '7.3.0')) {
test('should close the menu', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'closeMenu', baseContext);

Expand Down
31 changes: 22 additions & 9 deletions tests/UI/campaigns/sanity/03_catalogFO/01_filterProducts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,37 @@ test.describe('FO - Catalog : Filter Products by categories in Home page', async
expect(allProductsNumber).toBeGreaterThan(0);
});

test('should filter products by the category \'Accessories\' and check result', async () => {
test('should filter products by category and check result', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'FilterProductByCategory', baseContext);

await foClassicCategoryPage.goToCategory(page, dataCategories.accessories.id);
if (allProductsNumber > 7) {
await foClassicCategoryPage.goToCategory(page, dataCategories.accessories.id);

const pageTitle = await foClassicCategoryPage.getPageTitle(page);
expect(pageTitle).toEqual(dataCategories.accessories.name);
const pageTitle = await foClassicCategoryPage.getPageTitle(page);
expect(pageTitle).toEqual(dataCategories.accessories.name);

const numberOfProducts = await foClassicCategoryPage.getNumberOfProducts(page);
expect(numberOfProducts).toBeLessThan(allProductsNumber);
const numberOfProducts = await foClassicCategoryPage.getNumberOfProducts(page);
expect(numberOfProducts).toBeLessThan(allProductsNumber);
} else {
await foClassicCategoryPage.goToCategory(page, dataCategories.oldWomen.id);

const pageTitle = await foClassicCategoryPage.getPageTitle(page);
expect(pageTitle).toEqual(dataCategories.oldWomen.name);

const numberOfProducts = await foClassicCategoryPage.getNumberOfProducts(page);
expect(numberOfProducts).toEqual(allProductsNumber);
}
});

test('should filter products by the subcategory \'Stationery\' and check result', async () => {
test('should filter products by the subcategory and check result', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'FilterProductBySubCategory', baseContext);

await foClassicCategoryPage.reloadPage(page);
await foClassicCategoryPage.goToSubCategory(page, dataCategories.accessories.id, dataCategories.stationery.id);

if (allProductsNumber > 7) {
await foClassicCategoryPage.goToSubCategory(page, dataCategories.accessories.id, dataCategories.stationery.id);
} else {
await foClassicCategoryPage.goToSubCategory(page, dataCategories.oldWomen.id, dataCategories.eveningDresses.id);
}
const numberOfProducts = await foClassicCategoryPage.getNumberOfProducts(page);
expect(numberOfProducts).toBeLessThan(allProductsNumber);
});
Expand Down
20 changes: 14 additions & 6 deletions tests/UI/campaigns/sanity/03_catalogFO/02_checkProduct.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,25 @@ test.describe('FO - Catalog : Check the Product page', async () => {
await foClassicHomePage.goToProductPage(page, 1);

const pageTitle = await foClassicProductPage.getPageTitle(page);
expect(pageTitle).toContain(dataProducts.demo_1.name);
expect(pageTitle).toBeDefined();
});

test('should check the product page', async () => {
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkProductPage', baseContext);

const result = await foClassicProductPage.getProductInformation(page);
await Promise.all([
expect(result.name).toEqual(dataProducts.demo_1.name),
expect(result.price).toEqual(dataProducts.demo_1.finalPrice),
expect(result.description).toContain(dataProducts.demo_1.description),
]);
if (result.name === dataProducts.demo_1.name) {
await Promise.all([
expect(result.name).toEqual(dataProducts.demo_1.name),
expect(result.price).toEqual(dataProducts.demo_1.finalPrice),
expect(result.description).toContain(dataProducts.demo_1.description),
]);
} else {
await Promise.all([
expect(result.name).toEqual(dataProducts.old_demo_1.name),
expect(result.price).toEqual(dataProducts.old_demo_1.finalPrice),
expect(result.description).toContain(dataProducts.old_demo_1.description),
]);
}
});
});
Loading

0 comments on commit 11263aa

Please sign in to comment.