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: product form tests (other options, catalog) #57

Merged
merged 1 commit into from
Oct 7, 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
10 changes: 10 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,16 @@
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

- page: 'MyOrders'
features:
Expand Down
69 changes: 69 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;
}
}
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved

// add product catalog mode
async addProductCatalogMode(productName: string, hidePrice: boolean = false): Promise<void> {
await this.goToProductEdit(productName);
Expand All @@ -1109,6 +1158,26 @@ 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);
}
}

shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
// add product EU compliance
async addProductEuCompliance(productName: string, euCompliance: product['productInfo']['euCompliance']): Promise<void> {
await this.goToProductEdit(productName);
Expand Down
50 changes: 50 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,54 @@ 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);
});
});
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
Loading