Skip to content

Commit

Permalink
Merge pull request PrestaShop#29802 from khouloudbelguith/refactoBulk…
Browse files Browse the repository at this point in the history
…DuplicateProducts

Functional tests - Refacto BO - bulk duplicate products
  • Loading branch information
kpodemski authored Nov 10, 2022
2 parents af9f677 + c0283a6 commit c1a4ad6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ let browserContext;
let page;

let numberOfProducts = 0;
let numberOfFilteredProductsAfterDuplicate = 0;

/*
Go to products page
Create 2 products
Enable/Disable/Delete products by bulk actions
Enable/Disable/Duplicate/Delete products by bulk actions
*/

describe('BO - Catalog - Products : Bulk actions products', async () => {
Expand Down Expand Up @@ -131,6 +132,38 @@ describe('BO - Catalog - Products : Bulk actions products', async () => {
});
});

describe('Bulk duplicate products', async () => {
it('should filter products by name', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'filterToBulkDuplicate', baseContext);

await productsPage.filterProducts(page, 'name', 'TO DELETE');

const textColumn = await productsPage.getProductNameFromList(page, 1);
await expect(textColumn).to.contains('TO DELETE');
});

it('should duplicate products by bulk actions', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'bulkDuplicate', baseContext);

const duplicateTextResult = await productsPage.duplicateAllProductsWithBulkActions(page);
await expect(duplicateTextResult).to.equal(productsPage.productMultiDuplicatedSuccessfulMessage);


numberOfFilteredProductsAfterDuplicate = await productsPage.getNumberOfProductsFromList(page);
await expect(numberOfFilteredProductsAfterDuplicate).to.be.below(numberOfProducts);
});

it('should reset all filters', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'resetAfterBulkDuplicate', baseContext);

const numberOfProductsAfterDuplicate = await productsPage.resetAndGetNumberOfLines(page);
await expect(numberOfProductsAfterDuplicate)
.to
.be
.equal(numberOfProducts + numberOfFilteredProductsAfterDuplicate);
});
});

describe('Bulk delete products', async () => {
it('should filter products by name', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'filterToBulkDelete', baseContext);
Expand Down
19 changes: 19 additions & 0 deletions tests/UI/pages/BO/catalog/products/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Products extends BOBasePage {
this.productActivatedSuccessfulMessage = 'Product successfully activated.';
this.productMultiActivatedSuccessfulMessage = 'Product(s) successfully activated.';
this.productMultiDeactivatedSuccessfulMessage = 'Product(s) successfully deactivated.';
this.productMultiDuplicatedSuccessfulMessage = 'Product(s) successfully duplicated.';

// Selectors
// List of products
Expand All @@ -43,6 +44,7 @@ class Products extends BOBasePage {
this.productBulkDeleteLink = `${this.productBulkDropdownMenu} a[onclick*='delete_all']`;
this.productBulkEnableLink = `${this.productBulkDropdownMenu} a[onclick*='activate_all']`;
this.productBulkDisableLink = `${this.productBulkDropdownMenu} a[onclick*='deactivate_all']`;
this.productBulkDuplicateLink = `${this.productBulkDropdownMenu} a[onclick*='duplicate_all']`;

// Filters input
this.productFilterIDMinInput = `${this.productListForm} #filter_column_id_product_min`;
Expand Down Expand Up @@ -524,6 +526,23 @@ class Products extends BOBasePage {
return this.getAlertSuccessBlockParagraphContent(page);
}

/**
* Duplicate all products with Bulk Actions
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
async duplicateAllProductsWithBulkActions(page) {
await this.selectAllProducts(page);

await Promise.all([
this.waitForVisibleSelector(page, this.productBulkMenuButtonState('true')),
page.click(this.productBulkMenuButton),
]);

await this.clickAndWaitForNavigation(page, this.productBulkDuplicateLink);
return this.getAlertSuccessBlockParagraphContent(page);
}

/**
* Bulk set status
* @param page {Page} Browser tab
Expand Down

0 comments on commit c1a4ad6

Please sign in to comment.