Skip to content

Commit

Permalink
Add Pro module tests(wholesale, vendorstaff) (test automation) (#2379)
Browse files Browse the repository at this point in the history
* Add Wholesale module tests

* Update featureMap

* Add vendor staff & menu tests

* Fix locator issue

* Fix typos

* Update featureMap

* Rename context
  • Loading branch information
shashwatahalder01 authored Sep 25, 2024
1 parent e73c5df commit 90d99d8
Show file tree
Hide file tree
Showing 30 changed files with 346 additions and 176 deletions.
65 changes: 31 additions & 34 deletions tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
admin can enable shipping method [lite]: true
admin can add flat rate shipping method [lite]: true
admin can add free shipping method [lite]: true
admin can add vendor table rate shipping method: true
admin can add vendor distance rate shipping method: true
admin can add vendor shipping method: true
admin can delete shipping method [lite]: true
admin can delete shipping zone [lite]: true
Expand All @@ -35,8 +33,6 @@
vendor can add flat rate shipping: true
vendor can add free shipping: true
vendor can add local pickup shipping: true
vendor can add table rate shipping: true
vendor can add distance rate shipping: true
vendor can edit shipping method: true
vendor can delete shipping method: true

Expand Down Expand Up @@ -80,6 +76,7 @@
admin can add Dokan news subscriber [lite]: true
vendor:
vendor can view vendor dashboard [lite]: true
vendor can view vendor dashboard menus [lite]: true

- page: 'Products'
features:
Expand Down Expand Up @@ -117,7 +114,6 @@
vendor can add product quantity discount: false
vendor can add product rma options: false
vendor can add product wholesale options: true
vendor can add product min-max options: false
vendor can add product other options [lite]: true
vendor can duplicate product: true
vendor can permanently delete product [lite]: true
Expand Down Expand Up @@ -353,8 +349,6 @@
vendor can set biography settings: true
vendor can set live chat settings: false
vendor can set store support settings: true
vendor can set min-max settings: true
vendor can set shipStation settings: true
vendor can set social profile settings: true
vendor can set rma settings: true
vendor can set store seo settings: true
Expand Down Expand Up @@ -453,7 +447,7 @@
admin can export all logs: true
admin can filter all logs by store name: true
admin can filter all logs by order status: true
# admin can filter all logs by calander: true
# admin can filter all logs by calendar: true
vendor:
vendor can view reports menu page: true
vendor can export statement: true
Expand Down Expand Up @@ -692,12 +686,13 @@
- page: 'MangoPay'
features:
admin:
admin can add Mangopay payment method: false
admin can add Mangopay payment method: true

- page: 'Min Max Quantities'
features:
admin:
no test is written for min-max module: false
vendor:
vendor can add product min-max options: true
vendor can set min-max settings: true

- page: 'PayPal Marketplace'
features:
Expand All @@ -713,7 +708,7 @@
vendor can delete product addon: true
# vendor can add individual product addon [duplicate]: false
vendor can edit individual product product addon: false
vendor can delete individual productproduct addon: false
vendor can delete individual product addon: false
customer:
customer can view product addons on single product page: false
customer can buy product with addons: false
Expand All @@ -728,7 +723,7 @@
admin can set product advertisement cost: false
admin can enable product advertising on dokan subscription: false
admin can set advertised product as featured: false
admin can set advertised product display pefeference: false
admin can set advertised product display preference: false
admin can hide out of stock advertised product: false
admin can add product advertising widget: false
# admin can add product advertising shortcode [duplicate]: false
Expand All @@ -738,7 +733,7 @@
admin can search advertised product by order: false
admin can filter advertised product by stores: true
admin can filter advertised product by creation process: true
# admin can filter advertised product by calander: false
# admin can filter advertised product by calendar: false
admin can expire advertised product: true
admin can delete advertised product: true
admin can perform bulk action on product advertisements: false
Expand Down Expand Up @@ -811,7 +806,7 @@
- page: 'Razorpay'
features:
admin:
admin can add Razorpay payment method: false
admin can add Razorpay payment method: true

- page: 'Report Abuse'
features:
Expand All @@ -821,7 +816,7 @@
admin can filter abuse reports by abuse reason: true
admin can filter abuse reports by product: true
admin can filter abuse reports by vendor: true
admin can perform bulk action on abuse reports: false
admin can perform bulk action on abuse reports: true
customer:
customer can report product: true
guest:
Expand Down Expand Up @@ -849,7 +844,7 @@
admin can permanently delete quote: true
admin can approve quote: true
admin can convert quote to order: true
admin can perform quote bulk actions: false
admin can perform quote bulk actions: true
vendor:
vendor can view request quotes menu page: true
vendor can view request quote details: true
Expand Down Expand Up @@ -903,8 +898,8 @@

- page: 'ShipStation Integration'
features:
admin:
no test is written for shipstation integration: false
vendor:
vendor can set shipStation settings: true

- page: 'Single Product Multiple Vendor (SPMV)'
features:
Expand Down Expand Up @@ -954,7 +949,7 @@
admin can search support ticket by ticket title: true
admin can filter support tickets by vendor: true
admin can filter support tickets by customer: true
# admin can filter support tickets by calander: false
# admin can filter support tickets by calendar: false
admin can reply to support ticket as admin: true
admin can reply to support ticket as vendor: true
admin can disable support ticket email notification: true
Expand Down Expand Up @@ -991,17 +986,21 @@
- page: 'Stripe Connect'
features:
admin:
admin can add stripe payment method: false
admin can add stripe payment method: true

- page: 'Stripe Express'
features:
admin:
admin can add Strip Express payment method: false
admin can add Strip Express payment method: true

- page: 'Table Rate Shipping'
features:
admin:
no test is written for table rate shipping: false
admin can add vendor table rate shipping method: true
admin can add vendor distance rate shipping method: true
vendor:
vendor can add table rate shipping: true
vendor can add distance rate shipping: true

- page: 'Vendor Analytics'
features:
Expand All @@ -1025,8 +1024,8 @@
vendor can edit staff: true
vendor can manage staff permission: true
vendor can delete staff: true
vendorStaff:
vendorStaff can view allowed menus: false
staff:
vendorStaff can view allowed menus: true

- page: 'Vendor Subscription'
features:
Expand Down Expand Up @@ -1069,7 +1068,6 @@
admin can approve verification request: true
admin can reject verification request: true
admin can perform bulk action on verification requests: true
admin receive notification for verification request: false
vendor:
vendor can view verifications settings menu page: true
vendor can submit verification request: true
Expand All @@ -1091,10 +1089,6 @@
- page: 'Wholesale'
features:
admin:
# admin can set Dokan wholesale settings [duplicate]: true
admin can set wholesale price viewer: false
admin can set show wholsesale price on shop archive: false
admin can set need approval for becoming wholesale customer: false
admin can view wholesale customers menu page: true
admin can search wholesale customer: true
admin can disable customer's wholesale capability: true
Expand All @@ -1103,13 +1097,16 @@
admin can view wholesale customer orders: true
admin can delete wholesale customer: true
admin can perform bulk action on wholesale customers: true
All users can see wholesale price: true
vendor:
vendor can create wholesale product: false
vendor can create wholesale product: true
customer:
customer can become a wholesale customer: true
customer can request for become a wholesale customer: true
customer can see wholesale price on shop archive: true
customer can buy wholesale product: true
customer can't see wholesale price on shop archive: true
customer (wholesale) can only see wholesale price: true
customer (wholesale) can buy wholesale product: true

- page: 'WooCommerce Booking Integration'
features:
Expand All @@ -1133,7 +1130,7 @@
vendor can add booking resource: true
vendor can edit booking resource: true
vendor can delete booking resource: true
vendor can add booking for guest customer: false
vendor can add booking for existing customer: false
vendor can add booking for guest customer: true
vendor can add booking for existing customer: true
customer:
customer can buy bookable product: true
12 changes: 6 additions & 6 deletions tests/pw/fixtures/testPage.ts → tests/pw/fixtures/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { VendorStaffPage } from '@pages/vendorStaffPage';
import { VendorToolsPage } from '@pages/vendorToolsPage';
import { VendorVerificationsPage } from '@pages/vendorVerificationsPage';
import { VisualPage } from '@pages/visualPage';
import { WholesaleCustomersPage } from '@pages/wholesaleCustomersPage';
import { WholesalePage } from '@pages/wholesalePage';
import { WithdrawsPage } from '@pages/withdrawsPage';

// types of pages
Expand Down Expand Up @@ -134,7 +134,7 @@ type pages = {
vendorToolsPage: VendorToolsPage;
vendorVerificationsPage: VendorVerificationsPage;
visualPage: VisualPage;
wholesaleCustomersPage: WholesaleCustomersPage;
WholesalePage: WholesalePage;
withdrawsPage: WithdrawsPage;
};

Expand Down Expand Up @@ -399,8 +399,8 @@ export const test = base.extend<pages>({
await use(new VisualPage(page));
},

wholesaleCustomersPage: async ({ page }, use) => {
await use(new WholesaleCustomersPage(page));
WholesalePage: async ({ page }, use) => {
await use(new WholesalePage(page));
},

withdrawsPage: async ({ page }, use) => {
Expand All @@ -410,5 +410,5 @@ export const test = base.extend<pages>({

export { expect, request, Page } from '@playwright/test';

// export const test = testpage;
// export const expect = testpage.expect;
// export const test = page;
// export const expect = page.expect;
10 changes: 5 additions & 5 deletions tests/pw/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ export class BasePage {
await this.page.dblclick(selector);
}

// click & wait for another locator to be visible [userful for modals]
async clickAndWaitForLocatorTobeVisible(selector: string, selector2: string): Promise<void> {
// click & wait for another locator to be visible [useful for modals]
async clickAndWaitForLocatorToBeVisible(selector: string, selector2: string): Promise<void> {
await Promise.all([this.toBeVisible(selector2), this.page.locator(selector).click()]);
}

Expand Down Expand Up @@ -1358,7 +1358,7 @@ export class BasePage {
return this.page.context().pages();
}

// add locator handler [userful for randomly popups] [call before the start of the test]
// add locator handler [useful for randomly popups] [call before the start of the test]
async addLocatorHandler(selector: string, asyncFn: () => Promise<void>, options?: { noWaitAfter?: boolean; times?: number } | undefined): Promise<void> {
const locator = this.page.locator(selector);
await this.page.addLocatorHandler(locator, asyncFn, options);
Expand Down Expand Up @@ -1601,7 +1601,7 @@ export class BasePage {
selector = /^(\/\/|\(\/\/)/.test(selector) ? `${selector}//span` : `${selector} span`;
const value = await this.getElementBackgroundColor(selector);
if (!value.includes('rgb(0, 144, 255)')) {
const [response] = await Promise.all([this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code), this.page.locator(selector).click()]);
const response = await this.clickAndWaitForResponse(subUrl, selector, code);
return response;
}
return '';
Expand All @@ -1612,7 +1612,7 @@ export class BasePage {
selector = /^(\/\/|\(\/\/)/.test(selector) ? `${selector}//span` : `${selector} span`;
const value = await this.getElementBackgroundColor(selector);
if (value.includes('rgb(0, 144, 255)')) {
const [response] = await Promise.all([this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code), this.page.locator(selector).click()]);
const response = await this.clickAndWaitForResponse(subUrl, selector, code);
return response;
}
return '';
Expand Down
14 changes: 7 additions & 7 deletions tests/pw/pages/colorsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,27 @@ export class ColorsPage extends AdminPage {

await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsStore);

// asertions
// assertions

// convert hex to rgb
Object.keys(paletteValues).forEach(key => {
paletteValues[key as keyof paletteValues] = helpers.hexToRgb(paletteValues[key as keyof paletteValues]);
});

// button color
const beforHover = await this.getElementCssStyle(settingsVendor.updateSettingsTop);
const beforeHover = await this.getElementCssStyle(settingsVendor.updateSettingsTop);
// hovered button color
await this.hover(settingsVendor.updateSettingsTop);
const afterHover = await this.getElementCssStyle(settingsVendor.updateSettingsTop);
// sidebar color
const dashboardSidebarMenuText = await this.getElementColor(dashboardVendor.menus.dashboard);
const dashboardSidebarMenuText = await this.getElementColor(dashboardVendor.menus.primary.dashboard);
const dashboardSidebarBackground = await this.getElementBackgroundColor(dashboardVendor.menus.menus);
const dashboardSidebarActiveMenuBackground = await this.getElementBackgroundColor(dashboardVendor.menus.activeMenu);
const dashboardSidebarActiveHoverMenuText = await this.getElementColor(dashboardVendor.menus.settings);
const dashboardSidebarActiveHoverMenuText = await this.getElementColor(dashboardVendor.menus.primary.settings);

expect(beforHover.color).toEqual(paletteValues.buttonText);
expect(beforHover.backgroundColor).toEqual(paletteValues.buttonBackground);
expect(beforHover.borderColor).toEqual(paletteValues.buttonBorder);
expect(beforeHover.color).toEqual(paletteValues.buttonText);
expect(beforeHover.backgroundColor).toEqual(paletteValues.buttonBackground);
expect(beforeHover.borderColor).toEqual(paletteValues.buttonBorder);
expect(afterHover.color).toEqual(paletteValues.buttonHoverText);
expect(afterHover.backgroundColor).toEqual(paletteValues.buttonHoverBackground);
expect(afterHover.borderColor).toEqual(paletteValues.buttonHoverBorder);
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/pages/customerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class CustomerPage extends BasePage {

// skip vendor setup wizard
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.dashboard, selector.vendor.vSetup.notRightNow);
await this.toBeVisible(selector.vendor.vDashboard.menus.dashboard);
await this.toBeVisible(selector.vendor.vDashboard.menus.primary.dashboard);
}

// customer add customer details
Expand Down
Loading

0 comments on commit 90d99d8

Please sign in to comment.