diff --git a/tests/pw/api.config.ts b/tests/pw/api.config.ts index c97ce5993d..49882a3f31 100644 --- a/tests/pw/api.config.ts +++ b/tests/pw/api.config.ts @@ -9,7 +9,7 @@ export default defineConfig({ // globalTeardown: './global-teardown' /* Path to the global teardown file. This file will be required and run after all the tests. */, globalTimeout: process.env.CI ? 20 * (60 * 1000) : 20 * (60 * 1000) /* Maximum time in milliseconds the whole test suite can run */, maxFailures: process.env.CI ? 30 : 30 /* The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error. */, - timeout: process.env.CI ? 15 * 1000 : 15 * 1000 /* Maximum time one test can run for. */, + timeout: process.env.CI ? 15 * 1000 : 20 * 1000 /* Maximum time one test can run for. */, expect: { timeout: 5 * 1000 /* Maximum time expect() should wait for the condition to be met. For example in `await expect(locator).toHaveText();`*/, } /* Configuration for the expect assertion library */, diff --git a/tests/pw/pages/basePage.ts b/tests/pw/pages/basePage.ts index e1b8e33d66..bdeea406fe 100644 --- a/tests/pw/pages/basePage.ts +++ b/tests/pw/pages/basePage.ts @@ -264,7 +264,9 @@ export class BasePage { // type & wait for response async typeViaPageAndWaitForResponse(subUrl: string, selector: string, text: string, code = 200): Promise { - const [response] = await Promise.all([this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code), this.page.locator(selector).pressSequentially(text, { delay: 100 })]); + const [response] = await Promise.all([ + this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code), + this.page.locator(selector).pressSequentially(text, { delay: 100 })]); return response; } @@ -272,7 +274,6 @@ export class BasePage { async typeAndWaitForResponse(subUrl: string, selector: string, text: string, code = 200): Promise { const [response] = await Promise.all([ this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code), - // await this.page.locator(selector).pressSequentially(text), this.clearAndFill(selector, text), ]); return response; @@ -874,7 +875,8 @@ export class BasePage { // check locator async checkLocator(selector: string): Promise { const locator = this.page.locator(selector); - await locator.check({ force: true }); // forced is used to avoid "locator.check: Clicking the checkbox did not change its state" error + await locator.check(); + // await locator.check({ force: true }); // forced is used to avoid "locator.check: Clicking the checkbox did not change its state" error } // click locator diff --git a/tests/pw/pages/productAddonsPage.ts b/tests/pw/pages/productAddonsPage.ts index a71d8bc8a3..4c76a8e012 100644 --- a/tests/pw/pages/productAddonsPage.ts +++ b/tests/pw/pages/productAddonsPage.ts @@ -22,13 +22,13 @@ export class ProductAddonsPage extends VendorPage { // create new addon text is visible await this.toBeVisible(selector.vendor.vAddonSettings.createNewAddon); - // create new text is visible + // create new text is visible await this.toBeVisible(selector.vendor.vAddonSettings.createNew); // product addon table elements are visible await this.multipleElementVisible(selector.vendor.vAddonSettings.table); - await this.click(selector.vendor.vAddonSettings.createNewAddon); + await this.clickAndWaitForLoadState(selector.vendor.vAddonSettings.createNewAddon); await this.click(selector.vendor.vAddonSettings.addon.addField); await this.check(selector.vendor.vAddonSettings.addon.enableDescription); @@ -69,7 +69,7 @@ export class ProductAddonsPage extends VendorPage { // add addon async addAddon(addon: vendor['addon']) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsAddon); - await this.click(selector.vendor.vAddonSettings.createNewAddon); + await this.clickAndWaitForLoadState(selector.vendor.vAddonSettings.createNewAddon); await this.updateAddonFields(addon); } diff --git a/tests/pw/pages/reportsPage.ts b/tests/pw/pages/reportsPage.ts index c56559bcc9..3fc332d34c 100644 --- a/tests/pw/pages/reportsPage.ts +++ b/tests/pw/pages/reportsPage.ts @@ -61,7 +61,7 @@ export class ReportsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.allLogs); await this.clearInputField(selector.admin.dokan.reports.allLogs.search); - await this.typeViaPageAndWaitForResponse(data.subUrls.api.dokan.logs, selector.admin.dokan.reports.allLogs.search, orderId); + await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.logs, selector.admin.dokan.reports.allLogs.search, orderId); await this.toBeVisible(selector.admin.dokan.reports.allLogs.orderIdCell(orderId)); const count = (await this.getElementText(selector.admin.dokan.reports.allLogs.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBe(1); diff --git a/tests/pw/pages/selectors.ts b/tests/pw/pages/selectors.ts index e791ba69a2..3838f338b9 100644 --- a/tests/pw/pages/selectors.ts +++ b/tests/pw/pages/selectors.ts @@ -3463,7 +3463,7 @@ export const selector = { // Product Sub Options numberOfRowsFound: '#dokan-product-list-table tbody tr', - productCell: (productName: string) => `//a[contains(text(),'${productName}')]/../..`, + productCell: (productName: string) => `//strong//a[contains(text(),'${productName}')]/../..`, productLink: (productName: string) => `//strong//a[contains(text(),'${productName}')]`, editProduct: (productName: string) => `//a[contains(text(),'${productName}')]/../..//span[@class="edit"]//a`, buyAdvertisement: (productName: string) => `//a[contains(text(),'${productName}')]/../../..//td[@class="product-advertisement-td"]//span`, diff --git a/tests/pw/tests/api/announcements.spec.ts b/tests/pw/tests/api/announcements.spec.ts index b418147d8b..7e82f13dfc 100644 --- a/tests/pw/tests/api/announcements.spec.ts +++ b/tests/pw/tests/api/announcements.spec.ts @@ -36,6 +36,7 @@ test.describe('announcements api test', () => { test('get single announcement @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getSingleAnnouncement(announcementId)); + console.log(responseBody); expect(response.ok()).toBeTruthy(); expect(responseBody).toBeTruthy(); expect(responseBody).toMatchSchema(schemas.announcementsSchema.announcementSchema); diff --git a/tests/pw/tests/api/calculation.spec.ts b/tests/pw/tests/api/calculation.spec.ts index aea1a6991b..87e82cd935 100644 --- a/tests/pw/tests/api/calculation.spec.ts +++ b/tests/pw/tests/api/calculation.spec.ts @@ -251,7 +251,7 @@ test.describe.skip('commission test', () => { ]; console.table(table); } else { - // todo: modify for lite as well + // todo: modify for lite as well const table = [ [`OID: ${oid}`, 'OrderTotal', 'VendorEarning', 'AdmminCommission', 'GatewayFee', 'ShippingFee', 'ShippingTax', 'ProductTax'], ['Expected', calculatedOrderTotal, calculatedVendorEarning, calculatedAdminCommission, gatewayFee, providedShippingFee, calculatedShippingTax, calculatedProductTax], diff --git a/tests/pw/tests/api/refunds.spec.ts b/tests/pw/tests/api/refunds.spec.ts index b9027c12ac..75d5c78f2d 100644 --- a/tests/pw/tests/api/refunds.spec.ts +++ b/tests/pw/tests/api/refunds.spec.ts @@ -51,14 +51,14 @@ test.describe('refunds api test', () => { }); test('approve a refund @pro', async () => { - const [, refundId] = await dbUtils.createRefund(orderResponseBody); + const [, refundId] = await dbUtils.createRefundRequest(orderResponseBody); const [response, responseBody] = await apiUtils.put(endPoints.approveRefund(refundId)); expect(response.ok()).toBeTruthy(); expect(responseBody).toBeTruthy(); }); test('update batch refunds @pro', async () => { - await dbUtils.createRefund(orderResponseBody); + await dbUtils.createRefundRequest(orderResponseBody); const allPendingRefundsIds = (await apiUtils.getAllRefunds('pending', payloads.vendorAuth)).map((a: { id: unknown }) => a.id); const [response, responseBody] = await apiUtils.put(endPoints.updateBatchRefunds, { data: { cancelled: allPendingRefundsIds } }); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/supportTickets.spec.ts b/tests/pw/tests/api/supportTickets.spec.ts index ab4477f690..821f802a41 100644 --- a/tests/pw/tests/api/supportTickets.spec.ts +++ b/tests/pw/tests/api/supportTickets.spec.ts @@ -80,8 +80,8 @@ test.describe('support ticket api test', () => { expect(responseBody).toBeTruthy(); // reopen all support tickets - for (const supportTicketId of allSupportTicketIds) { - await apiUtils.updateSupportTicketStatus(supportTicketId, 'open'); - } + // for (const supportTicketId of allSupportTicketIds) { + // await apiUtils.updateSupportTicketStatus(supportTicketId, 'open'); + // } }); }); diff --git a/tests/pw/tests/e2e/announcements.spec.ts b/tests/pw/tests/e2e/announcements.spec.ts index 5200b26019..01d8d46a70 100644 --- a/tests/pw/tests/e2e/announcements.spec.ts +++ b/tests/pw/tests/e2e/announcements.spec.ts @@ -60,7 +60,7 @@ test.describe('Announcements test (admin)', () => { }); test.skip('admin can perform announcements bulk action @pro @a', async () => { - // todo: might cause other tests to fail in parallel + // todo: might cause other tests to fail in parallel // await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth); await admin.announcementBulkAction('trash'); }); diff --git a/tests/pw/tests/e2e/productAddons.spec.ts b/tests/pw/tests/e2e/productAddons.spec.ts index 9fb30626e2..111d3695fa 100644 --- a/tests/pw/tests/e2e/productAddons.spec.ts +++ b/tests/pw/tests/e2e/productAddons.spec.ts @@ -33,7 +33,7 @@ test.describe('Product addon functionality test', () => { await apiUtils.deleteAllProductAddons(payloads.adminAuth); await vPage.close(); await apiUtils.dispose(); - }); + }); test('vendor product addons menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorProductAddonsSettingsRenderProperly(); diff --git a/tests/pw/tests/e2e/products.spec.ts b/tests/pw/tests/e2e/products.spec.ts index da1e23df22..79eb03d315 100644 --- a/tests/pw/tests/e2e/products.spec.ts +++ b/tests/pw/tests/e2e/products.spec.ts @@ -152,8 +152,8 @@ test.describe('Product functionality test', () => { await vendor.addProductDescription(productName, data.product.productInfo.description); }); - test.skip('vendor can add product quantity discount @pro @v', async ( ) => { - await vendor.addProductQuantityDiscount(productName, data.product.productInfo.quantityDiscount); + test.skip('vendor can add product quantity discount @pro @v', async () => { + await vendor.addProductQuantityDiscount(productName, data.product.productInfo.quantityDiscount); }); test('vendor can add product rma options @pro @v', async () => { diff --git a/tests/pw/tests/e2e/setting.spec.ts b/tests/pw/tests/e2e/setting.spec.ts index 1d12215599..ab1bf11f97 100644 --- a/tests/pw/tests/e2e/setting.spec.ts +++ b/tests/pw/tests/e2e/setting.spec.ts @@ -140,5 +140,4 @@ test.describe.skip('Settings test', () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, order_status_change: 'off' }); await vendor.setOrderStatusChangeCapability(orderId, 'off'); }); - }); diff --git a/tests/pw/tests/e2e/tools.spec.ts b/tests/pw/tests/e2e/tools.spec.ts index 2ec99523db..7908c21f77 100644 --- a/tests/pw/tests/e2e/tools.spec.ts +++ b/tests/pw/tests/e2e/tools.spec.ts @@ -46,9 +46,9 @@ test.describe('Tools test', () => { await admin.regenerateVariableProductVariationsAuthorIds(); }); - test.skip('admin can import dummy data @pro', async ( ) => { + test.skip('admin can import dummy data @pro', async () => { // todo: need to fix - await admin.importDummyData(); + await admin.importDummyData(); }); test('admin can clear dummy data @pro @a', async () => { diff --git a/tests/pw/tsconfig.json b/tests/pw/tsconfig.json index 893dc0c82f..ad9cdfbfaf 100644 --- a/tests/pw/tsconfig.json +++ b/tests/pw/tsconfig.json @@ -27,7 +27,7 @@ "@payloads": ["utils/payloads"], "@schemas": ["utils/schemas"], "@testData": ["utils/testData"], - "@pwMatchers": ["utils/pwMatchers"], + "@pwMatchers": ["utils/pwMatchers"] }, "esModuleInterop": true /* fixes some issues TS originally had with the ES6 spec where TypeScript treats CommonJS/AMD/UMD modules similar to ES6 module*/, "moduleResolution": "node" /* Pretty much always node for modern JS. Other option is "classic"*/, @@ -56,7 +56,7 @@ "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, "noUncheckedIndexedAccess": true /* accessing index must always check for undefined*/, "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, - "forceConsistentCasingInFileNames": true /* Force consistent Casing In File Names */, + "forceConsistentCasingInFileNames": true /* Force consistent Casing In File Names */ }, - "exclude": ["node_modules/**/*", "playwright/**/*", "playwright-report/**/*"], + "exclude": ["node_modules/**/*", "playwright/**/*", "playwright-report/**/*"] } diff --git a/tests/pw/utils/apiEndPoints.ts b/tests/pw/utils/apiEndPoints.ts index dd09c12769..ed677f75ef 100644 --- a/tests/pw/utils/apiEndPoints.ts +++ b/tests/pw/utils/apiEndPoints.ts @@ -332,14 +332,13 @@ export const endPoints = { updateProductQuestion: (questionId: string) => `${SERVER_URL}/dokan/v1/product-questions/${questionId}`, deleteProductQuestion: (questionId: string) => `${SERVER_URL}/dokan/v1/product-questions/${questionId}`, updateBatchProductQuestions: `${SERVER_URL}/dokan/v1/product-questions/bulk_action`, // method: delete, read, unread - + getAllProductQuestionAnswers: `${SERVER_URL}/dokan/v1/product-answers`, getSingleProductQuestionAnswer: (answerId: string) => `${SERVER_URL}/dokan/v1/product-answers/${answerId}`, createProductQuestionAnswer: `${SERVER_URL}/dokan/v1/product-answers`, updateProductQuestionAnswer: (answerId: string) => `${SERVER_URL}/dokan/v1/product-answers/${answerId}`, deleteProductQuestionAnswer: (answerId: string) => `${SERVER_URL}/dokan/v1/product-answers/${answerId}`, - wc: { // coupons getAllCoupons: `${SERVER_URL}/wc/v3/coupons`, diff --git a/tests/pw/utils/schemas.ts b/tests/pw/utils/schemas.ts index 124e8af5a4..853fda373f 100644 --- a/tests/pw/utils/schemas.ts +++ b/tests/pw/utils/schemas.ts @@ -605,21 +605,23 @@ export const schemas = { adminExportLogsSchema: z.object({ step: z.string().or(z.number()), percentage: z.number(), - columns: z.object({ - order_id: z.string(), - vendor_id: z.string(), - vendor_name: z.string(), - previous_order_total: z.string(), - order_total: z.string(), - vendor_earning: z.string(), - commission: z.string(), - dokan_gateway_fee: z.string(), - gateway_fee_paid_by: z.string(), - shipping_total: z.string(), - tax_total: z.string(), - status: z.string(), - date: z.string(), - }).or(z.null()), + columns: z + .object({ + order_id: z.string(), + vendor_id: z.string(), + vendor_name: z.string(), + previous_order_total: z.string(), + order_total: z.string(), + vendor_earning: z.string(), + commission: z.string(), + dokan_gateway_fee: z.string(), + gateway_fee_paid_by: z.string(), + shipping_total: z.string(), + tax_total: z.string(), + status: z.string(), + date: z.string(), + }) + .or(z.null()), }), },