From ffbc5f20b3069b33dd7cb8b23830a6c1b1553acd Mon Sep 17 00:00:00 2001 From: shashwata Date: Thu, 7 Mar 2024 14:02:39 +0600 Subject: [PATCH] add: added new test --- .github/workflows/e2e_api_tests.yml | 2 +- tests/pw/pages/licensePage.ts | 6 +++ tests/pw/pages/selectors.ts | 2 +- tests/pw/tests/e2e/_env.setup.ts | 18 +++++++++ tests/pw/tests/e2e/license.spec.ts | 4 ++ tests/pw/utils/apiUtils.ts | 10 ++++- tests/pw/utils/dbData.ts | 59 +++++++++++++++++++++++++++++ tests/pw/utils/payloads.ts | 2 +- 8 files changed, 99 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e_api_tests.yml b/.github/workflows/e2e_api_tests.yml index df8d35fcbb..3d344b1cdd 100644 --- a/.github/workflows/e2e_api_tests.yml +++ b/.github/workflows/e2e_api_tests.yml @@ -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 diff --git a/tests/pw/pages/licensePage.ts b/tests/pw/pages/licensePage.ts index ef3964d8b9..439d753a3b 100644 --- a/tests/pw/pages/licensePage.ts +++ b/tests/pw/pages/licensePage.ts @@ -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); diff --git a/tests/pw/pages/selectors.ts b/tests/pw/pages/selectors.ts index c13a270327..d8f746a18c 100644 --- a/tests/pw/pages/selectors.ts +++ b/tests/pw/pages/selectors.ts @@ -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: { diff --git a/tests/pw/tests/e2e/_env.setup.ts b/tests/pw/tests/e2e/_env.setup.ts index 89049f2960..acd2650edf 100644 --- a/tests/pw/tests/e2e/_env.setup.ts +++ b/tests/pw/tests/e2e/_env.setup.ts @@ -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'; @@ -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' }); @@ -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; @@ -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); @@ -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(); }); diff --git a/tests/pw/tests/e2e/license.spec.ts b/tests/pw/tests/e2e/license.spec.ts index deb2d8098d..45c9556ec0 100644 --- a/tests/pw/tests/e2e/license.spec.ts +++ b/tests/pw/tests/e2e/license.spec.ts @@ -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(); diff --git a/tests/pw/utils/apiUtils.ts b/tests/pw/utils/apiUtils.ts index 58fec6c50d..2dd761d0a7 100644 --- a/tests/pw/utils/apiUtils.ts +++ b/tests/pw/utils/apiUtils.ts @@ -296,7 +296,7 @@ export class ApiUtils { // get product exists or not async checkProductExistence(productName: string, auth?: auth): Promise { - 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; } @@ -1604,6 +1604,14 @@ export class ApiUtils { return [response, responseBody]; } + // product + + // get all products + async getAllProductsWc(auth?: auth): Promise { + const [, responseBody] = await this.get(endPoints.wc.getAllProducts, { params: { per_page: 100 }, headers: auth }); + return responseBody; + } + // order // get all site orders diff --git a/tests/pw/utils/dbData.ts b/tests/pw/utils/dbData.ts index 457e17bd3d..25dc124cfa 100644 --- a/tests/pw/utils/dbData.ts +++ b/tests/pw/utils/dbData.ts @@ -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: { @@ -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', diff --git a/tests/pw/utils/payloads.ts b/tests/pw/utils/payloads.ts index c50063e8d2..a8476c3bfa 100644 --- a/tests/pw/utils/payloads.ts +++ b/tests/pw/utils/payloads.ts @@ -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',