Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: add product tests (product addon, rma) #2396

Merged
merged 7 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@
vendor can add product geolocation (individual): true
vendor can update product geolocation (individual): true
vendor can remove product geolocation (individual): true
vendor can add product EU compliance data: true
vendor can update product EU compliance data: true
vendor can remove product EU compliance data: true
vendor can add product addon: true
vendor can import product addon: true
vendor can export product addon: true
vendor can remove product addon: true
vendor can add product rma options (no warranty): true
vendor can add product rma options (warranty included limited): true
vendor can add product rma options (warranty included lifetime): true
vendor can add product rma options (warranty as addon): true
vendor can remove product rma options: true

- page: 'MyOrders'
features:
Expand Down Expand Up @@ -424,7 +436,10 @@
vendor can set live chat settings: false
vendor can set store support settings: true
vendor can set social profile settings: true
vendor can set rma settings: true
vendor can set rma settings (no warranty): true
vendor can set rma settings (warranty included limited): true
vendor can set rma settings (warranty included lifetime): true
vendor can set rma settings (warranty as addon): true
vendor can set store seo settings: true

- page: 'Setting'
Expand Down Expand Up @@ -782,6 +797,10 @@
vendor can import global product addon field: true
vendor can export global product addon field: true
vendor can remove product addon field: true
vendor can add product addon: true
vendor can import product addon: true
vendor can export product addon: true
vendor can remove product addon: true
customer:
customer can view product addons on single product page: false
customer can buy product with addon: false
Expand Down
122 changes: 122 additions & 0 deletions tests/pw/pages/productsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,128 @@ export class ProductsPage extends AdminPage {
await this.toHaveValue(productsVendor.euComplianceFields.saleUnitPrice, euCompliance.saleUnitPrice);
await this.toContainTextFrameLocator(productsVendor.euComplianceFields.optionalMiniDescription.descriptionIframe, productsVendor.euComplianceFields.optionalMiniDescription.descriptionHtmlBody, euCompliance.optionalMiniDescription);
}

// add product addons
async addProductAddon(productName: string, addon: product['productInfo']['addon']): Promise<void> {
await this.goToProductEdit(productName);
await this.toPass(async () => {
await this.clickAndWaitForResponse(data.subUrls.ajax, productsVendor.addon.addField);
await this.toBeVisible(productsVendor.addon.addonForm);
});
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved

await this.selectByValue(productsVendor.addon.type, addon.type);
await this.selectByValue(productsVendor.addon.displayAs, addon.displayAs);
await this.clearAndType(productsVendor.addon.titleRequired, addon.title);
await this.selectByValue(productsVendor.addon.formatTitle, addon.formatTitle);
await this.check(productsVendor.addon.addDescription);
await this.clearAndType(productsVendor.addon.descriptionInput, addon.addDescription);
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);
await this.clearAndType(productsVendor.addon.option.optionPriceInput, addon.optionPriceInput);
await this.check(productsVendor.addon.excludeAddons);

await this.saveProduct();

await this.toBeVisible(productsVendor.addon.addonRow(addon.title));
await this.click(productsVendor.addon.addonRow(addon.title));

await this.toHaveSelectedValue(productsVendor.addon.type, addon.type);
await this.toHaveSelectedValue(productsVendor.addon.displayAs, addon.displayAs);
await this.toHaveValue(productsVendor.addon.titleRequired, addon.title);
await this.toHaveSelectedValue(productsVendor.addon.formatTitle, addon.formatTitle);
await this.toBeChecked(productsVendor.addon.addDescription);
await this.toHaveValue(productsVendor.addon.descriptionInput, addon.addDescription);
await this.toBeChecked(productsVendor.addon.requiredField);
// option
await this.toHaveValue(productsVendor.addon.option.enterAnOption, addon.enterAnOption);
await this.toHaveSelectedValue(productsVendor.addon.option.optionPriceType, addon.optionPriceType);
await this.toHaveValue(productsVendor.addon.option.optionPriceInput, addon.optionPriceInput);
await this.toBeChecked(productsVendor.addon.excludeAddons);
}

// import addon
async importAddon(productName: string, addon: string, addonTitle: string): Promise<void> {
await this.goToProductEdit(productName);
await this.click(productsVendor.addon.import);
await this.clearAndType(productsVendor.addon.importInput, addon);
await this.saveProduct();
await this.toBeVisible(productsVendor.addon.addonRow(addonTitle));
}

// export addon
async exportAddon(productName: string, addon: string): Promise<void> {
await this.goToProductEdit(productName);
await this.click(productsVendor.addon.export);
await this.toContainText(productsVendor.addon.exportInput, addon);
}

