From 9a21a8422dc7593dd2630aca200f56e7ab985848 Mon Sep 17 00:00:00 2001 From: shashwata Halder Date: Wed, 2 Oct 2024 08:41:55 +0600 Subject: [PATCH 1/4] Add: add product form tests (#2385) --- tests/pw/feature-map/feature-map.yml | 10 +++ tests/pw/pages/productsPage.ts | 76 ++++++++++++++++++++++ tests/pw/tests/e2e/productsDetails.spec.ts | 56 ++++++++++++++++ 3 files changed, 142 insertions(+) diff --git a/tests/pw/feature-map/feature-map.yml b/tests/pw/feature-map/feature-map.yml index 8e32b04d70..fc0572af2b 100644 --- a/tests/pw/feature-map/feature-map.yml +++ b/tests/pw/feature-map/feature-map.yml @@ -136,6 +136,16 @@ vendor can add product tags [lite]: true vendor can remove product tags [lite]: true vendor can create product tags: true + vendor can add product cover image [lite]: true + vendor can update product cover image [lite]: true + vendor can remove product cover image [lite]: true + vendor can add product gallery image [lite]: true + vendor can update product gallery image [lite]: true + vendor can remove product gallery image [lite]: true + vendor can add product short description [lite]: true + vendor can update product short description [lite]: true + vendor can remove product short description [lite]: true + vendor can update product description [lite]: true - page: 'MyOrders' features: diff --git a/tests/pw/pages/productsPage.ts b/tests/pw/pages/productsPage.ts index e884b42d25..a802e6abe9 100644 --- a/tests/pw/pages/productsPage.ts +++ b/tests/pw/pages/productsPage.ts @@ -928,6 +928,82 @@ export class ProductsPage extends AdminPage { } } + // add product cover image + async addProductCoverImage(productName: string, coverImage: string, removePrevious: boolean = false): Promise { + await this.goToProductEdit(productName); + // remove previous cover image + if (removePrevious) { + await this.hover(productsVendor.image.coverImageDiv); + await this.click(productsVendor.image.removeFeatureImage); + await this.toBeVisible(productsVendor.image.uploadImageText); + } + await this.click(productsVendor.image.cover); + await this.uploadMedia(coverImage); + await this.saveProduct(); + await this.toHaveAttribute(productsVendor.image.uploadedFeatureImage, 'src', /.+/); // Ensures 'src' has any non-falsy value + await this.notToBeVisible(productsVendor.image.uploadImageText); + } + + // remove product cover image + async removeProductCoverImage(productName: string): Promise { + await this.goToProductEdit(productName); + await this.hover(productsVendor.image.coverImageDiv); + await this.click(productsVendor.image.removeFeatureImage); + await this.saveProduct(); + await this.toHaveAttribute(productsVendor.image.uploadedFeatureImage, 'src', /^$/); + await this.toBeVisible(productsVendor.image.uploadImageText); + } + + // add product gallery images + async addProductGalleryImages(productName: string, galleryImages: string[], removePrevious: boolean = false): Promise { + await this.goToProductEdit(productName); + // remove previous gallery images + if (removePrevious) { + const imageCount = await this.getElementCount(productsVendor.image.uploadedGalleryImage); + for (let i = 0; i < imageCount; i++) { + await this.hover(productsVendor.image.galleryImageDiv); + await this.click(productsVendor.image.removeGalleryImage); + } + await this.toHaveCount(productsVendor.image.uploadedGalleryImage, 0); + } + + for (const galleryImage of galleryImages) { + await this.click(productsVendor.image.gallery); + await this.uploadMedia(galleryImage); + } + await this.saveProduct(); + await this.toHaveCount(productsVendor.image.uploadedGalleryImage, galleryImages.length); + } + + // remove product gallery images + async removeProductGalleryImages(productName: string): Promise { + await this.goToProductEdit(productName); + const imageCount = await this.getElementCount(productsVendor.image.uploadedGalleryImage); + for (let i = 0; i < imageCount; i++) { + await this.hover(productsVendor.image.galleryImageDiv); + await this.click(productsVendor.image.removeGalleryImage); + } + await this.saveProduct(); + await this.toHaveCount(productsVendor.image.uploadedGalleryImage, 0); + } + + // add product short description + async addProductShortDescription(productName: string, shortDescription: string): Promise { + await this.goToProductEdit(productName); + await this.typeFrameSelector(productsVendor.shortDescription.shortDescriptionIframe, productsVendor.shortDescription.shortDescriptionHtmlBody, shortDescription); + await this.saveProduct(); + await this.toContainTextFrameLocator(productsVendor.shortDescription.shortDescriptionIframe, productsVendor.shortDescription.shortDescriptionHtmlBody, shortDescription); + } + + // add product description + async addProductDescription(productName: string, description: string): Promise { + await this.goToProductEdit(productName); + await this.typeFrameSelector(productsVendor.description.descriptionIframe, productsVendor.description.descriptionHtmlBody, description); + await this.saveProduct(); + await this.toContainTextFrameLocator(productsVendor.description.descriptionIframe, productsVendor.description.descriptionHtmlBody, description); + } + + // add product catalog mode async addProductCatalogMode(productName: string, hidePrice: boolean = false): Promise { await this.goToProductEdit(productName); diff --git a/tests/pw/tests/e2e/productsDetails.spec.ts b/tests/pw/tests/e2e/productsDetails.spec.ts index 0038c48432..ffbedaa490 100644 --- a/tests/pw/tests/e2e/productsDetails.spec.ts +++ b/tests/pw/tests/e2e/productsDetails.spec.ts @@ -156,4 +156,60 @@ test.describe('Product details functionality test', () => { await vendor.addProductTags(productName, data.product.productInfo.tags.randomTags); }); + // product cover image + + test('vendor can add product cover image', { tag: ['@lite', '@vendor'] }, async () => { + await vendor.addProductCoverImage(productName1, data.product.productInfo.images.cover); + }); + + test('vendor can update product cover image', { tag: ['@lite', '@vendor'] }, async () => { + // todo: need a product with cover image + await vendor.addProductCoverImage(productName, data.product.productInfo.images.cover); + await vendor.addProductCoverImage(productName, data.product.productInfo.images.cover, true); + }); + + test('vendor can remove product cover image', { tag: ['@lite', '@vendor'] }, async () => { + // todo: need a product with cover image + await vendor.addProductCoverImage(productName, data.product.productInfo.images.cover, true); + await vendor.removeProductCoverImage(productName); + }); + + // product gallery image + + test('vendor can add product gallery image', { tag: ['@lite', '@vendor'] }, async () => { + await vendor.addProductGalleryImages(productName1, data.product.productInfo.images.gallery); + }); + + test('vendor can update product gallery image', { tag: ['@lite', '@vendor'] }, async () => { + // todo: need a product with gallery images + await vendor.addProductGalleryImages(productName, data.product.productInfo.images.gallery); + await vendor.addProductGalleryImages(productName, data.product.productInfo.images.gallery, true); + }); + + test('vendor can remove product gallery image', { tag: ['@lite', '@vendor'] }, async () => { + // todo: need a product with gallery images + await vendor.addProductGalleryImages(productName, data.product.productInfo.images.gallery, true); + await vendor.removeProductGalleryImages(productName); + }); + + // product short description + + test('vendor can add product short description', { tag: ['@lite', '@vendor'] }, async () => { + await vendor.addProductShortDescription(productName1, data.product.productInfo.description.shortDescription); + }); + + test('vendor can update product short description', { tag: ['@lite', '@vendor'] }, async () => { + await vendor.addProductShortDescription(productName, data.product.productInfo.description.shortDescription); + }); + + test('vendor can remove product short description', { tag: ['@lite', '@vendor'] }, async () => { + await vendor.addProductShortDescription(productName, ''); + }); + + // product description + + test('vendor can update product description', { tag: ['@lite', '@vendor'] }, async () => { + await vendor.addProductDescription(productName, data.product.productInfo.description.description); + }); + }); From 8d546e4d6f7626a67f5546e514bb7433be37d4ae Mon Sep 17 00:00:00 2001 From: shashwata Date: Wed, 2 Oct 2024 14:57:07 +0600 Subject: [PATCH 2/4] Add: add vendor payment tests --- tests/pw/pages/paymentsPage.ts | 80 +++++++++++------------------ tests/pw/tests/e2e/payments.spec.ts | 59 ++++++++++++++++----- tests/pw/utils/dbData.ts | 24 +++++++++ tests/pw/utils/helpers.ts | 8 ++- tests/pw/utils/testData.ts | 1 - 5 files changed, 107 insertions(+), 65 deletions(-) diff --git a/tests/pw/pages/paymentsPage.ts b/tests/pw/pages/paymentsPage.ts index 3c13eaffb7..4b1189e189 100644 --- a/tests/pw/pages/paymentsPage.ts +++ b/tests/pw/pages/paymentsPage.ts @@ -16,13 +16,13 @@ export class PaymentsPage extends AdminPage { // payment methods - async goToPaymentSettings() { + async goToWcPaymentSettings() { await this.goIfNotThere(data.subUrls.backend.wc.paymentSettings); } // admin setup basic payment methods async setupBasicPaymentMethods(payment: payment) { - await this.goToPaymentSettings(); + await this.goToWcPaymentSettings(); // bank transfer await this.enablePaymentMethod(paymentSettingsAdmin.enableDirectBankTransfer); @@ -38,7 +38,7 @@ export class PaymentsPage extends AdminPage { // admin setup stripe sonnect async setupStripeConnect(payment: payment) { - await this.goToPaymentSettings(); + await this.goToWcPaymentSettings(); await this.click(paymentSettingsAdmin.setupDokanStripeConnect); // setup strip connect @@ -63,7 +63,7 @@ export class PaymentsPage extends AdminPage { // admin setup dokan paypal marketplace async setupPaypalMarketPlace(payment: payment) { - await this.goToPaymentSettings(); + await this.goToWcPaymentSettings(); await this.click(paymentSettingsAdmin.setupDokanPayPalMarketplace); // setup paypal marketplace @@ -91,7 +91,7 @@ export class PaymentsPage extends AdminPage { // admin setup mangopay async setupMangoPay(payment: payment) { - await this.goToPaymentSettings(); + await this.goToWcPaymentSettings(); await this.click(paymentSettingsAdmin.setupDokanMangoPay); // setup mangopay @@ -138,7 +138,7 @@ export class PaymentsPage extends AdminPage { // admin setup razorpay async setupRazorpay(payment: payment) { - await this.goToPaymentSettings(); + await this.goToWcPaymentSettings(); await this.click(paymentSettingsAdmin.setupDokanRazorpay); // setup razorpay @@ -162,7 +162,7 @@ export class PaymentsPage extends AdminPage { // admin setup stripe express async setupStripeExpress(payment: payment) { - await this.goToPaymentSettings(); + await this.goToWcPaymentSettings(); await this.click(paymentSettingsAdmin.setupDokanStripeExpress); @@ -217,46 +217,53 @@ export class PaymentsPage extends AdminPage { // paymentMethods dropdown is visible await this.toBeVisible(paymentSettingsVendor.paymentMethods.addPaymentMethodDropDown); - await this.notToHaveCount(paymentSettingsVendor.paymentMethods.noOfPaymentMethods, 0); + // await this.notToHaveCount(paymentSettingsVendor.paymentMethods.noOfPaymentMethods, 0); } - // vendor set basic payment settings - async setBasicPaymentSettings(payment: vendor['payment']): Promise { - await this.setBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); - await this.setBankTransfer(payment); - await this.setBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); - await this.setBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); - } - - // set basic payment method [paypal, skrill, custom ] - async setBasicPayment(paymentMethod: vendor['payment']): Promise { - switch (paymentMethod.methodName) { + // goto payment settings + async goToPaymentSettings(methodName: string): Promise { + switch (methodName) { case 'paypal': - await this.goIfNotThere(data.subUrls.frontend.vDashboard.paypal); + await this.goto(data.subUrls.frontend.vDashboard.paypal); + break; + + case 'bank': + await this.goto(data.subUrls.frontend.vDashboard.bankTransfer); break; case 'skrill': - await this.goIfNotThere(data.subUrls.frontend.vDashboard.skrill); + await this.goto(data.subUrls.frontend.vDashboard.skrill); break; case 'custom': - await this.goIfNotThere(data.subUrls.frontend.vDashboard.customPayment); + await this.goto(data.subUrls.frontend.vDashboard.customPayment); break; default: break; } + } + // set basic payment method [paypal, skrill, custom ] + async setBasicPayment(paymentMethod: vendor['payment']): Promise { + await this.goToPaymentSettings(paymentMethod.methodName); await this.clearAndType(paymentSettingsVendor.paymentEmail, paymentMethod.email()); await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.updateSettings); await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); } + // disconnect basic payment method [paypal, skrill, custom ] + async disconnectBasicPayment(paymentMethod: vendor['payment']): Promise { + await this.goToPaymentSettings(paymentMethod.methodName); + await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.disconnectPayment); + await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); + } + // bank transfer payment settings async setBankTransfer(paymentMethod: vendor['payment']): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.bankTransfer); - await this.clickIfVisible(paymentSettingsVendor.disconnectAccount); + // await this.clickIfVisible(paymentSettingsVendor.disconnectAccount); await this.clearAndType(paymentSettingsVendor.bankAccountName, paymentMethod.bankAccountName); await this.selectByValue(paymentSettingsVendor.bankAccountType, paymentMethod.bankAccountType); await this.clearAndType(paymentSettingsVendor.bankAccountNumber, paymentMethod.bankAccountNumber); @@ -270,31 +277,4 @@ export class PaymentsPage extends AdminPage { await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.addAccount); await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); } - - // disconnect basic payment method [paypal, skrill, custom ] - async disconnectBasicPayment(paymentMethod: vendor['payment']): Promise { - switch (paymentMethod.methodName) { - case 'paypal': - await this.goIfNotThere(data.subUrls.frontend.vDashboard.paypal); - break; - - case 'bank': - await this.goIfNotThere(data.subUrls.frontend.vDashboard.bankTransfer); - break; - - case 'skrill': - await this.goIfNotThere(data.subUrls.frontend.vDashboard.skrill); - break; - - case 'custom': - await this.goIfNotThere(data.subUrls.frontend.vDashboard.customPayment); - break; - - default: - break; - } - - await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.disconnectPayment); - await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); - } } diff --git a/tests/pw/tests/e2e/payments.spec.ts b/tests/pw/tests/e2e/payments.spec.ts index 1defc23ec1..8070678d50 100644 --- a/tests/pw/tests/e2e/payments.spec.ts +++ b/tests/pw/tests/e2e/payments.spec.ts @@ -3,6 +3,11 @@ import { PaymentsPage } from '@pages/paymentsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; import { payloads } from '@utils/payloads'; +import { dbUtils } from '@utils/dbUtils'; +import { dbData } from '@utils/dbData'; +import { helpers } from '@utils/helpers'; + +const { VENDOR_ID } = process.env; test.describe('Payments test', () => { let admin: PaymentsPage; @@ -20,10 +25,13 @@ test.describe('Payments test', () => { vendor = new PaymentsPage(vPage); apiUtils = new ApiUtils(await request.newContext()); + // await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: [] }); }); test.afterAll(async () => { await apiUtils.updateBatchWcSettingsOptions('general', payloads.currency, payloads.adminAuth); + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', dbData.testData.dokan.paymentSettings); + // await apiUtils.setStoreSettings(payloads.defaultStoreSettings, payloads.vendorAuth); await aPage.close(); await vPage.close(); await apiUtils.dispose(); @@ -71,38 +79,63 @@ test.describe('Payments test', () => { }); test('vendor can add paypal payment method', { tag: ['@lite', '@vendor'] }, async () => { + // await apiUtils.setStoreSettings({ payment: { paypal: { email: '' } } }, payloads.vendorAuth); + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { paypal: { email: '' } } }); await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); }); - test('vendor can add bank payment method', { tag: ['@lite', '@vendor'] }, async () => { - await vendor.setBankTransfer(data.vendor.payment); + test('vendor can update paypal payment method', { tag: ['@lite', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { paypal: { email: 'paypal@g.c' } } }); + await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); }); - test('vendor can add Skrill payment method', { tag: ['@pro', '@vendor'] }, async () => { - await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); + test('vendor can disconnect paypal payment method', { tag: ['@lite', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { paypal: { email: 'paypal@g.c' } } }); + await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); }); - test('vendor can add custom payment method', { tag: ['@pro', '@vendor'] }, async () => { - await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); + test('vendor can add bank payment method', { tag: ['@lite', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', helpers.emptyObjectValues(dbData.testData.dokan.paymentSettings.bank)); + await vendor.setBankTransfer(data.vendor.payment); }); - test('vendor can disconnect paypal payment method', { tag: ['@lite', '@vendor'] }, async () => { - await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); - //reset - await apiUtils.setStoreSettings(payloads.defaultStoreSettings, payloads.vendorAuth); + test('vendor can update bank payment method', { tag: ['@lite', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', dbData.testData.dokan.paymentSettings.bank); + await vendor.setBankTransfer(data.vendor.payment); }); test('vendor can disconnect bank payment method', { tag: ['@lite', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', dbData.testData.dokan.paymentSettings.bank); await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'bank' }); - // reset - await apiUtils.setStoreSettings(payloads.defaultStoreSettings, payloads.vendorAuth); }); - test('vendor can disconnect Skrill payment method', { tag: ['@pro', '@vendor'] }, async () => { + test('vendor can add skrill payment method', { tag: ['@pro', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { skrill: { email: '' } } }); + await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); + }); + + test('vendor can update skrill payment method', { tag: ['@pro', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { skrill: { email: 'skrill@g.c' } } }); + await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); + }); + + test('vendor can disconnect skrill payment method', { tag: ['@pro', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { skrill: { email: 'skrill@g.c' } } }); await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); }); + test('vendor can add custom payment method', { tag: ['@pro', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { dokan_custom: { value: '' } } }); + await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); + }); + + test('vendor can update custom payment method', { tag: ['@pro', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { dokan_custom: { value: '0123456789' } } }); + await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); + }); + test('vendor can disconnect custom payment method', { tag: ['@pro', '@vendor'] }, async () => { + await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { dokan_custom: { value: '0123456789' } } }); await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); }); }); diff --git a/tests/pw/utils/dbData.ts b/tests/pw/utils/dbData.ts index 3dc413252e..f3cea8a3bd 100644 --- a/tests/pw/utils/dbData.ts +++ b/tests/pw/utils/dbData.ts @@ -1420,6 +1420,30 @@ export const dbData = { length_duration: '', addon_settings: [], }, + + // vendor payment settings + paymentSettings: { + paypal: { + email: 'paypal@g.com', + }, + bank: { + ac_name: 'accountName', + ac_number: '0123456789', + bank_name: 'bankName', + ac_type: 'personal', + bank_addr: 'bankAddress', + routing_number: '9876543210', + iban: 'QWERTY12345', + swift: 'AZERTY98765', + declaration: 'on', + }, + dokan_custom: { + value: '0123456789QWERTY', + }, + skrill: { + email: 'skrill@g.com', + }, + }, }, }, }; diff --git a/tests/pw/utils/helpers.ts b/tests/pw/utils/helpers.ts index ec37d44a95..58e4ef95ce 100644 --- a/tests/pw/utils/helpers.ts +++ b/tests/pw/utils/helpers.ts @@ -466,6 +466,12 @@ export const helpers = { return `rgb(${r}, ${g}, ${b})`; }, + // empty object values + emptyObjectValues: (obj: { [key: string]: any }) => (Object.keys(obj).forEach(key => (obj[key] = '')), obj), + + // is object + isPlainObject: (value: any) => value !== null && typeof value === 'object' && !Array.isArray(value), + // deep merge arrays deepMergeArrays(targetArray: any[], sourceArray: any[]) { if (targetArray.every((item: any) => item instanceof Object && !Array.isArray(item)) && sourceArray.every(item => item instanceof Object && !Array.isArray(item))) { @@ -488,7 +494,7 @@ export const helpers = { const result = { ...target }; for (const key of Object.keys(source)) { - if (source[key] instanceof Object && target[key] instanceof Object) { + if (this.isPlainObject(source[key]) && this.isPlainObject(target[key])) { result[key] = this.deepMergeObjects(target[key], source[key]); } else if (Array.isArray(source[key]) && Array.isArray(target[key])) { result[key] = this.deepMergeArrays(target[key], source[key]); diff --git a/tests/pw/utils/testData.ts b/tests/pw/utils/testData.ts index 7e27412899..446e762d2a 100644 --- a/tests/pw/utils/testData.ts +++ b/tests/pw/utils/testData.ts @@ -1410,7 +1410,6 @@ export const data = { payment: { methodName: '', - // email: () => faker.internet.email(), email: () => `${faker.person.firstName('male')}@email.com`, bankAccountName: 'accountName', bankAccountType: faker.helpers.arrayElement(['personal', 'business']), From e9418614b0a322c0723e5ee57338b903bf4c2430 Mon Sep 17 00:00:00 2001 From: shashwata Date: Thu, 3 Oct 2024 09:15:37 +0600 Subject: [PATCH 3/4] Update: update feature map --- tests/pw/feature-map/feature-map.yml | 14 +++++++----- tests/pw/pages/paymentsPage.ts | 6 +++--- tests/pw/tests/e2e/payments.spec.ts | 32 ++++++++++++++-------------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/tests/pw/feature-map/feature-map.yml b/tests/pw/feature-map/feature-map.yml index fc0572af2b..e7758eee31 100644 --- a/tests/pw/feature-map/feature-map.yml +++ b/tests/pw/feature-map/feature-map.yml @@ -184,13 +184,17 @@ vendor: vendor can view payment settings menu page [lite]: true vendor can add paypal payment method [lite]: true + vendor can update paypal payment method [lite]: true + vendor can remove paypal payment method [lite]: true vendor can add bank payment method [lite]: true - vendor can add Skrill payment method: true + vendor can update bank payment method [lite]: true + vendor can remove bank payment method [lite]: true + vendor can add skrill payment method: true + vendor can update skrill payment method: true + vendor can remove skrill payment method: true vendor can add custom payment method: true - vendor can disconnect paypal payment method: true - vendor can disconnect bank payment method: true - vendor can disconnect Skrill payment method: true - vendor can disconnect custom payment method: true + vendor can update custom payment method: true + vendor can remove custom payment method: true - page: 'Shop' features: diff --git a/tests/pw/pages/paymentsPage.ts b/tests/pw/pages/paymentsPage.ts index 4b1189e189..c8e92ecb03 100644 --- a/tests/pw/pages/paymentsPage.ts +++ b/tests/pw/pages/paymentsPage.ts @@ -245,7 +245,7 @@ export class PaymentsPage extends AdminPage { } // set basic payment method [paypal, skrill, custom ] - async setBasicPayment(paymentMethod: vendor['payment']): Promise { + async addBasicPayment(paymentMethod: vendor['payment']): Promise { await this.goToPaymentSettings(paymentMethod.methodName); await this.clearAndType(paymentSettingsVendor.paymentEmail, paymentMethod.email()); await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.updateSettings); @@ -253,14 +253,14 @@ export class PaymentsPage extends AdminPage { } // disconnect basic payment method [paypal, skrill, custom ] - async disconnectBasicPayment(paymentMethod: vendor['payment']): Promise { + async removeBasicPayment(paymentMethod: vendor['payment']): Promise { await this.goToPaymentSettings(paymentMethod.methodName); await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.disconnectPayment); await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); } // bank transfer payment settings - async setBankTransfer(paymentMethod: vendor['payment']): Promise { + async addBankTransfer(paymentMethod: vendor['payment']): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.bankTransfer); // await this.clickIfVisible(paymentSettingsVendor.disconnectAccount); diff --git a/tests/pw/tests/e2e/payments.spec.ts b/tests/pw/tests/e2e/payments.spec.ts index 8070678d50..d9ce7031fd 100644 --- a/tests/pw/tests/e2e/payments.spec.ts +++ b/tests/pw/tests/e2e/payments.spec.ts @@ -81,61 +81,61 @@ test.describe('Payments test', () => { test('vendor can add paypal payment method', { tag: ['@lite', '@vendor'] }, async () => { // await apiUtils.setStoreSettings({ payment: { paypal: { email: '' } } }, payloads.vendorAuth); await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { paypal: { email: '' } } }); - await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); + await vendor.addBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); }); test('vendor can update paypal payment method', { tag: ['@lite', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { paypal: { email: 'paypal@g.c' } } }); - await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); + await vendor.addBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); }); - test('vendor can disconnect paypal payment method', { tag: ['@lite', '@vendor'] }, async () => { + test('vendor can remove paypal payment method', { tag: ['@lite', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { paypal: { email: 'paypal@g.c' } } }); - await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); + await vendor.removeBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); }); test('vendor can add bank payment method', { tag: ['@lite', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', helpers.emptyObjectValues(dbData.testData.dokan.paymentSettings.bank)); - await vendor.setBankTransfer(data.vendor.payment); + await vendor.addBankTransfer(data.vendor.payment); }); test('vendor can update bank payment method', { tag: ['@lite', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', dbData.testData.dokan.paymentSettings.bank); - await vendor.setBankTransfer(data.vendor.payment); + await vendor.addBankTransfer(data.vendor.payment); }); - test('vendor can disconnect bank payment method', { tag: ['@lite', '@vendor'] }, async () => { + test.only('vendor can remove bank payment method', { tag: ['@lite', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', dbData.testData.dokan.paymentSettings.bank); - await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'bank' }); + await vendor.removeBasicPayment({ ...data.vendor.payment, methodName: 'bank' }); }); test('vendor can add skrill payment method', { tag: ['@pro', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { skrill: { email: '' } } }); - await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); + await vendor.addBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); }); test('vendor can update skrill payment method', { tag: ['@pro', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { skrill: { email: 'skrill@g.c' } } }); - await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); + await vendor.addBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); }); - test('vendor can disconnect skrill payment method', { tag: ['@pro', '@vendor'] }, async () => { + test('vendor can remove skrill payment method', { tag: ['@pro', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { skrill: { email: 'skrill@g.c' } } }); - await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); + await vendor.removeBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); }); test('vendor can add custom payment method', { tag: ['@pro', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { dokan_custom: { value: '' } } }); - await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); + await vendor.addBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); }); test('vendor can update custom payment method', { tag: ['@pro', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { dokan_custom: { value: '0123456789' } } }); - await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); + await vendor.addBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); }); - test('vendor can disconnect custom payment method', { tag: ['@pro', '@vendor'] }, async () => { + test('vendor can remove custom payment method', { tag: ['@pro', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', { payment: { dokan_custom: { value: '0123456789' } } }); - await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); + await vendor.removeBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); }); }); From bfb0c7734d6b00f367be9b853c29c67fac6887b3 Mon Sep 17 00:00:00 2001 From: shashwata Date: Thu, 3 Oct 2024 09:52:08 +0600 Subject: [PATCH 4/4] Update: remove test.only --- tests/pw/tests/e2e/payments.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pw/tests/e2e/payments.spec.ts b/tests/pw/tests/e2e/payments.spec.ts index d9ce7031fd..5d9b288816 100644 --- a/tests/pw/tests/e2e/payments.spec.ts +++ b/tests/pw/tests/e2e/payments.spec.ts @@ -104,7 +104,7 @@ test.describe('Payments test', () => { await vendor.addBankTransfer(data.vendor.payment); }); - test.only('vendor can remove bank payment method', { tag: ['@lite', '@vendor'] }, async () => { + test('vendor can remove bank payment method', { tag: ['@lite', '@vendor'] }, async () => { await dbUtils.updateUserMeta(VENDOR_ID, 'dokan_profile_settings', dbData.testData.dokan.paymentSettings.bank); await vendor.removeBasicPayment({ ...data.vendor.payment, methodName: 'bank' }); });