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 E2E tests for shortcode, commission, geolocation #2441

Merged
merged 9 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion tests/pw/api.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { CI, BASE_URL, NO_SETUP, ADMIN, ADMIN_PASSWORD, DOKAN_PRO } = process.env

export default defineConfig({
/* test directory */
testDir: './tests/api',
testDir: 'tests/api',
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
/* Include tests based on the pattern */
grep: [/@lite/, /@pro/],
/* Exclude tests based on the pattern */
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { CI, NON_HEADLESS, BASE_URL, SLOWMO, NO_SETUP, DOKAN_PRO } = process.env;

export default defineConfig({
/* test directory */
testDir: './tests/e2e',
testDir: 'tests/e2e',
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
/* Include tests based on the pattern */
grep: [/@lite/, /@liteOnly/, /@pro/],
/* Exclude tests based on the pattern */
Expand Down
82 changes: 45 additions & 37 deletions tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
features:
admin:
admin can install Dokan plugin [lite]: false
admin can activate Dokan plugin [lite]: false
admin can deactivate Dokan plugin [lite]: false
admin can deactivate Dokan plugin with deactivate reason [lite]: false
admin can delete Dokan plugin [lite]: false
admin can activate Dokan plugin [lite]: true
admin can deactivate Dokan plugin [lite]: true
admin can deactivate Dokan plugin with deactivate reason [lite]: true
admin can delete Dokan plugin [lite]: true
admin can install Dokan pro plugin: false
admin can activate Dokan pro plugin: false
admin can deactivate Dokan pro plugin: false
admin can deactivate Dokan pro plugin with deactivate reason: false
admin can delete Dokan pro plugin: false
admin can activate Dokan pro plugin: true
admin can deactivate Dokan pro plugin: true
admin can deactivate Dokan pro plugin with deactivate reason: true
admin can delete Dokan pro plugin: true

- page: 'Tax'
features:
Expand Down Expand Up @@ -314,12 +314,12 @@
customer can view stores on map: true
customer can go to single store from store list [lite]: true

- page: 'Stores'
- page: 'Vendors'
features:
admin:
admin can view vendors menu page [lite]: true
admin can filter vendors by pending status: false
admin can filter vendors by approved status: false
admin can filter vendors by status (pending): true
admin can filter vendors by status (approved): true
admin can search vendors [lite]: true
admin can view vendor details: true
admin can disable vendor's selling capability [lite]: true
Expand Down Expand Up @@ -347,6 +347,7 @@
admin can set commission to Dokan subscription product (fixed): true
admin can set commission to Dokan subscription product (category based): true
admin can set commission to Dokan subscription product (specific category based): true
admin can view commission meta-box on order details [lite]: true

- page: 'Withdraw'
features:
Expand All @@ -357,7 +358,7 @@
admin can filter withdrawal requests by cancelled status: true
admin can filter withdrawal requests by vendor [lite]: true
admin can filter withdrawal requests by payment methods [lite]: true
admin can filter withdrawal requests by date: false
# admin can filter withdrawal requests by date: false
admin can clear withdrawal request filters: false
admin can export withdrawal requests [lite]: true
admin can add note to withdrawal request [lite]: true
Expand All @@ -379,7 +380,7 @@
admin:
admin can view reverse withdrawal menu page [lite]: true
admin can filter reverse withdrawal by store [lite]: true
admin can filter reverse withdrawal by date [lite]: false
# admin can filter reverse withdrawal by date [lite]: false
admin can clear reverse withdrawal filters: true
admin can add reverse withdrawal [lite]: true
vendor:
Expand Down Expand Up @@ -412,6 +413,13 @@
customer can contact vendor [lite]: true
customer can navigate to Dokan privacy policy [lite]: true

- page: 'Diagnostic Notice'
features:
admin:
admin can view Dokan diagnostic notice [lite]: true
admin can allow Dokan diagnostic tracking [lite]: true
admin can disallow Dokan diagnostic tracking [lite]: true

shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
- page: 'Notice And Promotion'
features:
admin:
Expand All @@ -438,7 +446,7 @@
customer can view top rated products (shortcode): true
customer can view customer migration form (shortcode): true
customer can view geolocation filter form (shortcode): true
customer can view advertised products (shortcode): false
customer can view advertised products (shortcode): true
customer can view stores (shortcode): true
customer can view my orders (shortcode): true
customer can view request for quote (shortcode): true
Expand All @@ -460,7 +468,7 @@
vendor can set vacation settings: true
vendor can set discount settings: true
vendor can set biography settings: true
vendor can set live chat settings: false
vendor can set live chat settings: true
vendor can set store support settings: true
vendor can set social profile settings: true
vendor can set rma settings (no warranty): true
Expand Down Expand Up @@ -534,7 +542,7 @@
- page: 'coupons'
features:
admin:
admin can add marketplace coupon: false
admin can add marketplace coupon: true
vendor:
vendor can view coupons menu page: true
vendor can view marketPlace coupons: true
Expand Down Expand Up @@ -597,7 +605,7 @@
admin can trash announcement: true
admin can restore announcement: true
admin can permanently delete announcement: true
admin can perform bulk action on announcements: false
admin can perform bulk action on announcements: true
vendor:
vendor can view announcements menu page: true
vendor can view announcement details: true
Expand Down Expand Up @@ -638,10 +646,10 @@
features:
admin:
admin can view license menu page: true
admin can't activate license with incorrect key: false
admin can activate license: false
admin can't activate license with incorrect key: true
admin can activate license: true
admin can refresh license: true
admin can deactivate license: false
admin can deactivate license: true

- page: 'Modules'
features:
Expand Down Expand Up @@ -720,7 +728,7 @@

customer:
customer can bid auction product: true
customer can buy auction product with buy it now price: false
customer can buy auction product with buy it now price: true

- page: 'Color Scheme Customizer'
features:
Expand Down Expand Up @@ -870,7 +878,7 @@
- page: 'PayPal Marketplace'
features:
admin:
admin can add Paypal Marketplace payment method: false
admin can add Paypal Marketplace payment method: true

- page: 'Printful'
features:
Expand Down Expand Up @@ -928,7 +936,7 @@
# 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
admin can perform bulk action on product advertisements: true
vendor:
vendor can buy product advertising (product list page): true
vendor can buy product advertising (product edit page): false
Expand Down Expand Up @@ -977,18 +985,18 @@
features:
vendor:
vendor can view user subscriptions menu page: true
vendor can view product subscription details: false
vendor can filter user subscriptions by customer: false
vendor can filter user subscriptions by date: false
vendor can view user subscription: false
vendor can view product subscription details: true
vendor can filter user subscriptions by customer: true
vendor can filter user subscriptions by date: true
vendor can view user subscription: true
customer:
customer can view product subscription details: false
customer can cancel subscription: false
customer can reactivate subscription: false
customer can change address of subscription: false
customer can change payment of subscription: false
customer can renew subscription: false
customer can buy product subscription: false
customer can view product subscription details: true
customer can cancel subscription: true
customer can reactivate subscription: true
customer can change address of subscription: true
customer can change payment of subscription: true
customer can renew subscription: true
customer can buy product subscription: true

- page: 'Rank Math SEO'
features:
Expand Down Expand Up @@ -1076,8 +1084,8 @@
admin can search seller badge: true
admin can create seller badge: true
admin can edit seller badge: true
admin can filter vendors by seller badge: false
admin can view seller badge vendors: false
admin can filter vendors by seller badge: true
admin can view seller badge vendors: true
admin can view seller badges acquired by vendor: true
admin can update seller badge status: true
admin can delete seller badge: true
Expand Down Expand Up @@ -1227,7 +1235,7 @@
admin can filter subscribed vendors by subscription pack: true
admin can cancel subscription (immediately): true
admin can cancel subscription (end of the current period): true
admin can reactive recurring subscription (has active period ): false
admin can reactive recurring subscription (has active period): false
admin can perform bulk action on subscribed vendors: true
admin can assign non recurring subscription pack to vendor: true
vendor:
Expand Down
10 changes: 8 additions & 2 deletions tests/pw/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ export class BasePage {
}

// goto subUrl
async goto(subPath: string, options: { referer?: string; timeout?: number; waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit' } | undefined = { waitUntil: 'domcontentloaded' }): Promise<void> {
async goto(subPath: string, options: { referer?: string; timeout?: number; waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit' } | undefined = { waitUntil: 'domcontentloaded' }, force = false): Promise<void> {
await this.page.goto(subPath, options);
if (force) {
await this.reload();
}
}

// goto subUrl until networkidle
async gotoUntilNetworkidle(subPath: string, options: { referer?: string; timeout?: number; waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit' } | undefined = { waitUntil: 'networkidle' }): Promise<void> {
async gotoUntilNetworkidle(subPath: string, options: { referer?: string; timeout?: number; waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit' } | undefined = { waitUntil: 'networkidle' }, force = false): Promise<void> {
await this.goto(subPath, options);
if (force) {
await this.reload();
}
}

// go forward
Expand Down
8 changes: 8 additions & 0 deletions tests/pw/pages/commissionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,12 @@ export class CommissionPage extends AdminPage {
await this.click(productsAdmin.product.subMenus.commission);
await this.assertCommission(commission);
}

// view commission metabox
async viewCommissionMetaBox(orderId: string) {
await this.gotoUntilNetworkidle(data.subUrls.backend.orderDetails(orderId));

// metabox elements are visible
await this.multipleElementVisible(selector.admin.wooCommerce.orders.commissionMetaBox);
}
}
23 changes: 23 additions & 0 deletions tests/pw/pages/noticeAndPromotionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Page } from '@playwright/test';
import { AdminPage } from '@pages/adminPage';
import { selector } from '@pages/selectors';
import { data } from '@utils/testData';
import { diagnosticNotice } from '@utils/interfaces';

export class NoticeAndPromotionPage extends AdminPage {
constructor(page: Page) {
Expand Down Expand Up @@ -74,4 +75,26 @@ export class NoticeAndPromotionPage extends AdminPage {
// settings pro advertisement banner elements are visible
await this.multipleElementVisible(selector.admin.dokan.settings.proAdvertisementBanner);
}

// dokan diagnostic notice
async dokanDiagnosticNoticeRenderProperly(diagnosticNotice: diagnosticNotice) {
await this.gotoUntilNetworkidle(data.subUrls.backend.adminDashboard);
await this.toBeVisible(selector.admin.dokan.diagnostic.noticeDiv);
await this.toContainText(selector.admin.dokan.diagnostic.paragraph1, diagnosticNotice.paragraph1);
await this.toContainText(selector.admin.dokan.diagnostic.paragraph2, diagnosticNotice.paragraph2);
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
}

// allow diagnostic tracking
async allowDiagnosticTracking() {
await this.goIfNotThere(data.subUrls.backend.adminDashboard, 'networkidle');
await this.clickAndWaitForResponse(data.subUrls.backend.diagnosticNotice, selector.admin.dokan.diagnostic.allowCollectData, 302);
await this.notToBeVisible(selector.admin.dokan.diagnostic.noticeDiv);
}

// allow diagnostic tracking
async disallowDiagnosticTracking() {
await this.goIfNotThere(data.subUrls.backend.adminDashboard, 'networkidle');
await this.clickAndWaitForLoadState(selector.admin.dokan.diagnostic.disallowCollectData);
await this.notToBeVisible(selector.admin.dokan.diagnostic.noticeDiv);
}
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
}
17 changes: 16 additions & 1 deletion tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ export const selector = {
sliderNext: '.slide-notice .next',
},

diagnostic: {
noticeDiv: '//a[@class="dokan-insights-data-we-collect"]/../..',
allowCollectData: '//a[@class="dokan-insights-data-we-collect"]/../..//a[normalize-space()="Allow"]',
disallowCollectData: '//a[@class="dokan-insights-data-we-collect"]/../..//a[normalize-space()="No thanks"]',
paragraph1: '(//a[@class="dokan-insights-data-we-collect"]/../..//p)[1]',
paragraph2: '//a[@class="dokan-insights-data-we-collect"]/../..//p[@class="description"]',
},

// promo banner
promoBanner: {
promoBanner: '.dokan-promo-banner',
Expand Down Expand Up @@ -433,7 +441,7 @@ export const selector = {

// Nav Tabs
navTabs: {
cancelled: '//ul[@class="subsubsub"]//li//a[contains(text(),"All")]',
all: '//ul[@class="subsubsub"]//li//a[contains(text(),"All")]',
approved: '//ul[@class="subsubsub"]//li//a[contains(text(),"Approved")]',
pending: '//ul[@class="subsubsub"]//li//a[contains(text(),"Pending")]',
},
Expand Down Expand Up @@ -2972,6 +2980,13 @@ export const selector = {
//table
numberOfRowsFound: '(//span[@class="displaying-num"])[1]',
noRowsFound: '//td[normalize-space(text())="No items found."]',

commissionMetaBox: {
metaBoxDiv: 'div#dokan_commission_box',
commissionsText: '//h2[normalize-space()="Commissions"]',
orderItemInfo: 'div#dokan_commission_box table.woocommerce_order_items',
orderTotalInfo: 'div#dokan_commission_box div.wc-order-totals-items',
},
},
},

Expand Down
15 changes: 15 additions & 0 deletions tests/pw/pages/shortcodePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,19 @@ export class ShortcodePage extends AdminPage {
async viewRequestQuote(link: string) {
await this.requestForQuotationsPage.requestForQuoteRenderProperly(link);
}

// view advertised products
async viewAdvertisedProducts(link: string) {
await this.goto(link);

const productCount = await this.getElementCount(shopCustomer.productCard.card);
if (productCount) {
// product card elements are visible
await this.notToHaveCount(shopCustomer.productCard.card, 0);
await this.notToHaveCount(shopCustomer.productCard.productDetailsLink, 0);
await this.notToHaveCount(shopCustomer.productCard.productTitle, 0);
await this.notToHaveCount(shopCustomer.productCard.productPrice, 0);
await this.notToHaveCount(shopCustomer.productCard.addToCart, 0);
}
}
}
19 changes: 19 additions & 0 deletions tests/pw/pages/storesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,25 @@ export class StoresPage extends AdminPage {
}
}

// filter vendors
async filterVendors(filterBy: string): Promise<void> {
await this.goIfNotThere(data.subUrls.backend.dokan.vendors);

switch (filterBy) {
case 'pending':
await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.stores, vendors.navTabs.pending);
break;

case 'approved':
await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.stores, vendors.navTabs.approved);
break;

default:
break;
}
await this.notToHaveCount(vendors.numberOfRows, 0);
}
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved

// update vendor
async updateVendor(vendorName: string, action: string) {
await this.searchVendor(vendorName);
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { customExpect } from '@utils/pwMatchers';
const { CI, NON_HEADLESS, BASE_URL, SLOWMO } = process.env;

export default defineConfig({
testDir: './tests/',
testDir: 'tests',
testMatch: /.*\.spec\.ts/,
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
outputDir: 'playwright/test-artifacts/',
Expand Down
Loading
Loading