// delete addon
async removeAddon(productName: string, addonName: string): Promise<void> {
await this.goToProductEdit(productName);
await this.click(productsVendor.addon.removeAddon(addonName));
await this.click(productsVendor.addon.confirmRemove);
await this.notToBeVisible(productsVendor.addon.addonRow(addonName));
await this.saveProduct();
await this.notToBeVisible(productsVendor.addon.addonRow(addonName));
}

// add product rma options
async addProductRmaOptions(productName: string, rma: vendor['rma']): Promise<void> {
await this.goToProductEdit(productName);
await this.check(productsVendor.rma.overrideDefaultRmaSettings);
await this.clearAndType(productsVendor.rma.label, rma.label);
await this.selectByValue(productsVendor.rma.type, rma.type);

if (rma.type === 'included_warranty') {
await this.selectByValue(productsVendor.rma.length, rma.length);
if (rma.length === 'limited') {
await this.clearAndType(productsVendor.rma.lengthValue, rma.lengthValue);
await this.selectByValue(productsVendor.rma.lengthDuration, rma.lengthDuration);
}
} else if (rma.type === 'addon_warranty') {
await this.clearAndType(productsVendor.rma.addonCost, rma.addon.cost);
await this.clearAndType(productsVendor.rma.addonDurationLength, rma.addon.durationLength);
await this.selectByValue(productsVendor.rma.addonDurationType, rma.addon.durationType);
}
const refundReasonIsVisible = await this.isVisible(productsVendor.rma.refundReasonsFirst);
if (refundReasonIsVisible) {
await this.checkMultiple(productsVendor.rma.refundReasons);
}
await this.typeFrameSelector(productsVendor.rma.rmaPolicyIframe, productsVendor.rma.rmaPolicyHtmlBody, rma.refundPolicy);

await this.saveProduct();

await this.toBeChecked(productsVendor.rma.overrideDefaultRmaSettings);
await this.toHaveValue(productsVendor.rma.label, rma.label);
await this.toHaveSelectedValue(productsVendor.rma.type, rma.type);
if (rma.type === 'included_warranty') {
await this.toHaveSelectedValue(productsVendor.rma.length, rma.length);
if (rma.length === 'limited') {
await this.toHaveValue(productsVendor.rma.lengthValue, rma.lengthValue);
await this.toHaveSelectedValue(productsVendor.rma.lengthDuration, rma.lengthDuration);
}
} else if (rma.type === 'addon_warranty') {
await this.toHaveValue(productsVendor.rma.addonCost, rma.addon.cost);
await this.toHaveValue(productsVendor.rma.addonDurationLength, rma.addon.durationLength);
await this.toHaveSelectedValue(productsVendor.rma.addonDurationType, rma.addon.durationType);
}

if (refundReasonIsVisible) {
await this.toBeCheckedMultiple(productsVendor.rma.refundReasons);
}
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
await this.toContainTextFrameLocator(productsVendor.rma.rmaPolicyIframe, productsVendor.rma.rmaPolicyHtmlBody, rma.refundPolicy);
}
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved

// remove product rma options
async removeProductRmaOptions(productName: string): Promise<void> {
await this.goToProductEdit(productName);
await this.uncheck(productsVendor.rma.overrideDefaultRmaSettings);
await this.saveProduct();
await this.notToBeChecked(productsVendor.rma.overrideDefaultRmaSettings);
}

// add product wholesale options
async addProductWholesaleOptions(productName: string, wholesaleOption: product['productInfo']['wholesaleOption']): Promise<void> {
await this.goToProductEdit(productName);
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/pages/requestForQuotationsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class RequestForQuotationsPage extends AdminPage {
await this.clearAndType(requestForQuotationAdmin.quoteRules.addNewQuoteRule.hidePriceText, rule.hidePriceText);
} else {
if (rule.hideAddToCartButton) await this.click(requestForQuotationAdmin.quoteRules.addNewQuoteRule.hideAddToCartButton);
if (rule.hideAddToCartButton) await this.click(requestForQuotationAdmin.quoteRules.addNewQuoteRule.keepBothAddToCartAndQuoteButton);
if (rule.keepBothCartQuoteButton) await this.click(requestForQuotationAdmin.quoteRules.addNewQuoteRule.keepBothAddToCartAndQuoteButton);
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
}
await this.clearAndType(requestForQuotationAdmin.quoteRules.addNewQuoteRule.customButtonLabel, rule.customButtonLabel);

Expand Down
26 changes: 26 additions & 0 deletions tests/pw/tests/e2e/productAddons.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, request, Page } from '@playwright/test';
import { ProductAddonsPage } from '@pages/productAddonsPage';
import { ProductsPage } from '@pages/productsPage';
import { ApiUtils } from '@utils/apiUtils';
import { data } from '@utils/testData';
import { payloads } from '@utils/payloads';
Expand All @@ -11,10 +12,12 @@ const { VENDOR_ID } = process.env;

