Skip to content

Commit

Permalink
Merge branch 'develop' into rfq
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Oct 7, 2024
2 parents 28ad239 + b2ce2cc commit 895665e
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 3 deletions.
19 changes: 19 additions & 0 deletions tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,25 @@
vendor can remove product inventory options (stock management) [lite]: true
vendor can add product inventory options (allow single quantity) [lite]: true
vendor can remove product inventory options (allow single quantity) [lite]: true
vendor can add product other options (product status) [lite]: true
vendor can add product other options (visibility) [lite]: true
vendor can add product other options (purchase note) [lite]: true
vendor can remove product other options (purchase note) [lite]: true
vendor can add product other options (product review) [lite]: true
vendor can remove product other options (product review) [lite]: true
vendor can add product catalog mode [lite]: true
vendor can add product catalog mode (with price hidden) [lite]: true
vendor can remove product catalog mode [lite]: true
vendor can remove product catalog mode (price hidden option) [lite]: true
vendor can add product shipping: true
vendor can update product shipping: true
vendor can remove product shipping: true
vendor can add product tax: true
vendor can add product tax (with tax class): true
vendor can add product linked products (up-sells): true
vendor can add product linked products (cross-sells): true
vendor can remove product linked products (up-sells): true
vendor can remove product linked products (cross-sells): true

