Skip to content

Commit

Permalink
Auction tests (#2452)
Browse files Browse the repository at this point in the history
* Add a test

* Update feature map

* Fix lint issue

* change filename temporary

* Revert filename to original

* Fix notice test

* Fix commission test
  • Loading branch information
shashwatahalder01 authored Nov 27, 2024
1 parent 9b8e9c2 commit 1f97569
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 18 deletions.
21 changes: 18 additions & 3 deletions tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@
vendor can't bid own product: true
vendor can add auction product: true
vendor can view auction product: true
vendor can duplicate auction product: false
vendor can duplicate auction product: true
vendor can permanently delete auction product: true
vendor can edit auction product: true
vendor can update auction product title: true
Expand Down Expand Up @@ -760,13 +760,28 @@
admin:
admin can enable delivery time module: false
admin can disable delivery time module: false
admin can allow vendor to override delivery time settings: false
admin can set delivery support options: false
admin can set delivery date label: false
admin can set delivery blocked buffer: false
admin can set delivery time slot: false
admin can set delivery order per slot: false
admin can set delivery box info: false
admin can require delivery date and time: false
admin can set delivery days: false
admin can update delivery time on order details: false
vendor:
vendor can view delivery time menu page: true
vendor can change view style of delivery time calendar: true
vendor can filter delivery time: true
vendor can view delivery time orders on calendar: false
vendor can view delivery time settings menu page: true
vendor can set delivery time settings: true
vendor can filter delivery time: true
vendor can change view style of delivery time calendar: true
vendor can set delivery support options: false
vendor can set delivery blocked buffer: false
vendor can set delivery time slot: false
vendor can set delivery order per slot: false
vendor can set delivery days: false
vendor can update delivery time on order details: false
customer:
customer can buy product with delivery time: true
Expand Down
20 changes: 10 additions & 10 deletions tests/pw/pages/commissionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ export class CommissionPage extends AdminPage {
// await this.selectByValue(setupWizardAdmin.commissionType, commission.commissionType);

await this.clearAndType(setupWizardAdmin.percentage, commission.commissionPercentage);
await this.wait(0.5); //todo: need to resolve
await this.wait(1); //todo: need to resolve
await this.clearAndType(setupWizardAdmin.fixed, commission.commissionFixed);
await this.wait(0.5);
await this.wait(1);
} else {
// await this.selectByValueAndWaitForResponse(data.subUrls.api.dokan.multistepCategories, setupWizardAdmin.commissionType, commission.commissionType);

if (commission.commissionCategory.allCategory) {
await this.clearAndType(setupWizardAdmin.categoryPercentage(commission.commissionCategory.category), commission.commissionPercentage);
await this.wait(0.5);
await this.wait(1);
await this.clearAndType(setupWizardAdmin.categoryFixed(commission.commissionCategory.category), commission.commissionFixed);
await this.wait(0.5);
await this.wait(1);
} else {
const categoryExpanded = await this.isVisible(setupWizardAdmin.expandedCategories);
if (!categoryExpanded) {
await this.click(setupWizardAdmin.expandCategories);
}
await this.clearAndType(setupWizardAdmin.categoryPercentageById(commission.commissionCategory.category), commission.commissionPercentage);
await this.wait(0.5);
await this.wait(1);
await this.clearAndType(setupWizardAdmin.categoryFixedById(commission.commissionCategory.category), commission.commissionFixed);
await this.wait(0.5);
await this.wait(1);
}
}
}
Expand Down Expand Up @@ -124,7 +124,7 @@ export class CommissionPage extends AdminPage {

// set commission for vendor
async setCommissionForVendor(sellerId: string, commission: commission) {
await this.goto(data.subUrls.backend.dokan.vendorDetailsEdit(sellerId));
await this.gotoUntilNetworkidle(data.subUrls.backend.dokan.vendorDetailsEdit(sellerId));

await this.selectByValue(vendors.editVendor.commissionType, commission.commissionType);

Expand All @@ -141,14 +141,14 @@ export class CommissionPage extends AdminPage {

// set commission to product
async setCommissionForProduct(productId: string, commission: commission) {
await this.goto(data.subUrls.backend.wc.productDetails(productId));
await this.gotoUntilNetworkidle(data.subUrls.backend.wc.productDetails(productId));

// add commission
await this.click(productsAdmin.product.subMenus.advanced);
await this.clearAndType(productsAdmin.product.advanced.commissionPercentage, commission.commissionPercentage);
await this.wait(0.5);
await this.wait(1);
await this.clearAndType(productsAdmin.product.advanced.commissionFixed, commission.commissionFixed);
await this.wait(0.5);
await this.wait(1);

// update product
await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, productsAdmin.product.publish);
Expand Down
10 changes: 6 additions & 4 deletions tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ export const selector = {

// dokan promotion
promotion: {
promotion: '.dokan-notice-slides .dokan-promotion',
message: '.dokan-promotion .dokan-message',
promotion: 'div.dokan-notice-slides div.dokan-promotion',
message: 'div.dokan-promotion div.dokan-message',
},

// dokan notice
notice: {
noticeDiv: '.dokan-admin-notices',
noticeDiv1: '.dokan-admin-notice.dokan-alert',
noticeDiv: 'div.dokan-admin-notices',
noticeDiv1: '//div[@class="dokan-admin-notices"]//div[contains(@class,"dokan-admin-notice")and not(contains(@class,"dokan-promotion"))]',
closeNotice: '.close-notice',
slider: '.slide-notice',
sliderPrev: '.slide-notice .prev',
Expand Down Expand Up @@ -5708,6 +5708,8 @@ export const selector = {
edit: (productName: string) => `//a[normalize-space()="${productName}"]/../..//span[@class="edit"]`,
permanentlyDelete: (productName: string) => `//a[normalize-space()="${productName}"]/../..//span[@class="delete"]`,
view: (productName: string) => `//a[normalize-space()="${productName}"]/../..//span[@class="view"]`,
duplicate: (productName: string) => `//a[normalize-space()="${productName}"]/../..//span[@class="duplicate"]`,
duplicateSuccessMessage: '//div[contains(@class,"dokan-alert dokan-alert-success")]//strong[normalize-space(text())="Product successfully duplicated"]',

confirmDelete: '.swal2-confirm',
cancelDelete: '.swal2-cancel',
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions tests/pw/pages/vendorAuctionsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ export class AuctionsPage extends VendorPage {
await this.toBeVisible(auctionProductsVendor.productCell(productName));
}

// duplicate auction product
async duplicateAuctionProduct(productName: string) {
await this.searchAuctionProduct(productName);
await this.removeAttribute(auctionProductsVendor.rowActions(productName), 'class'); // forcing the row actions to be visible, to avoid flakiness
await this.hover(auctionProductsVendor.productCell(productName));
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auction, auctionProductsVendor.duplicate(productName), 302);
await this.toBeVisible(auctionProductsVendor.duplicateSuccessMessage);
await this.toBeVisible(auctionProductsVendor.productCell(productName + ' (Copy)'));
}

// delete auction product
async deleteAuctionProduct(productName: string) {
await this.searchAuctionProduct(productName);
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/tests/e2e/commission.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { payloads } from '@utils/payloads';
import { dbUtils } from '@utils/dbUtils';
import { dbData } from '@utils/dbData';

const { DOKAN_PRO, PRODUCT_ID } = process.env;
const { PRODUCT_ID } = process.env;

test.describe('Commission test', () => {
let admin: CommissionPage;
Expand Down
5 changes: 5 additions & 0 deletions tests/pw/tests/e2e/vendorAuction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ test.describe('Auction Product test', () => {
await vendor.searchAuctionProduct(auctionProductName);
});

test('vendor can duplicate auction product', { tag: ['@pro', '@vendor'] }, async () => {
const [, , auctionProductName] = await apiUtils.createProduct(payloads.createAuctionProduct(), payloads.vendorAuth);
await vendor.duplicateAuctionProduct(auctionProductName);
});

test('vendor can permanently delete auction product', { tag: ['@pro', '@vendor'] }, async () => {
const [, , auctionProductName] = await apiUtils.createProduct(payloads.createAuctionProduct(), payloads.vendorAuth);
await vendor.deleteAuctionProduct(auctionProductName);
Expand Down

0 comments on commit 1f97569

Please sign in to comment.