Skip to content

Commit

Permalink
Merge branch 'testlite' into e2e-pw
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Feb 16, 2024
2 parents 3352655 + 144b723 commit 7918b43
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 55 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/e2e_api_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/pw/e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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. */,
Expand Down
9 changes: 2 additions & 7 deletions tests/pw/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,13 @@ export class BasePage {

// type & wait for response
async typeViaPageAndWaitForResponse(subUrl: string, selector: string, text: string, code = 200): Promise<Response> {
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<Response> {
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;
}

Expand Down
1 change: 1 addition & 0 deletions tests/pw/pages/reportsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/tests/e2e/_env.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 0 additions & 3 deletions tests/pw/tests/e2e/admin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
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;

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);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/tests/e2e/productAddons.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/tests/e2e/refunds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions tests/pw/tests/e2e/vendorAuction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/pw/tests/e2e/vendorBooking.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
6 changes: 0 additions & 6 deletions tests/pw/tests/e2e/vendorDeliveryTime.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 () => {
Expand Down
13 changes: 7 additions & 6 deletions tests/pw/tests/e2e/vendorProductSubscription.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 () => {
Expand Down
6 changes: 0 additions & 6 deletions tests/pw/tests/e2e/vendorReports.spec.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
3 changes: 1 addition & 2 deletions tests/pw/tests/e2e/vendorSettings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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();
});

Expand Down
2 changes: 1 addition & 1 deletion tests/pw/tests/e2e/vendorVerifications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
8 changes: 4 additions & 4 deletions tests/pw/tests/e2e/wholesaleCustomers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7918b43

Please sign in to comment.