- page: 'MyOrders'
features:
Expand Down
4 changes: 2 additions & 2 deletions tests/pw/pages/loginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export class LoginPage extends BasePage {

// user login backend
async loginBackend(user: user, url: string = data.subUrls.backend.login, storageState?: string): Promise<void> {
await this.goIfNotThere(url);
await this.gotoUntilNetworkidle(url);
const emailField = await this.isVisible(selector.backend.email);
if (emailField) {
await this.clearAndType(selector.backend.email, user.username);
await this.clearAndType(selector.backend.password, user.password);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.backend.login, selector.backend.login, 302);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.backend.adminDashboard, selector.backend.login);
if (storageState) {
await this.page.context().storageState({ path: storageState });
}
Expand Down
184 changes: 184 additions & 0 deletions tests/pw/pages/productsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,55 @@ export class ProductsPage extends AdminPage {
await this.notToBeChecked(productsVendor.inventory.enableStockManagement);
}

// add product other options (product status, visibility, purchase note, reviews)
async addProductOtherOptions(productName: string, otherOption: product['productInfo']['otherOptions'], choice: string): Promise<void> {
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<void> {
await this.goToProductEdit(productName);
Expand All @@ -1109,6 +1158,141 @@ export class ProductsPage extends AdminPage {
await this.toBeChecked(productsVendor.catalogMode.removeAddToCart);
if (hidePrice) await this.toBeChecked(productsVendor.catalogMode.hideProductPrice);
}

// remove product catalog mode
async removeProductCatalogMode(productName: string, onlyPrice: boolean = false): Promise<void> {
await this.goToProductEdit(productName);

if (onlyPrice) {
await this.uncheck(productsVendor.catalogMode.hideProductPrice);
} else {
await this.uncheck(productsVendor.catalogMode.removeAddToCart);
}

await this.saveProduct();

if (onlyPrice) {
await this.notToBeChecked(productsVendor.catalogMode.hideProductPrice);
} else {
await this.notToBeChecked(productsVendor.catalogMode.removeAddToCart);
}
}

// dokan pro features

// add product shipping
async addProductShipping(productName: string, shipping: product['productInfo']['shipping']): Promise<void> {
await this.goToProductEdit(productName);
await this.check(productsVendor.shipping.requiresShipping);
await this.clearAndType(productsVendor.shipping.weight, shipping.weight);
await this.clearAndType(productsVendor.shipping.length, shipping.length);
await this.clearAndType(productsVendor.shipping.width, shipping.width);
await this.clearAndType(productsVendor.shipping.height, shipping.height);
await this.selectByLabel(productsVendor.shipping.shippingClass, shipping.shippingClass);
await this.saveProduct();
await this.toBeChecked(productsVendor.shipping.requiresShipping);
await this.toHaveValue(productsVendor.shipping.weight, shipping.weight);
await this.toHaveValue(productsVendor.shipping.length, shipping.length);
await this.toHaveValue(productsVendor.shipping.width, shipping.width);
await this.toHaveValue(productsVendor.shipping.height, shipping.height);
await this.toHaveSelectedLabel(productsVendor.shipping.shippingClass, shipping.shippingClass);
}
// add product shipping
async removeProductShipping(productName: string): Promise<void> {
await this.goToProductEdit(productName);
await this.uncheck(productsVendor.shipping.requiresShipping);
await this.saveProduct();
await this.notToBeChecked(productsVendor.shipping.requiresShipping);
}

// add product tax
async addProductTax(productName: string, tax: product['productInfo']['tax'], hasClass: boolean = false): Promise<void> {
await this.goToProductEdit(productName);
await this.selectByValue(productsVendor.tax.status, tax.status);
if (hasClass) await this.selectByValue(productsVendor.tax.class, tax.class);
await this.saveProduct();
await this.toHaveSelectedValue(productsVendor.tax.status, tax.status);
if (hasClass) await this.toHaveSelectedValue(productsVendor.tax.class, tax.class);
}

// add product linked products
async addProductLinkedProducts(productName: string, linkedProducts: product['productInfo']['linkedProducts'], choice: string): Promise<void> {
await this.goToProductEdit(productName);
switch (choice) {
case 'up-sells':
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 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:
break;
}

await this.saveProduct();

switch (choice) {
case 'up-sells':
for (const linkedProduct of linkedProducts.upSells) {
await this.toBeVisible(productsVendor.linkedProducts.selectedUpSellProduct(linkedProduct));
}
break;
case 'cross-sells':
for (const linkedProduct of linkedProducts.crossSells) {
await this.toBeVisible(productsVendor.linkedProducts.selectedCrossSellProduct(linkedProduct));
}
break;
default:
break;
}
}

// add product linked products
async removeProductLinkedProducts(productName: string, linkedProducts: product['productInfo']['linkedProducts'], choice: string): Promise<void> {
await this.goToProductEdit(productName);
switch (choice) {
case 'up-sells':
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 linkedProduct of linkedProducts.crossSells) {
await this.click(productsVendor.linkedProducts.removeSelectedCrossSellProduct(linkedProduct));
await this.press('Escape'); // shift focus from element
}
break;
default:
break;
}

await this.saveProduct();

switch (choice) {
case 'up-sells':
for (const linkedProduct of linkedProducts.upSells) {
await this.notToBeVisible(productsVendor.linkedProducts.selectedUpSellProduct(linkedProduct));
}
break;
case 'cross-sells':
for (const linkedProduct of linkedProducts.crossSells) {
await this.notToBeVisible(productsVendor.linkedProducts.selectedCrossSellProduct(linkedProduct));
}
break;
default:
break;
}
}

// add product EU compliance
async addProductEuCompliance(productName: string, euCompliance: product['productInfo']['euCompliance']): Promise<void> {
await this.goToProductEdit(productName);
Expand Down
90 changes: 90 additions & 0 deletions tests/pw/tests/e2e/productsDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,94 @@ test.describe('Product details functionality test', () => {
test('vendor can remove product inventory options (allow single quantity)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductInventory(productName, { ...data.product.productInfo.inventory(), oneQuantity: false }, 'one-quantity');
});

// product other options

test('vendor can add product other options (product status)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductOtherOptions(productName1, data.product.productInfo.otherOptions, 'status');
});

test('vendor can add product other options (visibility)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductOtherOptions(productName1, data.product.productInfo.otherOptions, 'visibility');
});

test('vendor can add product other options (purchase note)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductOtherOptions(productName1, data.product.productInfo.otherOptions, 'purchaseNote');
});

test('vendor can remove product other options (purchase note)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductOtherOptions(productName, { ...data.product.productInfo.otherOptions, purchaseNote: '' }, 'purchaseNote');
});

