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 form tests (download options, inventory) #2389

Merged
merged 4 commits into from
Oct 4, 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
12 changes: 12 additions & 0 deletions tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@
vendor can update product short description [lite]: true
vendor can remove product short description [lite]: true
vendor can update product description [lite]: true
vendor can add product downloadable options [lite]: true
vendor can update product downloadable options [lite]: true
vendor can remove product downloadable file [lite]: true
vendor can add product inventory options (SKU) [lite]: true
vendor can update product inventory options (SKU) [lite]: true
vendor can remove product inventory options (SKU) [lite]: true
vendor can add product inventory options (stock status) [lite]: true
vendor can add product inventory options (stock management) [lite]: true
vendor can update product inventory options (stock management) [lite]: true
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

- page: 'MyOrders'
features:
Expand Down
98 changes: 97 additions & 1 deletion tests/pw/pages/productsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ export class ProductsPage extends AdminPage {
await this.goToProductEdit(productName);
for (const tag of tags) {
await this.click(productsVendor.tags.removeSelectedTags(tag));
await this.press('Escape'); // shift focus from element
await this.press('Escape'); // shift focus from element
}
await this.saveProduct();

Expand Down Expand Up @@ -1003,6 +1003,102 @@ export class ProductsPage extends AdminPage {
await this.toContainTextFrameLocator(productsVendor.description.descriptionIframe, productsVendor.description.descriptionHtmlBody, description);
}

// add product downloadable options
async addProductDownloadableOptions(productName: string, downloadableOption: product['productInfo']['downloadableOptions']): Promise<void> {
await this.goToProductEdit(productName);
await this.check(productsVendor.downloadable);
await this.click(productsVendor.downloadableOptions.addFile);
await this.clearAndType(productsVendor.downloadableOptions.fileName, downloadableOption.fileName);
await this.click(productsVendor.downloadableOptions.chooseFile);
await this.uploadMedia(downloadableOption.fileUrl);
await this.clearAndType(productsVendor.downloadableOptions.downloadLimit, downloadableOption.downloadLimit);
await this.clearAndType(productsVendor.downloadableOptions.downloadExpiry, downloadableOption.downloadExpiry);
await this.saveProduct();
await this.toBeChecked(productsVendor.downloadable);
await this.toHaveValue(productsVendor.downloadableOptions.fileName, downloadableOption.fileName);
await this.toHaveValue(productsVendor.downloadableOptions.downloadLimit, downloadableOption.downloadLimit);
await this.toHaveValue(productsVendor.downloadableOptions.downloadExpiry, downloadableOption.downloadExpiry);
}
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved

// remove product downloadable files
async removeDownloadableFile(productName: string, downloadableOption: product['productInfo']['downloadableOptions']): Promise<void> {
await this.goToProductEdit(productName);
const fileCount = await this.getElementCount(productsVendor.downloadableOptions.deleteFile);
for (let i = 0; i < fileCount; i++) {
await this.clickFirstLocator(productsVendor.downloadableOptions.deleteFile);
}
await this.clearAndType(productsVendor.downloadableOptions.downloadLimit, downloadableOption.downloadLimit);
await this.clearAndType(productsVendor.downloadableOptions.downloadExpiry, downloadableOption.downloadExpiry);
await this.saveProduct();
await this.notToBeVisible(productsVendor.downloadableOptions.deleteFile);
await this.toHaveValue(productsVendor.downloadableOptions.downloadLimit, downloadableOption.downloadLimit);
await this.toHaveValue(productsVendor.downloadableOptions.downloadExpiry, downloadableOption.downloadExpiry);
}
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved

// add product inventory
async addProductInventory(productName: string, inventory: product['productInfo']['inventory'], choice: string): Promise<void> {
await this.goToProductEdit(productName);

switch (choice) {
case 'sku':
await this.clearAndType(productsVendor.inventory.sku, inventory.sku);
break;
case 'stock-status':
await this.selectByValue(productsVendor.inventory.stockStatus, inventory.stockStatus);
break;
case 'stock-management':
await this.check(productsVendor.inventory.enableStockManagement);
await this.clearAndType(productsVendor.inventory.stockQuantity, inventory.stockQuantity);
await this.clearAndType(productsVendor.inventory.lowStockThreshold, inventory.lowStockThreshold);
await this.selectByValue(productsVendor.inventory.allowBackorders, inventory.backorders);
break;
case 'one-quantity':
if (inventory.oneQuantity) {
await this.check(productsVendor.inventory.allowOnlyOneQuantity);
} else {
await this.uncheck(productsVendor.inventory.allowOnlyOneQuantity);
}
break;
default:
break;
}

await this.saveProduct();

// todo: replace switch with all method action and assertion as object member and loop through to call them

switch (choice) {
case 'sku':
await this.toHaveValue(productsVendor.inventory.sku, inventory.sku);
break;
case 'stock-status':
await this.toHaveSelectedValue(productsVendor.inventory.stockStatus, inventory.stockStatus);
break;
case 'stock-management':
await this.toBeChecked(productsVendor.inventory.enableStockManagement);
await this.toHaveValue(productsVendor.inventory.stockQuantity, inventory.stockQuantity);
await this.toHaveValue(productsVendor.inventory.lowStockThreshold, inventory.lowStockThreshold);
await this.toHaveSelectedValue(productsVendor.inventory.allowBackorders, inventory.backorders);
await this.notToBeVisible(productsVendor.inventory.stockStatus);
break;
case 'one-quantity':
if (inventory.oneQuantity) {
await this.toBeChecked(productsVendor.inventory.allowOnlyOneQuantity);
} else {
await this.notToBeChecked(productsVendor.inventory.allowOnlyOneQuantity);
}
break;
default:
break;
}
}
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
// remove product inventory [stock management]
async removeProductInventory(productName: string): Promise<void> {
await this.goToProductEdit(productName);
await this.uncheck(productsVendor.inventory.enableStockManagement);
await this.saveProduct();
await this.notToBeChecked(productsVendor.inventory.enableStockManagement);
}

// add product catalog mode
async addProductCatalogMode(productName: string, hidePrice: boolean = false): Promise<void> {
Expand Down
54 changes: 54 additions & 0 deletions tests/pw/tests/e2e/productsDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,58 @@ test.describe('Product details functionality test', () => {
await vendor.addProductDescription(productName, data.product.productInfo.description.description);
});

// product downloadable options

test('vendor can add product downloadable options', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductDownloadableOptions(productName1, data.product.productInfo.downloadableOptions);
});

test('vendor can update product downloadable options', { tag: ['@lite', '@vendor'] }, async () => {
// todo: need a product with downloadable file
await vendor.addProductDownloadableOptions(productName, data.product.productInfo.downloadableOptions);
});

test('vendor can remove product downloadable file', { tag: ['@lite', '@vendor'] }, async () => {
// todo: need a product with downloadable file
await vendor.addProductDownloadableOptions(productName, data.product.productInfo.downloadableOptions);
await vendor.removeDownloadableFile(productName, { ...data.product.productInfo.downloadableOptions, downloadLimit: '', downloadExpiry: '' });
});

// product inventory options

test('vendor can add product inventory options (SKU)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductInventory(productName1, data.product.productInfo.inventory(), 'sku');
});

