diff --git a/tests/pw/pages/requestForQuotationsPage.ts b/tests/pw/pages/requestForQuotationsPage.ts index 2b66eb303a..f8869717bc 100644 --- a/tests/pw/pages/requestForQuotationsPage.ts +++ b/tests/pw/pages/requestForQuotationsPage.ts @@ -83,7 +83,6 @@ export class RequestForQuotationsPage extends AdminPage { // edit quote rule async editQuoteRule(rule: requestForQuotation['quoteRule']) { await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules); - // await this.goto(data.subUrls.backend.dokan.requestForQuoteRules); await this.hover(selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesCell(rule.title)); @@ -98,11 +97,11 @@ export class RequestForQuotationsPage extends AdminPage { // update quote rule async updateQuoteRule(quoteTitle: string, action: string) { - await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules); - // await this.goto(data.subUrls.backend.dokan.requestForQuoteRules); + await this.goto(data.subUrls.backend.dokan.requestForQuoteRules); switch (action) { case 'trash': + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.navTabs.published); await this.hover(selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesCell(quoteTitle)); await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesTrash(quoteTitle)); break; @@ -126,8 +125,7 @@ export class RequestForQuotationsPage extends AdminPage { // quote rules bulk action async quoteRulesBulkAction(action: string) { - await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules); - // await this.goto(data.subUrls.backend.dokan.requestForQuoteRules); + await this.goto(data.subUrls.backend.dokan.requestForQuoteRules); // ensure row exists await this.notToBeVisible(selector.admin.dokan.requestForQuotation.quoteRules.noRowsFound); @@ -220,10 +218,10 @@ export class RequestForQuotationsPage extends AdminPage { // update quote async updateQuote(quoteTitle: string, action: string) { await this.goto(data.subUrls.backend.dokan.requestForQuote); - // await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote); switch (action) { case 'trash': + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.navTabs.pending); await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle)); await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteTrash(quoteTitle)); break; @@ -248,7 +246,6 @@ export class RequestForQuotationsPage extends AdminPage { // approve quote async approveQuote(quoteTitle: string) { await this.goto(data.subUrls.backend.dokan.requestForQuote); - // await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote); await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle)); await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteEdit(quoteTitle)); await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.approveQuote); @@ -256,9 +253,8 @@ export class RequestForQuotationsPage extends AdminPage { // convert quote to order async convertQuoteToOrder(quoteTitle: string) { - // await this.approveQuote(quoteTitle); await this.goto(data.subUrls.backend.dokan.requestForQuote); - // await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.navTabs.approved); await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle)); await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteEdit(quoteTitle)); await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.convertToOrder); diff --git a/tests/pw/pages/selectors.ts b/tests/pw/pages/selectors.ts index c5b757b6f1..e791ba69a2 100644 --- a/tests/pw/pages/selectors.ts +++ b/tests/pw/pages/selectors.ts @@ -7082,7 +7082,7 @@ export const selector = { phoneNumber: 'input[name="phone_field"]', }, - message: '.woocommerce .is-success', + message: '.woocommerce-message', }, // requested quote diff --git a/tests/pw/pages/spmvPage.ts b/tests/pw/pages/spmvPage.ts index fcf381efa3..77eb7c1f1d 100644 --- a/tests/pw/pages/spmvPage.ts +++ b/tests/pw/pages/spmvPage.ts @@ -91,7 +91,7 @@ export class SpmvPage extends VendorPage { } // got to product edit from spmv - async goToProductEditFromSPMV(productName: string): Promise { + async goToProductEditFromSpmv(productName: string): Promise { await this.searchSimilarProduct(productName, 'spmv'); await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.vSpmv.editProduct(productName)); await this.toHaveValue(selector.vendor.product.edit.title, productName); diff --git a/tests/pw/tests/api/calculation.spec.ts b/tests/pw/tests/api/calculation.spec.ts index 51bef51b29..aea1a6991b 100644 --- a/tests/pw/tests/api/calculation.spec.ts +++ b/tests/pw/tests/api/calculation.spec.ts @@ -225,7 +225,7 @@ test.describe.skip('commission test', () => { const gatewayFee = 0; const lineItems = res.line_items; - const calculatedSubTotal = helpers.lineItemsToSubtoal(lineItems); + const calculatedSubTotal = helpers.lineItemsToSubtotal(lineItems); const calculatedProductTax = helpers.productTax(taxRate, calculatedSubTotal); const calculatedShippingTax = helpers.shippingTax(taxRate, providedShippingFee); const calculatedTotalTax = calculatedProductTax + calculatedShippingTax; diff --git a/tests/pw/tests/e2e/_auth.setup.ts b/tests/pw/tests/e2e/_auth.setup.ts index 93e26407a4..6828478e8b 100644 --- a/tests/pw/tests/e2e/_auth.setup.ts +++ b/tests/pw/tests/e2e/_auth.setup.ts @@ -51,16 +51,14 @@ setup.describe('authenticate users & set permalink', () => { }); setup('add vendor1 @lite', async () => { - const [, sellerId] = await apiUtils.createStore(payloads.createStore1, payloads.adminAuth); - await apiUtils.updateCustomer(sellerId, payloads.updateAddress, payloads.adminAuth); + const [, sellerId] = await apiUtils.createStore(payloads.createStore1, payloads.adminAuth, true); console.log('VENDOR_ID:', sellerId); process.env.VENDOR_ID = sellerId; helpers.appendEnv(`VENDOR_ID=${sellerId}`); // for local testing }); setup('add vendor2 @lite', async () => { - const [, sellerId] = await apiUtils.createStore(payloads.createStore2, payloads.adminAuth); - await apiUtils.updateCustomer(sellerId, payloads.updateAddress, payloads.adminAuth); + const [, sellerId] = await apiUtils.createStore(payloads.createStore2, payloads.adminAuth, true); console.log('VENDOR2_ID:', sellerId); process.env.VENDOR2_ID = sellerId; helpers.appendEnv(`VENDOR2_ID=${sellerId}`); // for local testing @@ -76,6 +74,11 @@ setup.describe('authenticate users & set permalink', () => { await loginPage.login(data.vendor, data.auth.vendorAuthFile); }); + setup('authenticate vendor2 @lite', async ({ page }) => { + const loginPage = new LoginPage(page); + await loginPage.login(data.vendor.vendor2, data.auth.vendor2AuthFile); + }); + setup('dokan pro enabled or not @lite', async () => { let res = await apiUtils.checkPluginsExistence(data.plugin.dokanPro, payloads.adminAuth); if (res) { diff --git a/tests/pw/tests/e2e/_env.setup.ts b/tests/pw/tests/e2e/_env.setup.ts index 4da5b7e725..7954b207cc 100644 --- a/tests/pw/tests/e2e/_env.setup.ts +++ b/tests/pw/tests/e2e/_env.setup.ts @@ -130,8 +130,7 @@ setup.describe('setup user settings', () => { await apiUtils.deleteAllProducts(data.predefined.simpleProduct.product1.name, payloads.vendorAuth); // create store product - const product = { ...payloads.createProduct(), name: data.predefined.simpleProduct.product1.name }; - const [, productId] = await apiUtils.createProduct(product, payloads.vendorAuth); + const [, productId] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.simpleProduct.product1.name }, payloads.vendorAuth); console.log('PRODUCT_ID', productId); process.env.PRODUCT_ID = productId; helpers.appendEnv(`PRODUCT_ID=${productId}`); // for local testing @@ -142,8 +141,7 @@ setup.describe('setup user settings', () => { await apiUtils.deleteAllProducts(data.predefined.vendor2.simpleProduct.product1.name, payloads.vendor2Auth); // create store product - const product = { ...payloads.createProduct(), name: data.predefined.vendor2.simpleProduct.product1.name }; - const [, productId] = await apiUtils.createProduct(product, payloads.vendor2Auth); + const [, productId] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.vendor2.simpleProduct.product1.name }, payloads.vendor2Auth); console.log('V2_PRODUCT_ID:', productId); process.env.V2_PRODUCT_ID = productId; helpers.appendEnv(`V2_PRODUCT_ID=${productId}`); // for local testing diff --git a/tests/pw/tests/e2e/refunds.spec.ts b/tests/pw/tests/e2e/refunds.spec.ts index d8a95f1a76..005c6795e0 100644 --- a/tests/pw/tests/e2e/refunds.spec.ts +++ b/tests/pw/tests/e2e/refunds.spec.ts @@ -26,7 +26,7 @@ test.describe('Refunds test', () => { apiUtils = new ApiUtils(await request.newContext()); [, orderResponseBody, orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.processing, payloads.vendorAuth); - await dbUtils.createRefund(orderResponseBody); + await dbUtils.createRefundRequest(orderResponseBody); }); test.afterAll(async () => { @@ -34,13 +34,18 @@ test.describe('Refunds test', () => { await apiUtils.dispose(); }); + //admin + test('admin refunds menu page is rendering properly @pro @exp @a', async () => { await admin.adminRefundRequestsRenderProperly(); }); - test('admin can search refund requests @pro @a', async () => { + test('admin can search refund requests by order-id @pro @a', async () => { await admin.searchRefundRequests(orderId); - // await admin.searchRefundRequests(data.predefined.vendorStores.vendor1); + }); + + test('admin can search refund requests by vendor @pro @a', async () => { + await admin.searchRefundRequests(data.predefined.vendorStores.vendor1); }); test('admin can approve refund request @pro @a', async () => { @@ -49,16 +54,18 @@ test.describe('Refunds test', () => { test('admin can cancel refund requests @pro @a', async () => { const [, orderResponseBody, orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.processing, payloads.vendorAuth); - await dbUtils.createRefund(orderResponseBody); + await dbUtils.createRefundRequest(orderResponseBody); await admin.updateRefundRequests(orderId, 'cancel'); }); test('admin can perform refund requests bulk actions @pro @a', async () => { const [, orderResponseBody, ,] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.processing, payloads.vendorAuth); - await dbUtils.createRefund(orderResponseBody); + await dbUtils.createRefundRequest(orderResponseBody); await admin.refundRequestsBulkAction('completed'); }); + //vendor + test('vendor can full refund @pro @v', async () => { const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.completed, payloads.vendorAuth); await vendor.refundOrder(orderId, data.predefined.simpleProduct.product1.name); diff --git a/tests/pw/tests/e2e/reports.spec.ts b/tests/pw/tests/e2e/reports.spec.ts index 9fdf22de7e..510e08312f 100644 --- a/tests/pw/tests/e2e/reports.spec.ts +++ b/tests/pw/tests/e2e/reports.spec.ts @@ -16,6 +16,7 @@ test.describe('Reports test', () => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new ReportsPage(aPage); + apiUtils = new ApiUtils(await request.newContext()); [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.completed, payloads.vendorAuth); }); @@ -33,7 +34,7 @@ test.describe('Reports test', () => { // all logs - test('admin All Logs menu page is rendering properly @pro @exp @a', async () => { + test('admin all Logs menu page is rendering properly @pro @exp @a', async () => { await admin.adminAllLogsRenderProperly(); }); @@ -42,7 +43,6 @@ test.describe('Reports test', () => { }); test('admin can export all logs @pro @a', async () => { - // await admin.exportAllLogs(orderId); await admin.exportAllLogs(); }); diff --git a/tests/pw/tests/e2e/requestForQuoteRules.spec.ts b/tests/pw/tests/e2e/requestForQuoteRules.spec.ts index a4a54e4276..70e9e9b38d 100644 --- a/tests/pw/tests/e2e/requestForQuoteRules.spec.ts +++ b/tests/pw/tests/e2e/requestForQuoteRules.spec.ts @@ -8,50 +8,57 @@ test.describe('Request for quotation Rules test', () => { let admin: RequestForQuotationsPage; let aPage: Page; let apiUtils: ApiUtils; - const quoteRuleTitle = data.requestForQuotation.quoteRule.title(); + let quoteRuleTitle: string; test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new RequestForQuotationsPage(aPage); + apiUtils = new ApiUtils(await request.newContext()); - await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), rule_name: quoteRuleTitle }, payloads.adminAuth); + [, , quoteRuleTitle] = await apiUtils.createQuoteRule(payloads.createQuoteRule(), payloads.adminAuth); }); test.afterAll(async () => { + await apiUtils.deleteAllQuoteRules(payloads.adminAuth); + await apiUtils.deleteAllQuoteRulesTrashed(payloads.adminAuth); await aPage.close(); await apiUtils.dispose(); }); // quote rules + //admin + test('admin quote rules menu page is rendering properly @pro @exp @a', async () => { await admin.adminQuoteRulesRenderProperly(); }); test('admin can add quote rule @pro @a', async () => { - await admin.addQuoteRule({ ...data.requestForQuotation.quoteRule, title: data.requestForQuotation.quoteRule.title() }); + await admin.addQuoteRule(data.requestForQuotation.quoteRule()); }); test('admin can edit quote rule @pro @a', async () => { - await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule, title: quoteRuleTitle }); + await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule(), title: quoteRuleTitle }); }); test('admin can trash quote rule @pro @a', async () => { + const [, , quoteRuleTitle] = await apiUtils.createQuoteRule(payloads.createQuoteRule(), payloads.adminAuth); await admin.updateQuoteRule(quoteRuleTitle, 'trash'); }); test('admin can restore quote rule @pro @a', async () => { + const [, , quoteRuleTitle] = await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), status: 'trash' }, payloads.adminAuth); await admin.updateQuoteRule(quoteRuleTitle, 'restore'); }); test('admin can permanently delete quote rule @pro @a', async () => { - await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), rule_name: data.requestForQuotation.trashedQuoteRule.title, status: data.requestForQuotation.trashedQuoteRule.status }, payloads.adminAuth); - await admin.updateQuoteRule(data.requestForQuotation.trashedQuoteRule.title, 'permanently-delete'); + const [, , quoteRuleTitle] = await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), status: 'trash' }, payloads.adminAuth); + await admin.updateQuoteRule(quoteRuleTitle, 'permanently-delete'); }); - // todo: need order for this type of test for whole project , will fail others tests while running parallel - test('admin can perform quote rule bulk actions @pro @a', async () => { + test.skip('admin can perform quote rule bulk actions @pro @a', async () => { + // todo: might cause other tests to fail in parallel await admin.quoteRulesBulkAction('trash'); }); }); diff --git a/tests/pw/tests/e2e/requestForQuotes.spec.ts b/tests/pw/tests/e2e/requestForQuotes.spec.ts index 5d76b32b2b..4381d81643 100644 --- a/tests/pw/tests/e2e/requestForQuotes.spec.ts +++ b/tests/pw/tests/e2e/requestForQuotes.spec.ts @@ -19,8 +19,7 @@ test.describe('Request for quotation test admin', () => { admin = new RequestForQuotationsPage(aPage); apiUtils = new ApiUtils(await request.newContext()); - const [, pId] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); - productId.push(pId); + [, productId[0]] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); [, , quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); }); @@ -36,14 +35,15 @@ test.describe('Request for quotation test admin', () => { }); test('admin can add quote @pro @a', async () => { - await admin.addQuote({ ...data.requestForQuotation.quote, title: data.requestForQuotation.quote.title() }); + await admin.addQuote(data.requestForQuotation.quote()); }); test('admin can edit quote @pro @a', async () => { - await admin.editQuote({ ...data.requestForQuotation.quote, title: quoteTitle }); + await admin.editQuote({ ...data.requestForQuotation.quote(), title: quoteTitle }); }); test('admin can trash quote @pro @a', async () => { + const [, , quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); await admin.updateQuote(quoteTitle, 'trash'); }); @@ -67,7 +67,8 @@ test.describe('Request for quotation test admin', () => { await admin.convertQuoteToOrder(quoteTitle); }); - test('admin can perform quote bulk actions @pro @a', async () => { + test.skip('admin can perform quote bulk actions @pro @a', async () => { + // todo: might cause other tests to fail in parallel await admin.quotesBulkAction('trash'); }); }); @@ -79,7 +80,6 @@ test.describe('Request for quotation test vendor', () => { const productId: string[] = []; let quoteTitle: string; let productName: string; - let pId: string; let quoteId: string; test.beforeAll(async ({ browser }) => { @@ -87,14 +87,14 @@ test.describe('Request for quotation test vendor', () => { vPage = await vendorContext.newPage(); vendor = new RequestForQuotationsPage(vPage); - apiUtils = new ApiUtils(await request.newContext()); - [, pId, productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); - productId.push(pId); - [, quoteId, quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); + // apiUtils = new ApiUtils(await request.newContext()); + // [, productId[0], productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); + // [, quoteId, quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); }); test.afterAll(async () => { await vPage.close(); + await apiUtils.dispose(); }); test('vendor request quotes menu page is rendering properly @pro @exp @v', async () => { @@ -110,11 +110,12 @@ test.describe('Request for quotation test vendor', () => { }); test('vendor can approve quote request @pro @v', async () => { + const [, quoteId] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); await vendor.vendorApproveQuoteRequest(quoteId); }); test('vendor can convert quote request to order @pro @v', async () => { - // const [, quoteId] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, status: 'approve', user_id: CUSTOMER_ID }, payloads.adminAuth); + const [, quoteId] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, status: 'approve', user_id: CUSTOMER_ID }, payloads.adminAuth); await vendor.vendorConvertQuoteToOrder(quoteId); }); }); @@ -122,11 +123,10 @@ test.describe('Request for quotation test vendor', () => { test.describe('Request for quotation test customer', () => { let customer: RequestForQuotationsPage; let guest: RequestForQuotationsPage; - let cPage: Page, gPage: Page; + let cPage: Page; let apiUtils: ApiUtils; const productId: string[] = []; let productName: string; - let pId: string; let quoteId: string; test.beforeAll(async ({ browser }) => { @@ -134,24 +134,20 @@ test.describe('Request for quotation test customer', () => { cPage = await customerContext.newPage(); customer = new RequestForQuotationsPage(cPage); - const guestContext = await browser.newContext(data.auth.noAuth); - gPage = await guestContext.newPage(); - guest = new RequestForQuotationsPage(gPage); - apiUtils = new ApiUtils(await request.newContext()); - [, pId, productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); - productId.push(pId); + [, productId[0], productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), product_ids: productId, apply_on_all_product: '0' }, payloads.adminAuth); - [, quoteId] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); }); test.afterAll(async () => { await cPage.close(); - await gPage.close(); + await apiUtils.dispose(); }); + //customer + test('customer request for quote menu page is rendering properly @pro @exp @c', async () => { await customer.requestForQuoteRenderProperly(); }); @@ -168,16 +164,19 @@ test.describe('Request for quotation test customer', () => { await customer.customerUpdateRequestedQuote(quoteId, { ...data.requestForQuotation.customerQuoteProduct, productName: productName }); }); - test('customer can pay order converted from quote request @pro @c', async () => { + test('customer can pay for order converted from quote request @pro @c', async () => { await apiUtils.convertQuoteToOrder(quoteId, payloads.adminAuth); await customer.payConvertedQuote(quoteId); }); - test.skip('customer can quote product @pro @exp @c', async () => { + test('customer can quote product @pro @c', async () => { await customer.customerQuoteProduct({ ...data.requestForQuotation.customerQuoteProduct, productName: productName }); }); - test.skip('guest customer can quote product @pro @exp @g', async () => { + //guest + + test('guest customer can quote product @pro @g', async ({ page }) => { + guest = new RequestForQuotationsPage(page); await guest.customerQuoteProduct({ ...data.requestForQuotation.customerQuoteProduct, productName: productName }, data.requestForQuotation.guest()); }); }); diff --git a/tests/pw/tests/e2e/reverseWithdraws.spec.ts b/tests/pw/tests/e2e/reverseWithdraws.spec.ts index c38c076d23..4293b12f06 100644 --- a/tests/pw/tests/e2e/reverseWithdraws.spec.ts +++ b/tests/pw/tests/e2e/reverseWithdraws.spec.ts @@ -1,42 +1,35 @@ import { test, request, Page } from '@playwright/test'; import { ReverseWithdrawsPage } from '@pages/reverseWithdrawsPage'; -// import { OrdersPage } from '@pages/ordersPage'; 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'; -const { PRODUCT_ID } = process.env; - test.describe('Reverse withdraw test', () => { let admin: ReverseWithdrawsPage; let vendor: ReverseWithdrawsPage; let aPage: Page, vPage: Page; let apiUtils: ApiUtils; - // let orderId: string; + let productId: string; + let productName: string; test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new ReverseWithdrawsPage(aPage); - const vendorContext = await browser.newContext(data.auth.vendorAuth); + const vendorContext = await browser.newContext(data.auth.vendor2Auth); vPage = await vendorContext.newPage(); vendor = new ReverseWithdrawsPage(vPage); - // const vendor1 = new OrdersPage(vPage); - - apiUtils = new ApiUtils(await request.newContext()); await dbUtils.setDokanSettings(dbData.dokan.optionName.reverseWithdraw, dbData.dokan.reverseWithdrawSettings); - // await admin.addReverseWithdrawal({ ...data.reverseWithdraw, amount: '1000', withdrawalBalanceType: 'debit' } ); - // await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrderCod, data.order.orderStatus.completed, payloads.vendorAuth); - // [,, orderId,]= await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrderCod, data.order.orderStatus.processing, payloads.vendorAuth); - // await vendor1.updateOrderStatusOnTable(orderId, 'complete'); + apiUtils = new ApiUtils(await request.newContext()); - const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrderCod, data.order.orderStatus.processing, payloads.vendorAuth); - await apiUtils.updateOrderStatus(orderId, data.order.orderStatus.completed, payloads.vendorAuth); + [, productId, productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendor2Auth); + const [, , orderId] = await apiUtils.createOrderWithStatus(productId, payloads.createOrderCod, data.order.orderStatus.processing, payloads.vendor2Auth); + await apiUtils.updateOrderStatus(orderId, data.order.orderStatus.completed, payloads.vendor2Auth); }); test.afterAll(async () => { @@ -50,12 +43,12 @@ test.describe('Reverse withdraw test', () => { await admin.adminReverseWithdrawRenderProperly(); }); - test.skip('filter reverse withdraws by store @lite @a', async () => { - await admin.filterReverseWithdraws(data.predefined.vendorStores.vendor1); + test('filter reverse withdraws by store @lite @a', async () => { + await admin.filterReverseWithdraws(data.predefined.vendorStores.vendor2); }); test('admin can crete reverse withdraws @lite @a', async () => { - await admin.addReverseWithdrawal(data.reverseWithdraw); + await admin.addReverseWithdrawal({ ...data.reverseWithdraw, store: data.predefined.vendorStores.vendor2, product: productName }); }); // vendor diff --git a/tests/pw/tests/e2e/sellerBadges.spec.ts b/tests/pw/tests/e2e/sellerBadges.spec.ts index 52d3d5af60..6f0cb253bb 100644 --- a/tests/pw/tests/e2e/sellerBadges.spec.ts +++ b/tests/pw/tests/e2e/sellerBadges.spec.ts @@ -53,13 +53,13 @@ test.describe('Seller badge test', () => { await admin.editSellerBadge({ ...data.sellerBadge, badgeName: data.sellerBadge.eventName.productsPublished }); }); - // test.skip('admin can filter vendors by seller badge @pro @a', async ( ) => { - // await admin.filterVendorsByBadge(data.sellerBadge.eventName.productsPublished); - // }); + test.skip('admin can filter vendors by seller badge @pro @a', async () => { + await admin.filterVendorsByBadge(data.sellerBadge.eventName.productsPublished); + }); - // test.skip('admin can view seller badge vendors @pro @a', async ( ) => { - // await admin.sellerBadgeVendors(data.sellerBadge.eventName.productsPublished); - // }); + test.skip('admin can view seller badge vendors @pro @a', async () => { + await admin.sellerBadgeVendors(data.sellerBadge.eventName.productsPublished); + }); test('admin can view seller badges acquired by vendor @pro @a', async () => { await admin.sellerBadgeAcquiredByVendor(data.predefined.vendorStores.vendor1); diff --git a/tests/pw/tests/e2e/setting.spec.ts b/tests/pw/tests/e2e/setting.spec.ts index 5fd847b0ff..1d12215599 100644 --- a/tests/pw/tests/e2e/setting.spec.ts +++ b/tests/pw/tests/e2e/setting.spec.ts @@ -50,12 +50,12 @@ test.describe.skip('Settings test', () => { test.skip('admin can set vendor store url (general settings) @lite @a', async () => { // todo: need to run on serial mode, will fail other tests await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, custom_store_url: 'stores' }); - CI ? await helpers.execommand(data.command.permalink) : await helpers.execommand(data.command.permalinkLocal); + CI ? await helpers.exeCommand(data.command.permalink) : await helpers.exeCommand(data.command.permalinkLocal); await admin.vendorStoreUrlSetting(data.predefined.vendorStores.vendor1, 'stores'); //reset await dbUtils.setDokanSettings(dbData.dokan.optionName.general, dbData.dokan.generalSettings); - CI ? await helpers.execommand(data.command.permalink) : await helpers.execommand(data.command.permalinkLocal); + CI ? await helpers.exeCommand(data.command.permalink) : await helpers.exeCommand(data.command.permalinkLocal); }); test('admin can set vendor setup wizard logo & message (general settings) @lite @a', async () => { @@ -67,7 +67,7 @@ test.describe.skip('Settings test', () => { setup_wizard_logo_url: logoUrl, setup_wizard_message: dbData.testData.dokan.generalSettings.setup_wizard_message, }); - await admin.vendorSetupWizardLogoAndMessageSetting(logoUrl, dbData.testData.dokan.generalSettings.setup_wozard_message_without_html); + await admin.vendorSetupWizardLogoAndMessageSetting(logoUrl, dbData.testData.dokan.generalSettings.setup_wizard_message_without_html); }); test('admin can disable vendor setup wizard (general settings) @lite @g', async () => { diff --git a/tests/pw/tests/e2e/shop.spec.ts b/tests/pw/tests/e2e/shop.spec.ts index 2657aa87f7..cd4709fda2 100644 --- a/tests/pw/tests/e2e/shop.spec.ts +++ b/tests/pw/tests/e2e/shop.spec.ts @@ -1,25 +1,19 @@ -import { test, request, Page } from '@playwright/test'; +import { test, Page } from '@playwright/test'; import { ShopPage } from '@pages/shopPage'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Shop functionality test', () => { let customer: ShopPage; let cPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new ShopPage(cPage); - - // apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await cPage.close(); - // await apiUtils.dispose(); }); // shop page diff --git a/tests/pw/tests/e2e/singleProduct.spec.ts b/tests/pw/tests/e2e/singleProduct.spec.ts index 5587913ee2..02e5e722a8 100644 --- a/tests/pw/tests/e2e/singleProduct.spec.ts +++ b/tests/pw/tests/e2e/singleProduct.spec.ts @@ -1,24 +1,19 @@ import { test, Page } from '@playwright/test'; import { SingleProductPage } from '@pages/singleProductPage'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Single product functionality test', () => { let customer: SingleProductPage; let cPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new SingleProductPage(cPage); - // apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await cPage.close(); - // await apiUtils.dispose(); }); // single product page diff --git a/tests/pw/tests/e2e/singleStore.spec.ts b/tests/pw/tests/e2e/singleStore.spec.ts index 545a1530d5..8b52a10638 100644 --- a/tests/pw/tests/e2e/singleStore.spec.ts +++ b/tests/pw/tests/e2e/singleStore.spec.ts @@ -1,24 +1,19 @@ import { test, Page } from '@playwright/test'; import { SingleStorePage } from '@pages/singleStorePage'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Single store functionality test', () => { let customer: SingleStorePage; let cPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new SingleStorePage(cPage); - // apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await cPage.close(); - // await apiUtils.dispose(); }); // single store page @@ -27,10 +22,10 @@ test.describe('Single store functionality test', () => { await customer.singleStoreRenderProperly(data.predefined.vendorStores.vendor1); }); - // test.skip('customer can view store open-close time on single store @lite @c', async ( ) => { - // // todo: pre: need store open close - // await customer.storeOpenCloseTime(data.predefined.vendorStores.vendor1); - // }); + test.skip('customer can view store open-close time on single store @lite @c', async () => { + // todo: pre: need store open close time + await customer.storeOpenCloseTime(data.predefined.vendorStores.vendor1); + }); test('customer can search product on single store @lite @c', async () => { await customer.singleStoreSearchProduct(data.predefined.vendorStores.vendor1, data.predefined.simpleProduct.product1.name); @@ -40,10 +35,10 @@ test.describe('Single store functionality test', () => { await customer.singleStoreSortProducts(data.predefined.vendorStores.vendor1, 'price'); }); - // test.skip('customer can view store terms and conditions @lite @c', async ( ) => { - // // todo: pre need toc on store and admin settings - // await customer.storeTermsAndCondition(data.predefined.vendorStores.vendor1, data.vendor.toc); - // }); + test.skip('customer can view store terms and conditions @lite @c', async () => { + // todo: pre need toc on store and admin settings + await customer.storeTermsAndCondition(data.predefined.vendorStores.vendor1, data.vendor.toc); + }); test('customer can share store @pro @c', async () => { await customer.storeShare(data.predefined.vendorStores.vendor1, data.storeShare.facebook); diff --git a/tests/pw/tests/e2e/spmv.spec.ts b/tests/pw/tests/e2e/spmv.spec.ts index 7edb812f1b..775fadf16d 100644 --- a/tests/pw/tests/e2e/spmv.spec.ts +++ b/tests/pw/tests/e2e/spmv.spec.ts @@ -13,7 +13,7 @@ test.describe('Vendor SPMV test', () => { let aPage: Page, vPage: Page, cPage: Page; let apiUtils: ApiUtils; let productName: string; - let productName1: string; + let productName2: string; let productId: string; test.beforeAll(async ({ browser }) => { @@ -32,7 +32,7 @@ test.describe('Vendor SPMV test', () => { apiUtils = new ApiUtils(await request.newContext()); await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, enable_min_max_quantity: 'off', enable_min_max_amount: 'off' }); // todo: might exists dokan issue -> min-max field is required on admin product edit [, , productName] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.spmv.productName() }, payloads.vendor2Auth); - [, productId, productName1] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.spmv.productName() }, payloads.vendor2Auth); + [, productId, productName2] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.spmv.productName() }, payloads.vendor2Auth); await apiUtils.addSpmvProductToStore(productId, payloads.vendorAuth); }); @@ -75,7 +75,7 @@ test.describe('Vendor SPMV test', () => { }); test('vendor can go to own product edit from spmv page @pro @v', async () => { - await vendor.goToProductEditFromSPMV(data.predefined.simpleProduct.product1.name); + await vendor.goToProductEditFromSpmv(data.predefined.simpleProduct.product1.name); }); test('vendor can sort spmv products @pro @v', async () => { @@ -94,18 +94,18 @@ test.describe('Vendor SPMV test', () => { // customer test('customer can view other available vendors @pro @c', async () => { - await customer.viewOtherAvailableVendors(productName1); + await customer.viewOtherAvailableVendors(productName2); }); test('customer can view other available vendor @pro @c', async () => { - await customer.viewOtherAvailableVendor(productName1, data.predefined.vendorStores.vendor1); + await customer.viewOtherAvailableVendor(productName2, data.predefined.vendorStores.vendor1); }); test('customer can view other available vendor product @pro @c', async () => { - await customer.viewOtherAvailableVendorProduct(productName1, data.predefined.vendorStores.vendor1); + await customer.viewOtherAvailableVendorProduct(productName2, data.predefined.vendorStores.vendor1); }); test('customer can add to cart other available vendor product @pro @c', async () => { - await customer.addToCartOtherAvailableVendorsProduct(productName1, data.predefined.vendorStores.vendor1); + await customer.addToCartOtherAvailableVendorsProduct(productName2, data.predefined.vendorStores.vendor1); }); }); diff --git a/tests/pw/tests/e2e/storeCategories.spec.ts b/tests/pw/tests/e2e/storeCategories.spec.ts index 733699cecb..6777680c03 100644 --- a/tests/pw/tests/e2e/storeCategories.spec.ts +++ b/tests/pw/tests/e2e/storeCategories.spec.ts @@ -55,11 +55,11 @@ test.describe('Store categories test', () => { }); test('admin can delete store category @pro @a', async () => { + const [, , categoryName] = await apiUtils.createStoreCategory(payloads.createStoreCategory(), payloads.adminAuth); await admin.updateStoreCategory(categoryName, 'delete'); }); test('vendor can update own store category @pro @v', async () => { - const [, , categoryName] = await apiUtils.createStoreCategory(payloads.createStoreCategory(), payloads.adminAuth); await vendor.vendorUpdateStoreCategory(categoryName); }); diff --git a/tests/pw/tests/e2e/storeSupports.spec.ts b/tests/pw/tests/e2e/storeSupports.spec.ts index 6f05f075b2..4aa0c9a296 100644 --- a/tests/pw/tests/e2e/storeSupports.spec.ts +++ b/tests/pw/tests/e2e/storeSupports.spec.ts @@ -12,7 +12,6 @@ test.describe('Store Support test (admin)', () => { let aPage: Page; let apiUtils: ApiUtils; let supportTicketId: string; - let closedSupportTicketId: string; test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); @@ -21,7 +20,6 @@ test.describe('Store Support test (admin)', () => { apiUtils = new ApiUtils(await request.newContext()); [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); - [, closedSupportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, status: 'closed', author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); }); test.afterAll(async () => { @@ -29,6 +27,8 @@ test.describe('Store Support test (admin)', () => { await apiUtils.dispose(); }); + //admin + test('dokan store support menu page is rendering properly @pro @exp @a', async () => { await admin.adminStoreSupportRenderProperly(); }); @@ -41,9 +41,12 @@ test.describe('Store Support test (admin)', () => { await admin.adminViewSupportTicketDetails(supportTicketId); }); - test('admin can search support ticket @pro @a', async () => { + test('admin can search support ticket by ticket id @pro @a', async () => { await admin.searchSupportTicket(supportTicketId); - // await admin.searchSupportTicket(data.storeSupport.title); // todo: + }); + + test('admin can search support ticket by ticket title @pro @a', async () => { + await admin.searchSupportTicket(data.storeSupport.title); }); test('admin can filter support tickets by vendor @pro @a', async () => { @@ -63,11 +66,11 @@ test.describe('Store Support test (admin)', () => { }); test('admin can disable support ticket email notification @pro @a', async () => { - // await apiUtils.updateSupportTicketEmailNotification(supportTicketId, { notification: true, }, payloads.adminAuth); await admin.updateSupportTicketEmailNotification(supportTicketId, 'disable'); }); test('admin can enable support ticket email notification @pro @a', async () => { + const [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); await apiUtils.updateSupportTicketEmailNotification(supportTicketId, { notification: false }, payloads.adminAuth); await admin.updateSupportTicketEmailNotification(supportTicketId, 'enable'); }); @@ -77,6 +80,7 @@ test.describe('Store Support test (admin)', () => { }); test('admin can reopen closed support ticket @pro @a', async () => { + const [, closedSupportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, status: 'closed', author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); await admin.reopenSupportTicket(closedSupportTicketId); }); @@ -89,7 +93,7 @@ test.describe('Store Support test (admin)', () => { test.describe('Store Support test (customer)', () => { let customer: StoreSupportsPage; let guest: StoreSupportsPage; - let cPage: Page, gPage: Page; + let cPage: Page; let apiUtils: ApiUtils; let orderId: string; let responseBody: responseBody; @@ -100,10 +104,6 @@ test.describe('Store Support test (customer)', () => { cPage = await customerContext.newPage(); customer = new StoreSupportsPage(cPage); - const guestContext = await browser.newContext(data.auth.noAuth); - gPage = await guestContext.newPage(); - guest = new StoreSupportsPage(gPage); - apiUtils = new ApiUtils(await request.newContext()); [, responseBody, orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.completed, payloads.vendorAuth); [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, author: CUSTOMER_ID, meta: { store_id: VENDOR_ID, order_id: orderId } }); @@ -111,7 +111,6 @@ test.describe('Store Support test (customer)', () => { test.afterAll(async () => { await cPage.close(); - await gPage.close(); await apiUtils.dispose(); }); @@ -157,7 +156,8 @@ test.describe('Store Support test (customer)', () => { await customer.cantSendMessageToSupportTicket(supportTicketId); }); - test('guest customer need to login before asking for store support @pro @g', async () => { + test('guest customer need to login before asking for store support @pro @g', async ({ page }) => { + guest = new StoreSupportsPage(page); await guest.storeSupport(data.predefined.vendorStores.vendor1, data.customer.getSupport, 'store'); }); }); @@ -201,9 +201,12 @@ test.describe('Store Support test (vendor)', () => { await vendor.vendorFilterSupportTickets('by-date', data.date.dateRange); }); - test('vendor can search support ticket @pro @v', async () => { + test('vendor can search support ticket by ticket id @pro @v', async () => { await vendor.vendorSearchSupportTicket('id', supportTicketId); - // await vendor.vendorSearchSupportTicket('title', data.storeSupport.title); // todo: separate or in same test + }); + + test('vendor can search support ticket by ticket title @pro @v', async () => { + await vendor.vendorSearchSupportTicket('title', data.storeSupport.title); }); test('vendor can reply to support ticket @pro @v', async () => { diff --git a/tests/pw/tests/e2e/storelisting.spec.ts b/tests/pw/tests/e2e/storelisting.spec.ts index 6e676c932d..69b9914a47 100644 --- a/tests/pw/tests/e2e/storelisting.spec.ts +++ b/tests/pw/tests/e2e/storelisting.spec.ts @@ -61,7 +61,6 @@ test.describe('Store listing functionality test', () => { test('customer can view stores on map @pro @c', async () => { await customer.storeOnMap(); - // await customer.storeOnMap(data.predefined.vendorStores.vendor1); }); test('customer can go to single store from store list @lite @c', async () => { diff --git a/tests/pw/tests/e2e/stores.spec.ts b/tests/pw/tests/e2e/stores.spec.ts index c2148974ac..5ef2553583 100644 --- a/tests/pw/tests/e2e/stores.spec.ts +++ b/tests/pw/tests/e2e/stores.spec.ts @@ -1,28 +1,27 @@ import { test, request, Page } from '@playwright/test'; import { StoresPage } from '@pages/storesPage'; -// import { ApiUtils } from '@utils/apiUtils'; +import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; +import { payloads } from '@utils/payloads'; const { VENDOR_ID } = process.env; test.describe('Stores test', () => { let admin: StoresPage; let aPage: Page; - // let apiUtils: ApiUtils; - // let storeName: string; + let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new StoresPage(aPage); - // apiUtils = new ApiUtils(await request.newContext()); - // [,, storeName] = await apiUtils.createStore(payloads.createStore()); + + apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await aPage.close(); - // await apiUtils.dispose(); + await apiUtils.dispose(); }); // stores @@ -48,11 +47,13 @@ test.describe('Stores test', () => { }); test("admin can disable vendor's selling capability @lite @a", async () => { - await admin.updateVendor(data.predefined.vendorStores.vendor1, 'disable'); //todo: nedd different vendor for this + const [, , storeName] = await apiUtils.createStore(payloads.createStore(), payloads.adminAuth); + await admin.updateVendor(storeName, 'disable'); }); test("admin can enable vendor's selling capability @lite @a", async () => { - await admin.updateVendor(data.predefined.vendorStores.vendor1, 'enable'); + const [, , storeName] = await apiUtils.createStore(payloads.createStore(), payloads.adminAuth); + await admin.updateVendor(storeName, 'enable'); }); test('admin can edit vendor info @lite @a', async () => { diff --git a/tests/pw/tests/e2e/tools.spec.ts b/tests/pw/tests/e2e/tools.spec.ts index 406b76ed90..2ec99523db 100644 --- a/tests/pw/tests/e2e/tools.spec.ts +++ b/tests/pw/tests/e2e/tools.spec.ts @@ -46,9 +46,10 @@ test.describe('Tools test', () => { await admin.regenerateVariableProductVariationsAuthorIds(); }); - // test.skip('admin can import dummy data @pro', async ( ) => { - // await admin.importDummyData(); - // }); + test.skip('admin can import dummy data @pro', async ( ) => { + // todo: need to fix + await admin.importDummyData(); + }); test('admin can clear dummy data @pro @a', async () => { await apiUtils.importDummyData(payloads.dummyData, payloads.adminAuth); diff --git a/tests/pw/utils/apiUtils.ts b/tests/pw/utils/apiUtils.ts index fac96ce1f4..6c48ee2200 100644 --- a/tests/pw/utils/apiUtils.ts +++ b/tests/pw/utils/apiUtils.ts @@ -3,7 +3,7 @@ import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; import { helpers } from '@utils/helpers'; import fs from 'fs'; -import { auth, user_api, taxRate, coupon_api, marketPlaceCoupon, reqOptions, headers, storageState, responseBody } from '@utils/interfaces'; +import { auth, user_api, taxRate, coupon_api, marketPlaceCoupon, reqOptions, params, headers, storageState, responseBody } from '@utils/interfaces'; const { VENDOR_ID, CUSTOMER_ID } = process.env; @@ -167,7 +167,7 @@ export class ApiUtils { } // create store - async createStore(payload: any, auth?: auth): Promise<[responseBody, string, string]> { + async createStore(payload: any, auth?: auth, addUserAddress: boolean = false): Promise<[responseBody, string, string]> { const [response, responseBody] = await this.post(endPoints.createStore, { data: payload, headers: auth }, false); let sellerId: string; let storeName: string; @@ -185,6 +185,10 @@ export class ApiUtils { sellerId = String(responseBody?.id); storeName = String(responseBody?.store_name); } + + // add vendor user address + addUserAddress && (await this.updateCustomer(sellerId, payloads.updateAddress, payloads.adminAuth)); + return [responseBody, sellerId, storeName]; } @@ -1011,16 +1015,21 @@ export class ApiUtils { */ // get all quote rules - async getAllQuoteRules(auth?: auth): Promise { - const [, responseBody] = await this.get(endPoints.getAllQuoteRules, { params: { per_page: 100 }, headers: auth }); + async getAllQuoteRules(params: params = { per_page: 100 }, auth?: auth): Promise { + if (arguments.length === 1 && 'Authorization' in params) { + auth = params as auth; + params = undefined; + } + const [, responseBody] = await this.get(endPoints.getAllQuoteRules, { params, headers: auth }); return responseBody; } // create quote rule - async createQuoteRule(payload: object, auth?: auth): Promise<[responseBody, string]> { + async createQuoteRule(payload: object, auth?: auth): Promise<[responseBody, string, string]> { const [, responseBody] = await this.post(endPoints.createQuoteRule, { data: payload, headers: auth }); const quoteRuleId = String(responseBody?.id); - return [responseBody, quoteRuleId]; + const quoteRuleName = responseBody?.rule_name; + return [responseBody, quoteRuleId, quoteRuleName]; } // delete quote rule @@ -1040,6 +1049,17 @@ export class ApiUtils { return responseBody; } + // delete all quote rules trashed + async deleteAllQuoteRulesTrashed(auth?: auth): Promise { + const allQuoteRuleIds = (await this.getAllQuoteRules({ status: 'trash', per_page: 100 }, auth)).map((o: { id: unknown }) => o.id); + if (!allQuoteRuleIds?.length) { + console.log('No quote rule exists'); + return; + } + const [, responseBody] = await this.put(endPoints.updateBatchQuoteRules, { data: { delete: allQuoteRuleIds }, headers: auth }); + return responseBody; + } + /** * quote requests api methods */ diff --git a/tests/pw/utils/dbData.ts b/tests/pw/utils/dbData.ts index 06e9781358..c180616fcd 100644 --- a/tests/pw/utils/dbData.ts +++ b/tests/pw/utils/dbData.ts @@ -653,7 +653,7 @@ export const dbData = { setup_wizard_logo_url: '', setup_wizard_message: '

Thank you for choosing The Marketplace to power your online store! This quick setup wizard will help you configure the basic settings. It’s completely optional and shouldn’t take longer than two minutes. Test wizard message.

', - setup_wozard_message_without_html: + setup_wizard_message_without_html: 'Thank you for choosing The Marketplace to power your online store! This quick setup wizard will help you configure the basic settings. It’s completely optional and shouldn’t take longer than two minutes. Test wizard message.', disable_welcome_wizard: 'off', global_digital_mode: 'sell_both', diff --git a/tests/pw/utils/dbUtils.ts b/tests/pw/utils/dbUtils.ts index 804f8f3fd5..c7ec1d6578 100644 --- a/tests/pw/utils/dbUtils.ts +++ b/tests/pw/utils/dbUtils.ts @@ -100,7 +100,7 @@ export const dbUtils = { }, // create refund - async createRefund(responseBody: any): Promise<[any, string]> { + async createRefundRequest(responseBody: any): Promise<[any, string]> { const refundId = (await this.getMaxId('id', 'dokan_refund')) + 1; const refund = { diff --git a/tests/pw/utils/helpers.ts b/tests/pw/utils/helpers.ts index 28855f92a6..0362729e52 100644 --- a/tests/pw/utils/helpers.ts +++ b/tests/pw/utils/helpers.ts @@ -79,7 +79,7 @@ export const helpers = { // remove dollar sign removeCurrencySign: (str: string): string => str.replace(/[^\d\-.,\\s]/g, ''), - // dateFormat // todo: remove all datetime , and update date to return date as required formate // also method to return as site date format + // dateFormat // todo: remove all date-time , and update date to return date as required formate // also method to return as site date format dateFormatFYJ: (date: string) => new Date(date).toLocaleDateString('en-CA', { year: 'numeric', month: 'long', day: 'numeric' }), // current year @@ -150,7 +150,7 @@ export const helpers = { return subtotal.reduce((a, b) => a + b, 0); }, - lineItemsToSubtoal(lineItems: object[]) { + lineItemsToSubtotal(lineItems: object[]) { const arrOfPriceQuantity = lineItems.map(({ price, quantity }) => [price, quantity]); // const arrOfSubtotals = res.map(([price, quantity]) => price * quantity) const subtotal = arrOfPriceQuantity.reduce((sum, [price, quantity]) => sum + price * quantity, 0); @@ -353,7 +353,7 @@ export const helpers = { }, // execute command - async execommand(command: string) { + async exeCommand(command: string) { const output = execSync(command, { encoding: 'utf-8' }); console.log(output); }, diff --git a/tests/pw/utils/interfaces.ts b/tests/pw/utils/interfaces.ts index 85b7e0dc26..64e72f2e30 100644 --- a/tests/pw/utils/interfaces.ts +++ b/tests/pw/utils/interfaces.ts @@ -668,6 +668,11 @@ export interface vendor { lastname: string; storeName: string; + vendor2: { + username: string; + password: string; + }; + vendorInfo: { email: () => string; // emailDomain: string; @@ -1790,6 +1795,8 @@ export interface reqOptions { timeout?: number | undefined; } +export type params = Record | undefined; + export type headers = Record; export interface storageState { diff --git a/tests/pw/utils/payloads.ts b/tests/pw/utils/payloads.ts index 92819bc0a3..ae65a10e2a 100644 --- a/tests/pw/utils/payloads.ts +++ b/tests/pw/utils/payloads.ts @@ -2834,6 +2834,132 @@ export const payloads = { admin_commission_type: '', }, + createStore3: { + user_login: process.env.VENDOR3, + user_pass: process.env.USER_PASSWORD, + user_nicename: process.env.VENDOR3 + 'store', + role: 'seller', + email: process.env.VENDOR3 + '@yopmail.com', + store_name: process.env.VENDOR3 + 'store', + first_name: process.env.VENDOR3, + last_name: 'v', + social: { + fb: 'http://dokan.test', + youtube: 'http://dokan.test', + twitter: 'http://dokan.test', + linkedin: 'http://dokan.test', + pinterest: 'http://dokan.test', + instagram: 'http://dokan.test', + flickr: 'http://dokan.test', + }, + phone: '0123456789', + show_email: true, // todo: doesn't work on lite + address: { + street_1: 'abc street', + street_2: 'xyz street', + city: 'New York', + zip: '10003', + state: 'NY', + country: 'US', + }, + location: '40.7127753,-74.0059728', + banner: 0, + banner_id: 0, + gravatar: 0, + gravatar_id: 0, + show_more_product_tab: true, + toc_enabled: true, // todo: doesn't work on lite + store_toc: 'test Vendor terms and conditions', + featured: true, + rating: { + rating: '4.00', // todo: doesn't work on lite + count: 1, + }, + enabled: true, + payment: { + paypal: { + 0: 'email', + email: 'paypal@g.c', + }, + bank: { + ac_name: 'account name', + ac_type: 'personal', + ac_number: '1234567', + bank_name: 'bank name', + bank_addr: 'bank address', + routing_number: '123456', + iban: '123456', + swift: '12345', + }, + stripe: false, + }, + trusted: true, + // store_open_close: { + // enabled: false, + // time: [], + // open_notice: 'Store is open', + // close_notice: 'Store is closed', + // }, + store_open_close: { + // todo: doesn't work on lite + enabled: true, + time: { + monday: { + status: 'open', // 'close' + opening_time: ['12:00 am'], // [] + closing_time: ['11:30 pm'], // [] + }, + tuesday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + wednesday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + thursday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + friday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + saturday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + sunday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + }, + open_notice: 'Store is open', + close_notice: 'Store is closed', + }, + company_name: '', + vat_number: '', + company_id_number: '', + bank_name: '', + bank_iban: '', + categories: [ + { + // id: 74, + // name: 'Uncategorized', + // slug: 'uncategorized' + }, + ], + admin_commission: '', + admin_additional_fee: '', + admin_commission_type: '', + }, + createCustomer1: { email: process.env.CUSTOMER + '@yopmail.com', first_name: 'customer1', @@ -2871,7 +2997,7 @@ export const payloads = { updateAddress: { billing: { first_name: faker.person.firstName(), - last_name: 'c1', + last_name: faker.person.lastName(), company: '', address_1: 'abc street', address_2: 'xyz street', @@ -2884,7 +3010,7 @@ export const payloads = { }, shipping: { first_name: faker.person.firstName(), - last_name: 'c1', + last_name: faker.person.lastName(), company: '', address_1: 'abc street', address_2: 'xyz street', diff --git a/tests/pw/utils/testData.ts b/tests/pw/utils/testData.ts index 7d844d6bfc..e40007a5ce 100644 --- a/tests/pw/utils/testData.ts +++ b/tests/pw/utils/testData.ts @@ -1,4 +1,3 @@ -// import { request } from '@playwright/test'; import { faker } from '@faker-js/faker'; import { helpers } from '@utils/helpers'; import 'dotenv/config'; @@ -34,6 +33,7 @@ export const data = { auth: { adminAuthFile: 'playwright/.auth/adminStorageState.json', vendorAuthFile: 'playwright/.auth/vendorStorageState.json', + vendor2AuthFile: 'playwright/.auth/vendor2StorageState.json', customerAuthFile: 'playwright/.auth/customerStorageState.json', adminAuth: { @@ -44,6 +44,10 @@ export const data = { storageState: 'playwright/.auth/vendorStorageState.json', }, + vendor2Auth: { + storageState: 'playwright/.auth/vendor2StorageState.json', + }, + customerAuth: { storageState: 'playwright/.auth/customerStorageState.json', }, @@ -1017,6 +1021,11 @@ export const data = { lastname: (String(process.env.VENDOR)[0] as string) + String(process.env.VENDOR)[String(process.env.VENDOR).length - 1], storeName: String(process.env.VENDOR) + 'store', + vendor2: { + username: String(process.env.VENDOR2), + password: String(process.env.USER_PASSWORD), + }, + vendorInfo: { emailDomain: '@email.com', // email : () => faker.internet.email(), @@ -1541,9 +1550,9 @@ export const data = { // Reverse withdraw reverseWithdraw: { - store: String(process.env.VENDOR) + 'store', + store: String(process.env.VENDOR2) + 'store', transactionType: 'manual_product', // manual_product, manual_order, other - product: 'p1_v1 (simple)', + product: '', withdrawalBalanceType: 'debit', // debit, credit amount: '500', note: 'test reverse withdraw note', @@ -1566,8 +1575,8 @@ export const data = { guest: 'guest', }, - quoteRule: { - title: () => 'test rule_' + faker.string.nanoid(10), + quoteRule: () => ({ + title: 'test rule_' + faker.string.nanoid(10), userRole: 'customer', product: 'p1_v1 (simple)', category: 'Uncategorized', @@ -1576,15 +1585,15 @@ export const data = { hideAddToCartButton: 'keep_and_add_new', // replace, keep_and_add_new customButtonLabel: 'Add to quote', order: '0', - }, + }), trashedQuoteRule: { - title: 'trashed quote rule ', + title: 'trashed quote rule', status: 'trash', }, - quote: { - title: () => 'test quote_' + faker.string.nanoid(10), + quote: () => ({ + title: 'test quote_' + faker.string.nanoid(10), user: 'customer1', // todo: update customer data via env and email domain fullName: 'Jhon Doe', email: 'customer1@g.com', @@ -1594,7 +1603,7 @@ export const data = { quantity: '5', offerPrice: '80', offerProductQuantity: '10', - }, + }), trashedQuote: { title: 'trashed quote', @@ -2106,6 +2115,7 @@ export const data = { followFromStoreListing: 'storeListing', followFromSingleStore: 'singleStore', vendor1: String(process.env.VENDOR) + 'store', + vendor2: String(process.env.VENDOR2) + 'store', vendor1FullName: String(process.env.VENDOR) + ' ' + 'v1', shopUrl: String(process.env.VENDOR) + 'store', },