test('vendor can add product other options (product review)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductOtherOptions(productName1, data.product.productInfo.otherOptions, 'reviews');
});

test('vendor can remove product other options (product review)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductOtherOptions(productName, { ...data.product.productInfo.otherOptions, enableReview: false }, 'reviews');
});

// catalog mode

// todo: move to catalog page

test('vendor can add product catalog mode', { tag: ['@lite', '@vendor'] }, async () => {
await dbUtils.updateOptionValue(dbData.dokan.optionName.selling, { catalog_mode_hide_add_to_cart_button: 'on' });
await vendor.addProductCatalogMode(productName1);
});

test('vendor can add product catalog mode (with price hidden)', { tag: ['@lite', '@vendor'] }, async () => {
await dbUtils.updateOptionValue(dbData.dokan.optionName.selling, { catalog_mode_hide_add_to_cart_button: 'on', catalog_mode_hide_product_price: 'on' });
await vendor.addProductCatalogMode(productName1, true);
});

test('vendor can remove product catalog mode', { tag: ['@lite', '@vendor'] }, async () => {
await dbUtils.updateOptionValue(dbData.dokan.optionName.selling, { catalog_mode_hide_add_to_cart_button: 'on', catalog_mode_hide_product_price: 'on' });
await vendor.removeProductCatalogMode(productName);
});

test('vendor can remove product catalog mode (price hidden option)', { tag: ['@lite', '@vendor'] }, async () => {
await dbUtils.updateOptionValue(dbData.dokan.optionName.selling, { catalog_mode_hide_add_to_cart_button: 'on', catalog_mode_hide_product_price: 'on' });
await vendor.removeProductCatalogMode(productName, true);
});

// shipping and tax

test('vendor can add product shipping', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductShipping(productName1, data.product.productInfo.shipping);
});

test('vendor can update product shipping', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductShipping(productName, data.product.productInfo.shipping);
});

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

test('vendor can add product tax', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductTax(productName1, data.product.productInfo.tax);
});

test('vendor can add product tax (with tax class)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductTax(productName1, data.product.productInfo.tax, true);
});

// linked products

test('vendor can add product linked products (up-sells)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductLinkedProducts(productName1, data.product.productInfo.linkedProducts, 'up-sells');
});

test('vendor can add product linked products (cross-sells)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductLinkedProducts(productName1, data.product.productInfo.linkedProducts, 'cross-sells');
});

test('vendor can remove product linked products (up-sells)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.removeProductLinkedProducts(productName, data.product.productInfo.linkedProducts, 'up-sells');
});

test('vendor can remove product linked products (cross-sells)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.removeProductLinkedProducts(productName, data.product.productInfo.linkedProducts, 'cross-sells');
});
});
14 changes: 13 additions & 1 deletion tests/pw/tests/e2e/vendorSettings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,22 @@ test.describe('Vendor settings test', () => {
await vendor.setSocialProfile(data.vendor.socialProfileUrls);
});

test('vendor can set rma settings', { tag: ['@pro', '@vendor'] }, async () => {
test('vendor can set rma settings (no warranty)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.setRmaSettings({ ...data.vendor.rma, type: 'no_warranty' });
});

test('vendor can set rma settings (warranty included limited)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.setRmaSettings(data.vendor.rma);
});

test('vendor can set rma settings (warranty included lifetime)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.setRmaSettings({ ...data.vendor.rma, length: 'lifetime' });
});

test('vendor can set rma settings (warranty as addon)', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.setRmaSettings({ ...data.vendor.rma, type: 'addon_warranty' });
});

test('vendor can set store seo settings', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.setStoreSeo(data.vendor.seo);
});
Expand Down

0 comments on commit 895665e

Please sign in to comment.