test('vendor can update product inventory options (SKU)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductInventory(productName, data.product.productInfo.inventory(), 'sku');
});

test('vendor can remove product inventory options (SKU)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductInventory(productName, { ...data.product.productInfo.inventory(), sku: '' }, 'sku');
});

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

test('vendor can add product inventory options (stock management)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductInventory(productName1, data.product.productInfo.inventory(), 'stock-management');
});

test('vendor can update product inventory options (stock management)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductInventory(productName1, data.product.productInfo.inventory(), 'stock-management');
});

test('vendor can remove product inventory options (stock management)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.removeProductInventory(productName);
});

test('vendor can add product inventory options (allow single quantity)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductInventory(productName1, data.product.productInfo.inventory(), 'one-quantity');
});

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');
});
});
11 changes: 11 additions & 0 deletions tests/pw/tests/e2e/vendorSettings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { dbUtils } from '@utils/dbUtils';
import { data } from '@utils/testData';
import { payloads } from '@utils/payloads';

const { VENDOR_ID } = process.env;

test.describe('Vendor settings test', () => {
let vendor: VendorSettingsPage;
let vPage: Page;
Expand All @@ -21,6 +23,7 @@ test.describe('Vendor settings test', () => {

test.afterAll(async () => {
await apiUtils.setStoreSettings(payloads.defaultStoreSettings, payloads.vendorAuth);
await dbUtils.setUserMeta(VENDOR_ID, '_dokan_rma_settings', dbData.testData.dokan.rmaSettings, true);
await vPage.close();
await apiUtils.dispose();
});
Expand Down Expand Up @@ -49,6 +52,14 @@ test.describe('Vendor settings test', () => {

// store settings

test.skip('vendor can set store banner settings', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.setStoreSettings(data.vendor.vendorInfo, 'banner');
});
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved

test.skip('vendor can set store profile picture settings', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.setStoreSettings(data.vendor.vendorInfo, 'profile-picture');
});
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved

test('vendor can set store basic settings', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.setStoreSettings(data.vendor.vendorInfo, 'basic');
});
Expand Down
Loading