From 144b7234c9bb057f1f8f4824a3a65ac5467bf283 Mon Sep 17 00:00:00 2001 From: shashwata Date: Fri, 16 Feb 2024 15:01:37 +0600 Subject: [PATCH] update suite for parallellism --- .github/workflows/e2e_api_tests.yml | 27 ++++++++++++------- tests/pw/e2e.config.ts | 6 ++--- tests/pw/pages/basePage.ts | 9 ++----- tests/pw/pages/reportsPage.ts | 1 + tests/pw/tests/e2e/_env.setup.ts | 2 +- tests/pw/tests/e2e/admin.spec.ts | 3 --- tests/pw/tests/e2e/productAddons.spec.ts | 2 +- tests/pw/tests/e2e/refunds.spec.ts | 2 +- tests/pw/tests/e2e/vendorAuction.spec.ts | 4 +-- tests/pw/tests/e2e/vendorBooking.spec.ts | 4 +-- tests/pw/tests/e2e/vendorDeliveryTime.spec.ts | 6 ----- .../e2e/vendorProductSubscription.spec.ts | 13 ++++----- tests/pw/tests/e2e/vendorReports.spec.ts | 6 ----- tests/pw/tests/e2e/vendorSettings.spec.ts | 3 +-- .../pw/tests/e2e/vendorVerifications.spec.ts | 2 +- tests/pw/tests/e2e/wholesaleCustomers.spec.ts | 8 +++--- 16 files changed, 43 insertions(+), 55 deletions(-) diff --git a/.github/workflows/e2e_api_tests.yml b/.github/workflows/e2e_api_tests.yml index 8ac0f675b1..4ab1cf4606 100644 --- a/.github/workflows/e2e_api_tests.yml +++ b/.github/workflows/e2e_api_tests.yml @@ -13,15 +13,15 @@ on: # workflow can be manually triggered workflow_dispatch: - inputs: - testsuite: - description: Choose which test suite to run - default: All - type: choice - options: - - E2E - - API - - All + inputs: + testsuite: + description: Choose which test suite to run + default: All + type: choice + options: + - E2E + - API + - All # Cancels all previous workflow runs for pull requests that have not completed. concurrency: @@ -78,7 +78,7 @@ jobs: - name: Composer install and build (Dokan-lite) if: success() run: | - composer install --no-dev -o + composer install --no-dev -o - name: Npm install and build (Dokan-lite) if: success() @@ -222,6 +222,13 @@ jobs: reactions: hooray edit-mode: replace + # Backup Database + - name: Backup Database + if: success() + run: | + cd tests/pw + npm run wp-env run tests-cli wp db export --add-drop-table playwright/db-backup.sql + # Upload artifacts - name: Archive test artifacts (screenshots, HTML snapshots, Reports) uses: actions/upload-artifact@v4 diff --git a/tests/pw/e2e.config.ts b/tests/pw/e2e.config.ts index d4ac65b277..bade100ff6 100644 --- a/tests/pw/e2e.config.ts +++ b/tests/pw/e2e.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 ? 40 * (60 * 1000) : 40 * (60 * 1000) /* Maximum time in milliseconds the whole test suite can run */, maxFailures: process.env.CI ? 40 : 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 ? 60 * 1000 : 45 * 1000 /* Maximum time one test can run for. */, + timeout: process.env.CI ? 50 * 1000 : 45 * 1000 /* Maximum time one test can run for. */, expect: { timeout: 15 * 1000 /* Maximum time expect() should wait for the condition to be met. For example in `await expect(locator).toHaveText();`*/, toHaveScreenshot: { @@ -43,8 +43,8 @@ export default defineConfig({ use: { ...devices['Desktop Chrome'], acceptDownloads: true /* Whether to automatically download all the attachments. */, - actionTimeout: 30 * 1000 /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */, - navigationTimeout: 30 * 1000 /* Maximum time each navigation such as 'goto()' can take. */, + actionTimeout: 25 * 1000 /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */, + navigationTimeout: 25 * 1000 /* Maximum time each navigation such as 'goto()' can take. */, baseURL: process.env.BASE_URL ? process.env.BASE_URL : 'http://localhost:9999' /* Base URL */, // browserName: 'chromium' /* Name of the browser that runs tests. */, bypassCSP: true /* Toggles bypassing page's Content-Security-Policy. */, diff --git a/tests/pw/pages/basePage.ts b/tests/pw/pages/basePage.ts index bdeea406fe..20588f4584 100644 --- a/tests/pw/pages/basePage.ts +++ b/tests/pw/pages/basePage.ts @@ -264,18 +264,13 @@ 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; } // type & wait for response 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), - this.clearAndFill(selector, text), - ]); + const [response] = await Promise.all([this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code), this.clearAndFill(selector, text)]); return response; } diff --git a/tests/pw/pages/reportsPage.ts b/tests/pw/pages/reportsPage.ts index 3fc332d34c..7857688fc0 100644 --- a/tests/pw/pages/reportsPage.ts +++ b/tests/pw/pages/reportsPage.ts @@ -62,6 +62,7 @@ export class ReportsPage extends AdminPage { await this.clearInputField(selector.admin.dokan.reports.allLogs.search); await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.logs, selector.admin.dokan.reports.allLogs.search, orderId); + await this.wait(1); // todo: add dynamic wait instead of this 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/tests/e2e/_env.setup.ts b/tests/pw/tests/e2e/_env.setup.ts index 7954b207cc..67049d4879 100644 --- a/tests/pw/tests/e2e/_env.setup.ts +++ b/tests/pw/tests/e2e/_env.setup.ts @@ -49,7 +49,7 @@ setup.describe('setup site & woocommerce & user settings', () => { // delete previous shipping zones const allShippingZoneIds = (await apiUtils.getAllShippingZones()).map((a: { id: string }) => a.id); // allShippingZoneIds = helpers.removeItem(allShippingZoneIds, 0) // avoid remove default zone id - if (allShippingZoneIds.length) { + if (allShippingZoneIds?.length) { for (const shippingZoneId of allShippingZoneIds) { await apiUtils.deleteShippingZone(shippingZoneId); } diff --git a/tests/pw/tests/e2e/admin.spec.ts b/tests/pw/tests/e2e/admin.spec.ts index ee05f947b9..f9e83ab706 100644 --- a/tests/pw/tests/e2e/admin.spec.ts +++ b/tests/pw/tests/e2e/admin.spec.ts @@ -1,12 +1,10 @@ import { test, Page } from '@playwright/test'; import { LoginPage } from '@pages/loginPage'; -import { AdminPage } from '@pages/adminPage'; import { TaxPage } from '@pages/taxPage'; import { ShippingPage } from '@pages/shippingPage'; import { data } from '@utils/testData'; test.describe('Admin functionality test', () => { - let adminPage: AdminPage; let taxPage: TaxPage; let shippingPage: ShippingPage; let aPage: Page; @@ -14,7 +12,6 @@ test.describe('Admin functionality test', () => { test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); - adminPage = new AdminPage(aPage); taxPage = new TaxPage(aPage); shippingPage = new ShippingPage(aPage); }); diff --git a/tests/pw/tests/e2e/productAddons.spec.ts b/tests/pw/tests/e2e/productAddons.spec.ts index 111d3695fa..9fb30626e2 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/refunds.spec.ts b/tests/pw/tests/e2e/refunds.spec.ts index 005c6795e0..b5ce8a455a 100644 --- a/tests/pw/tests/e2e/refunds.spec.ts +++ b/tests/pw/tests/e2e/refunds.spec.ts @@ -58,7 +58,7 @@ test.describe('Refunds test', () => { await admin.updateRefundRequests(orderId, 'cancel'); }); - test('admin can perform refund requests bulk actions @pro @a', async () => { + test.skip('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.createRefundRequest(orderResponseBody); await admin.refundRequestsBulkAction('completed'); diff --git a/tests/pw/tests/e2e/vendorAuction.spec.ts b/tests/pw/tests/e2e/vendorAuction.spec.ts index 1398372dad..dfa734037c 100644 --- a/tests/pw/tests/e2e/vendorAuction.spec.ts +++ b/tests/pw/tests/e2e/vendorAuction.spec.ts @@ -26,8 +26,8 @@ test.describe('Auction Product test', () => { customer = new AuctionsPage(cPage); apiUtils = new ApiUtils(await request.newContext()); - // [, , auctionProductName] = await apiUtils.createProduct(payloads.createAuctionProduct(), payloads.vendorAuth); - // await customer.bidAuctionProduct(auctionProductName); + [, , auctionProductName] = await apiUtils.createProduct(payloads.createAuctionProduct(), payloads.vendorAuth); + await customer.bidAuctionProduct(auctionProductName); }); test.afterAll(async () => { diff --git a/tests/pw/tests/e2e/vendorBooking.spec.ts b/tests/pw/tests/e2e/vendorBooking.spec.ts index 20c261eff1..6bb3d05278 100644 --- a/tests/pw/tests/e2e/vendorBooking.spec.ts +++ b/tests/pw/tests/e2e/vendorBooking.spec.ts @@ -103,13 +103,13 @@ test.describe('Booking Product test', () => { test('vendor can edit booking resource @pro @v', async () => { const bookingResourceName = data.product.booking.resource.resourceName(); - await vendor.addBookingResource(bookingResourceName); // todo: convert with api + await vendor.addBookingResource(bookingResourceName); // todo: convert with woo api :fatal error exits on api await vendor.editBookingResource({ ...data.product.booking.resource, name: bookingResourceName }); }); test('vendor can delete booking resource @pro @v', async () => { const bookingResourceName = data.product.booking.resource.resourceName(); - await vendor.addBookingResource(bookingResourceName); // todo: convert with api + await vendor.addBookingResource(bookingResourceName); // todo: convert with woo api:fatal error exits on api await vendor.deleteBookingResource(bookingResourceName); }); diff --git a/tests/pw/tests/e2e/vendorDeliveryTime.spec.ts b/tests/pw/tests/e2e/vendorDeliveryTime.spec.ts index 6ab63d1c7a..76ae816b8d 100644 --- a/tests/pw/tests/e2e/vendorDeliveryTime.spec.ts +++ b/tests/pw/tests/e2e/vendorDeliveryTime.spec.ts @@ -2,15 +2,12 @@ import { test, Page } from '@playwright/test'; import { VendorDeliveryTimePage } from '@pages/vendorDeliveryTimePage'; import { dbData } from '@utils/dbData'; import { dbUtils } from '@utils/dbUtils'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Vendor delivery time test', () => { let vendor: VendorDeliveryTimePage; let customer: VendorDeliveryTimePage; let vPage: Page, cPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); @@ -20,14 +17,11 @@ test.describe('Vendor delivery time test', () => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new VendorDeliveryTimePage(cPage); - - // apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await vPage.close(); await cPage.close(); - // await apiUtils.dispose(); }); test('vendor delivery time menu page is rendering properly @pro @exp @v', async () => { diff --git a/tests/pw/tests/e2e/vendorProductSubscription.spec.ts b/tests/pw/tests/e2e/vendorProductSubscription.spec.ts index 0f620ff5d6..dc9e141b09 100644 --- a/tests/pw/tests/e2e/vendorProductSubscription.spec.ts +++ b/tests/pw/tests/e2e/vendorProductSubscription.spec.ts @@ -9,6 +9,7 @@ test.describe('Product subscriptions test', () => { let customer: VendorProductSubscriptionPage; let vPage: Page, cPage: Page; let apiUtils: ApiUtils; + let subscriptionId: string; test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); @@ -54,27 +55,27 @@ test.describe('Product subscriptions test', () => { // customer test.skip('customer can view product subscription details @pro @exp @c', async () => { - await customer.customerViewProductSubscription('2328'); + await customer.customerViewProductSubscription(subscriptionId); }); test.skip('customer can cancel subscription @pro @c', async () => { - await customer.cancelProductSubscription('2328'); + await customer.cancelProductSubscription(subscriptionId); }); test.skip('customer can reactivate subscription @pro @c', async () => { - await customer.reactivateProductSubscription('2328'); + await customer.reactivateProductSubscription(subscriptionId); }); test.skip('customer can change address of subscription @pro @c', async () => { - await customer.changeAddressOfProductSubscription('2328', data.customer.customerInfo.shipping); + await customer.changeAddressOfProductSubscription(subscriptionId, data.customer.customerInfo.shipping); }); test.skip('customer can change payment of subscription @pro @c', async () => { - await customer.changePaymentOfProductSubscription('2328'); + await customer.changePaymentOfProductSubscription(subscriptionId); }); test.skip('customer can renew subscription @pro @c', async () => { - await customer.renewProductSubscription('2328'); + await customer.renewProductSubscription(subscriptionId); }); test.skip('customer can buy product subscription @pro @c', async () => { diff --git a/tests/pw/tests/e2e/vendorReports.spec.ts b/tests/pw/tests/e2e/vendorReports.spec.ts index 55bb91fb3f..e73fae5080 100644 --- a/tests/pw/tests/e2e/vendorReports.spec.ts +++ b/tests/pw/tests/e2e/vendorReports.spec.ts @@ -1,25 +1,19 @@ import { test, Page } from '@playwright/test'; import { VendorReportsPage } from '@pages/vendorReportsPage'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Vendor analytics test', () => { let vendor: VendorReportsPage; let vPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new VendorReportsPage(vPage); - - // apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await vPage.close(); - // await apiUtils.dispose(); }); test('vendor reports menu page is rendering properly @pro @exp @v', async () => { diff --git a/tests/pw/tests/e2e/vendorSettings.spec.ts b/tests/pw/tests/e2e/vendorSettings.spec.ts index 4e3c58989c..7b9a598be1 100644 --- a/tests/pw/tests/e2e/vendorSettings.spec.ts +++ b/tests/pw/tests/e2e/vendorSettings.spec.ts @@ -3,7 +3,6 @@ import { VendorSettingsPage } from '@pages/vendorSettingsPage'; import { dbData } from '@utils/dbData'; import { ApiUtils } from '@utils/apiUtils'; import { dbUtils } from '@utils/dbUtils'; -// import { helpers } from '@utils/helpers'; import { data } from '@utils/testData'; import { payloads } from '@utils/payloads'; @@ -21,8 +20,8 @@ test.describe('Vendor settings test', () => { }); test.afterAll(async () => { - await vPage.close(); await apiUtils.setStoreSettings(payloads.defaultStoreSettings, payloads.vendorAuth); + await vPage.close(); await apiUtils.dispose(); }); diff --git a/tests/pw/tests/e2e/vendorVerifications.spec.ts b/tests/pw/tests/e2e/vendorVerifications.spec.ts index 4a6eed883c..cf06f66c2c 100644 --- a/tests/pw/tests/e2e/vendorVerifications.spec.ts +++ b/tests/pw/tests/e2e/vendorVerifications.spec.ts @@ -28,7 +28,7 @@ test.describe('Verifications test', () => { await vendor.vendorVerificationsSettingsRenderProperly(); }); - test('vendor can send id verification request @pro @v', async () => { + test.skip('vendor can send id verification request @pro @v', async () => { await vendor.sendIdVerificationRequest(data.vendor.verification); }); diff --git a/tests/pw/tests/e2e/wholesaleCustomers.spec.ts b/tests/pw/tests/e2e/wholesaleCustomers.spec.ts index 621c29a172..a67e81baba 100644 --- a/tests/pw/tests/e2e/wholesaleCustomers.spec.ts +++ b/tests/pw/tests/e2e/wholesaleCustomers.spec.ts @@ -69,12 +69,12 @@ test.describe('Wholesale customers test (admin)', () => { await admin.wholesaleCustomerBulkAction('activate'); }); - test('customer can become a wholesale customer @c', async () => { + test('customer can become a wholesale customer @pro @c', async () => { await customerPage.customerRegister(data.customer.customerInfo); await customer.customerBecomeWholesaleCustomer(); }); - test('customer can request for become a wholesale customer @c', async () => { + test('customer can request for become a wholesale customer @pro @c', async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.wholesale, { ...dbData.dokan.wholesaleSettings, need_approval_for_wholesale_customer: 'on' }); await customerPage.customerRegister(data.customer.customerInfo); await customer.customerRequestForBecomeWholesaleCustomer(); @@ -109,11 +109,11 @@ test.describe.skip('Wholesale customers test customer', () => { await cPage.close(); }); - test('customer can see wholesale price on shop archive @c', async () => { + test('customer can see wholesale price on shop archive @pro @c', async () => { await customer.viewWholeSalePrice(productName); }); - test('customer can buy wholesale product @c', async () => { + test('customer can buy wholesale product @pro @c', async () => { await customerPage.addProductToCart(productName, 'single-product', true, minimumWholesaleQuantity); await customer.assertWholesalePrice(wholesalePrice, minimumWholesaleQuantity); await customerPage.paymentOrder();