test.describe('Product addon functionality test', () => {
let vendor: ProductAddonsPage;
let vendor1: ProductsPage;
let vPage: Page;
let addonName: string;
let addonFieldTitle: string;
let categoryName: string;
let productName: string;
let apiUtils: ApiUtils;

// create product addon
Expand All @@ -29,9 +32,11 @@ test.describe('Product addon functionality test', () => {
const vendorContext = await browser.newContext(data.auth.vendorAuth);
vPage = await vendorContext.newPage();
vendor = new ProductAddonsPage(vPage);
vendor1 = new ProductsPage(vPage);

apiUtils = new ApiUtils(await request.newContext());
[, , addonName, addonFieldTitle, categoryName] = await createVendorProductAddon();
[, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth);
});

test.afterAll(async () => {
Expand Down Expand Up @@ -75,4 +80,25 @@ test.describe('Product addon functionality test', () => {
const [, , addonName] = await createVendorProductAddon();
await vendor.removeAddon({ ...data.vendor.addon(), name: addonName });
});

// product addon

test('vendor can add product addon', { tag: ['@pro', '@vendor'] }, async () => {
await vendor1.addProductAddon(productName, data.product.productInfo.addon);
});

test('vendor can import product addon', { tag: ['@pro', '@vendor'] }, async () => {
const addon = payloads.createProductAddon();
await vendor1.importAddon(productName, serialize([addon]), addon.name);
});

test('vendor can export product addon', { tag: ['@pro', '@vendor'] }, async () => {
const [responseBody, , productName] = await apiUtils.createProductWithAddon(payloads.createProduct(), [payloads.createProductAddon()], payloads.vendorAuth);
await vendor1.exportAddon(productName, serialize(apiUtils.getMetaDataValue(responseBody.meta_data, '_product_addons')));
});

test('vendor can remove product addon', { tag: ['@pro', '@vendor'] }, async () => {
const [, , productName, addonName] = await apiUtils.createProductWithAddon(payloads.createProduct(), [payloads.createProductAddon()], payloads.vendorAuth);
await vendor1.removeAddon(productName, addonName[0] as string);
});
});
61 changes: 61 additions & 0 deletions tests/pw/tests/e2e/productsDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,65 @@ test.describe('Product details functionality test', () => {
test('vendor can remove product geolocation (individual)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.removeProductGeolocation(productName);
});

// EU compliance options
// todo: duplicate test from euCompliance

shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
test.skip('vendor can add product EU compliance data', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductEuCompliance(productName1, data.product.productInfo.euCompliance);
});

test.skip('vendor can update product EU compliance data', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductEuCompliance(productName, data.product.productInfo.euCompliance);
});

test.skip('vendor can remove product EU compliance data', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductEuCompliance(productName, { ...data.product.productInfo.euCompliance, productUnits: '', basePriceUnits: '', freeShipping: false, regularUnitPrice: '', saleUnitPrice: '', optionalMiniDescription: '' });
});

shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
// addon
// todo: duplicate test from product addons also has new tests

shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
test('vendor can add product addon', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductAddon(productName1, data.product.productInfo.addon);
});

test('vendor can import product addon', { tag: ['@pro', '@vendor'] }, async () => {
const addon = payloads.createProductAddon();
await vendor.importAddon(productName1, serialize([addon]), addon.name);
});

test('vendor can export product addon', { tag: ['@pro', '@vendor'] }, async () => {
const [responseBody, , productName] = await apiUtils.createProductWithAddon(payloads.createProduct(), [payloads.createProductAddon()], payloads.vendorAuth);
await vendor.exportAddon(productName, serialize(apiUtils.getMetaDataValue(responseBody.meta_data, '_product_addons')));
});

test('vendor can remove product addon', { tag: ['@pro', '@vendor'] }, async () => {
const [, , productName, addonNames] = await apiUtils.createProductWithAddon(payloads.createProduct(), [payloads.createProductAddon()], payloads.vendorAuth);
await vendor.removeAddon(productName, addonNames[0] as string);
});

// rma options

test('vendor can add product rma options (no warranty)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductRmaOptions(productName1, { ...data.vendor.rma, type: 'no_warranty' });
});

test('vendor can add product rma options (warranty included limited)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductRmaOptions(productName1, data.vendor.rma);
});

test('vendor can add product rma options (warranty included lifetime)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductRmaOptions(productName1, { ...data.vendor.rma, length: 'lifetime' });
});

test('vendor can add product rma options (warranty as addon)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductRmaOptions(productName1, { ...data.vendor.rma, type: 'addon_warranty' });
});

shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
//todo: add update rma options tests

test('vendor can remove product rma options', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.removeProductRmaOptions(productName);
});
});
Loading