Skip to content

Commit

Permalink
add: added new test
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Mar 7, 2024
1 parent cdd8765 commit ffbc5f2
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e_api_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
if: success()
run: |
cd tests/pw
npm ci
npm ci || npm i
# Create wp debuglog file
- name: Create wp debuglog file
Expand Down
6 changes: 6 additions & 0 deletions tests/pw/pages/licensePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export class LicensePage extends AdminPage {
}
}

// refresh license
async refresehLicense() {
await this.goIfNotThere(data.subUrls.backend.dokan.license);
await this.clickAndWaitForResponse(data.subUrls.backend.dokan.license, licenseAdmin.refreshLicense);
await this.toContainText(licenseAdmin.successNotice, 'License refreshed successfully.');
}
// deactivate license
async deactivateLicense() {
await this.goIfNotThere(data.subUrls.backend.dokan.license);
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ export const selector = {
announcements: {
announcementText: '.dokan-announcement-wrapper h1',

addNewAnnouncement: '//a[normalize-space()="Add Announcement"]',
addNewAnnouncement: '//button[normalize-space()="Add Announcement"]',

// Nav Tabs
navTabs: {
Expand Down
18 changes: 18 additions & 0 deletions tests/pw/tests/e2e/_env.setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test as setup, expect, request, Page } from '@playwright/test';
import { LicensePage } from '@pages/licensePage';
import { ProductAdvertisingPage } from '@pages/productAdvertisingPage';
import { ReverseWithdrawsPage } from '@pages/reverseWithdrawsPage';
import { VendorSettingsPage } from '@pages/vendorSettingsPage';
Expand Down Expand Up @@ -98,6 +99,17 @@ setup.describe('setup site & woocommerce & user settings', () => {
await apiUtils.createAttributeTerm(attributeId, { name: 'm' });
});

setup('set dokan license @pro', async () => {
setup.skip(!DOKAN_PRO, 'skip on lite');
await dbUtils.setDokanSettings(dbData.dokan.optionName.dokanProLicense, dbData.dokan.dokanProLicense);
await dbUtils.setDokanSettings(dbData.dokan.optionName.dokanProActiveModules, dbData.dokan.dokanProActiveModules);
});

setup('activate all dokan modules @pro', async () => {
setup.skip(!DOKAN_PRO, 'skip on lite');
await dbUtils.setDokanSettings(dbData.dokan.optionName.dokanProActiveModules, dbData.dokan.dokanProActiveModules);
});

setup('check active dokan modules @pro', async () => {
setup.skip(!DOKAN_PRO, 'skip on lite');
const activeModules = await apiUtils.getAllModuleIds({ status: 'active' });
Expand Down Expand Up @@ -268,6 +280,7 @@ setup.describe('setup dokan settings', () => {
});

setup.describe('setup dokan settings e2e', () => {
let licensePage: LicensePage;
let productAdvertisingPage: ProductAdvertisingPage;
let reverseWithdrawsPage: ReverseWithdrawsPage;
let vendorPage: VendorSettingsPage;
Expand All @@ -277,6 +290,7 @@ setup.describe('setup dokan settings e2e', () => {
setup.beforeAll(async ({ browser }) => {
const adminContext = await browser.newContext(data.auth.adminAuth);
aPage = await adminContext.newPage();
licensePage = new LicensePage(aPage);
productAdvertisingPage = new ProductAdvertisingPage(aPage);
reverseWithdrawsPage = new ReverseWithdrawsPage(aPage);

Expand All @@ -293,6 +307,10 @@ setup.describe('setup dokan settings e2e', () => {
await apiUtils.dispose();
});

setup('admin can refreseh license @pro @a', async () => {
await licensePage.refresehLicense();
});

setup('recreate reverse withdrawal payment product via settings save @lite', async () => {
await reverseWithdrawsPage.reCreateReverseWithdrawalPaymentViaSettingsSave();
});
Expand Down
4 changes: 4 additions & 0 deletions tests/pw/tests/e2e/license.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ test.describe('License test', () => {
await admin.activateLicense(data.dokanLicense.correctKey);
});

test('admin can refreseh license @pro @a', async () => {
await admin.refresehLicense();
});

test.skip('admin can deactivate license @pro @a', async () => {
await admin.activateLicense(data.dokanLicense.correctKey);
await admin.deactivateLicense();
Expand Down
10 changes: 9 additions & 1 deletion tests/pw/utils/apiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export class ApiUtils {

// get product exists or not
async checkProductExistence(productName: string, auth?: auth): Promise<string | boolean> {
const allProducts = await this.getAllProducts(auth);
const allProducts = await this.getAllProductsWc(auth);
const res = allProducts.find((o: { name: string }) => o.name.toLowerCase() === productName.toLowerCase())?.id ?? false;
return res;
}
Expand Down Expand Up @@ -1604,6 +1604,14 @@ export class ApiUtils {
return [response, responseBody];
}

// product

// get all products
async getAllProductsWc(auth?: auth): Promise<responseBody> {
const [, responseBody] = await this.get(endPoints.wc.getAllProducts, { params: { per_page: 100 }, headers: auth });
return responseBody;
}

// order

// get all site orders
Expand Down
59 changes: 59 additions & 0 deletions tests/pw/utils/dbData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const dbData = {
vendorSubscription: 'dokan_product_subscription',
// vendorAnalytics:
dokanActiveModules: 'dokan_pro_active_modules',

// dokanPro
dokanProLicense: 'dokan_pro_license',
dokanProActiveModules: 'dokan_pro_active_modules',
},

generalSettings: {
Expand Down Expand Up @@ -1087,6 +1091,61 @@ export const dbData = {
alert_email_body: 'Dear subscriber, Your subscription will be ending soon. Please renew your package in a timely',
},


// dokan pro license
dokanProLicense: {
key: '74c8654e-84a5-49b2-a3f5-81afba8e13fa',
status: 'activate',
remaining: 42,
activation_limit: 50,
expiry_days: 329,
title: 'Business',
source_id: 'dokan-business',
recurring: 1,
},

// dokan pro modules
dokanProActiveModules: [
'booking',
'auction',
'color_scheme_customizer',
'delivery_time',
'elementor',
'germanized',
'follow_store',
'geolocation',
'live_chat',
'live_search',
'mangopay',
'order_min_max',
'paypal_marketplace',
'product_addon',
'product_advertising',
'product_enquiry',
'vsp',
'rank_math',
'razorpay',
'report_abuse',
'request_for_quotation',
'rma',
'seller_badge',
'seller_vacation',
'shipstation',
'spmv',
'store_reviews',
'store_support',
'stripe',
'stripe_express',
'table_rate_shipping',
'vendor_analytics',
'export_import',
'vendor_staff',
'product_subscription',
'vendor_verification',
'wholesale',
'moip',
],

// modules
modules: [
'booking',
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/utils/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,7 @@ export const payloads = {
email: process.env.VENDOR + '@yopmail.com',
store_name: process.env.VENDOR + 'store',
first_name: process.env.VENDOR,
last_name: 'v1',
last_name: 'v',
social: {
fb: 'http://dokan.test',
youtube: 'http://dokan.test',
Expand Down

0 comments on commit ffbc5f2

Please sign in to comment.