From 60dfed80ccfe524789e02e129c7513d64d1a0e31 Mon Sep 17 00:00:00 2001 From: shashwata Date: Tue, 8 Oct 2024 10:21:53 +0600 Subject: [PATCH] Fix: conflict issues --- tests/pw/pages/productsPage.ts | 93 +++++-------------- tests/pw/tests/e2e/productsDetails.spec.ts | 4 +- .../pw/tests/e2e/requestForQuoteRules.spec.ts | 2 +- 3 files changed, 25 insertions(+), 74 deletions(-) diff --git a/tests/pw/pages/productsPage.ts b/tests/pw/pages/productsPage.ts index 6213204877..7a09e36ef4 100644 --- a/tests/pw/pages/productsPage.ts +++ b/tests/pw/pages/productsPage.ts @@ -1149,55 +1149,6 @@ export class ProductsPage extends AdminPage { } } - // add product other options (product status, visibility, purchase note, reviews) - async addProductOtherOptions(productName: string, otherOption: product['productInfo']['otherOptions'], choice: string): Promise { - await this.goToProductEdit(productName); - - switch (choice) { - case 'status': - await this.selectByValue(productsVendor.otherOptions.productStatus, otherOption.status); - break; - case 'visibility': - await this.selectByValue(productsVendor.otherOptions.visibility, otherOption.visibility); - break; - case 'purchaseNote': - await this.clearAndType(productsVendor.otherOptions.purchaseNote, otherOption.purchaseNote); - break; - case 'reviews': - if (otherOption.enableReview) { - await this.check(productsVendor.otherOptions.enableProductReviews); - } else { - await this.uncheck(productsVendor.otherOptions.enableProductReviews); - } - break; - default: - break; - } - - await this.saveProduct(); - - switch (choice) { - case 'status': - await this.toHaveSelectedValue(productsVendor.otherOptions.productStatus, otherOption.status); - break; - case 'visibility': - await this.toHaveSelectedValue(productsVendor.otherOptions.visibility, otherOption.visibility); - break; - case 'purchaseNote': - await this.toHaveValue(productsVendor.otherOptions.purchaseNote, otherOption.purchaseNote); - break; - case 'reviews': - if (otherOption.enableReview) { - await this.toBeChecked(productsVendor.otherOptions.enableProductReviews); - } else { - await this.notToBeChecked(productsVendor.otherOptions.enableProductReviews); - } - break; - default: - break; - } - } - // add product catalog mode async addProductCatalogMode(productName: string, hidePrice: boolean = false): Promise { await this.goToProductEdit(productName); @@ -1269,17 +1220,17 @@ export class ProductsPage extends AdminPage { await this.goToProductEdit(productName); switch (choice) { case 'up-sells': - for (const product of linkedProducts.upSells) { - await this.typeAndWaitForResponse(data.subUrls.ajax, productsVendor.linkedProducts.upSells, product); - await this.click(productsVendor.linkedProducts.searchedResult(product)); - await this.toBeVisible(productsVendor.linkedProducts.selectedUpSellProduct(product)); + for (const linkedProduct of linkedProducts.upSells) { + await this.typeAndWaitForResponse(data.subUrls.ajax, productsVendor.linkedProducts.upSells, linkedProduct); + await this.click(productsVendor.linkedProducts.searchedResult(linkedProduct)); + await this.toBeVisible(productsVendor.linkedProducts.selectedUpSellProduct(linkedProduct)); } break; case 'cross-sells': - for (const product of linkedProducts.crossSells) { - await this.typeAndWaitForResponse(data.subUrls.ajax, productsVendor.linkedProducts.crossSells, product); - await this.click(productsVendor.linkedProducts.searchedResult(product)); - await this.toBeVisible(productsVendor.linkedProducts.selectedCrossSellProduct(product)); + for (const linkedProduct of linkedProducts.crossSells) { + await this.typeAndWaitForResponse(data.subUrls.ajax, productsVendor.linkedProducts.crossSells, linkedProduct); + await this.click(productsVendor.linkedProducts.searchedResult(linkedProduct)); + await this.toBeVisible(productsVendor.linkedProducts.selectedCrossSellProduct(linkedProduct)); } break; default: @@ -1290,13 +1241,13 @@ export class ProductsPage extends AdminPage { switch (choice) { case 'up-sells': - for (const product of linkedProducts.upSells) { - await this.toBeVisible(productsVendor.linkedProducts.selectedUpSellProduct(product)); + for (const linkedProduct of linkedProducts.upSells) { + await this.toBeVisible(productsVendor.linkedProducts.selectedUpSellProduct(linkedProduct)); } break; case 'cross-sells': - for (const product of linkedProducts.upSells) { - await this.toBeVisible(productsVendor.linkedProducts.selectedCrossSellProduct(product)); + for (const linkedProduct of linkedProducts.crossSells) { + await this.toBeVisible(productsVendor.linkedProducts.selectedCrossSellProduct(linkedProduct)); } break; default: @@ -1309,14 +1260,14 @@ export class ProductsPage extends AdminPage { await this.goToProductEdit(productName); switch (choice) { case 'up-sells': - for (const product of linkedProducts.upSells) { - await this.click(productsVendor.linkedProducts.removeSelectedUpSellProduct(product)); + for (const linkedProduct of linkedProducts.upSells) { + await this.click(productsVendor.linkedProducts.removeSelectedUpSellProduct(linkedProduct)); await this.press('Escape'); // shift focus from element } break; case 'cross-sells': - for (const product of linkedProducts.crossSells) { - await this.click(productsVendor.linkedProducts.removeSelectedCrossSellProduct(product)); + for (const linkedProduct of linkedProducts.crossSells) { + await this.click(productsVendor.linkedProducts.removeSelectedCrossSellProduct(linkedProduct)); await this.press('Escape'); // shift focus from element } break; @@ -1328,13 +1279,13 @@ export class ProductsPage extends AdminPage { switch (choice) { case 'up-sells': - for (const product of linkedProducts.upSells) { - await this.notToBeVisible(productsVendor.linkedProducts.selectedUpSellProduct(product)); + for (const linkedProduct of linkedProducts.upSells) { + await this.notToBeVisible(productsVendor.linkedProducts.selectedUpSellProduct(linkedProduct)); } break; case 'cross-sells': - for (const product of linkedProducts.upSells) { - await this.notToBeVisible(productsVendor.linkedProducts.selectedCrossSellProduct(product)); + for (const linkedProduct of linkedProducts.crossSells) { + await this.notToBeVisible(productsVendor.linkedProducts.selectedCrossSellProduct(linkedProduct)); } break; default: @@ -1476,7 +1427,7 @@ export class ProductsPage extends AdminPage { await this.selectByValue(productsVendor.addon.formatTitle, addon.formatTitle); await this.check(productsVendor.addon.addDescription); await this.clearAndType(productsVendor.addon.descriptionInput, addon.addDescription); - await this.click(productsVendor.addon.requiredField); + await this.check(productsVendor.addon.requiredField); // option await this.clearAndType(productsVendor.addon.option.enterAnOption, addon.enterAnOption); await this.selectByValue(productsVendor.addon.option.optionPriceType, addon.optionPriceType); @@ -1502,7 +1453,7 @@ export class ProductsPage extends AdminPage { await this.toBeChecked(productsVendor.addon.excludeAddons); } - // export addon + // import addon async importAddon(productName: string, addon: string, addonTitle: string): Promise { await this.goToProductEdit(productName); await this.click(productsVendor.addon.import); diff --git a/tests/pw/tests/e2e/productsDetails.spec.ts b/tests/pw/tests/e2e/productsDetails.spec.ts index 10a829c8d4..3c418fe632 100644 --- a/tests/pw/tests/e2e/productsDetails.spec.ts +++ b/tests/pw/tests/e2e/productsDetails.spec.ts @@ -448,8 +448,8 @@ test.describe('Product details functionality test', () => { }); test('vendor can remove product addon', { tag: ['@pro', '@vendor'] }, async () => { - const [, , productName, addonName] = await apiUtils.createProductWithAddon(payloads.createProduct(), [payloads.createProductAddon()], payloads.vendorAuth); - await vendor.removeAddon(productName, addonName[0] as string); + const [, , productName, addonNames] = await apiUtils.createProductWithAddon(payloads.createProduct(), [payloads.createProductAddon()], payloads.vendorAuth); + await vendor.removeAddon(productName, addonNames[0] as string); }); // rma options diff --git a/tests/pw/tests/e2e/requestForQuoteRules.spec.ts b/tests/pw/tests/e2e/requestForQuoteRules.spec.ts index c8bf11c618..c054e6c497 100644 --- a/tests/pw/tests/e2e/requestForQuoteRules.spec.ts +++ b/tests/pw/tests/e2e/requestForQuoteRules.spec.ts @@ -38,7 +38,7 @@ test.describe('Request for quotation Rules test', () => { }); test('admin can edit quote rule', { tag: ['@pro', '@admin'] }, async () => { - await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule(), title: quoteRuleTitle, specificProducts: false, }); + await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule(), title: quoteRuleTitle, specificProducts: false }); }); test('admin can trash quote rule', { tag: ['@pro', '@admin'] }, async () => {