Skip to content

Commit

Permalink
refactored suite for parallism
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Feb 14, 2024
1 parent 17479e8 commit d7f86dc
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 152 deletions.
2 changes: 1 addition & 1 deletion tests/pw/api.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig({
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 */,
preserveOutput: 'always' /* Whether to preserve test output in the testConfig.outputDir. Defaults to 'always'. */,
fullyParallel : true, /* Run tests in files in parallel */
// fullyParallel : true, /* Run tests in files in parallel */
// forbidOnly : !!process.env.CI, /* Fail the build on CI if you accidentally left testonly in the source code. */
repeatEach: 1 /* The number of times to repeat each test, useful for debugging flaky tests. */,
retries: process.env.CI ? 1 : 0 /* The maximum number of retry attempts given to failed tests. */,
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
globalSetup: './global-setup' /* Path to the global setup file. This file will be required and run before all the tests. */,
// 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 ? 60 : 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. */,
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 : 35 * 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();`*/,
Expand Down
26 changes: 0 additions & 26 deletions tests/pw/pages/adminPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,30 +143,4 @@ export class AdminPage extends BasePage {
await this.click(selector.admin.dokan.dokanSetupWizard.visitDokanDashboard);
await this.toBeVisible(selector.admin.dokan.dashboard.dashboardText);
}

// dokan notice & promotion

// dokan notice
async dokanPromotion() {
await this.goto(data.subUrls.backend.dokan.dokan);
// dokan promotion elements are visible
const isPromotionVisible = await this.isVisible(selector.admin.dokan.promotion.promotion);
if (isPromotionVisible) {
await this.multipleElementVisible(selector.admin.dokan.promotion);
} else {
console.log('No promotion is ongoing');
}
}

// dokan notice
async dokanNotice() {
await this.goto(data.subUrls.backend.dokan.dokan);

// dokan notice elements are visible
const isPromotionVisible = await this.isVisible(selector.admin.dokan.promotion.promotion);
isPromotionVisible ? await this.notToHaveCount(selector.admin.dokan.notice.noticeDiv1, 0) : await this.notToHaveCount(selector.admin.dokan.notice.noticeDiv, 0);
await this.notToHaveCount(selector.admin.dokan.notice.slider, 0);
await this.notToHaveCount(selector.admin.dokan.notice.sliderPrev, 0);
await this.notToHaveCount(selector.admin.dokan.notice.sliderNext, 0);
}
}
1 change: 1 addition & 0 deletions tests/pw/pages/loginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class LoginPage extends BasePage {

// admin logout
async logoutBackend(): Promise<void> {
await this.goIfNotThere(data.subUrls.backend.adminLogin);
await this.hover(selector.backend.userMenu);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.backend.adminLogout, selector.backend.logout, 302);
const loggedInUser = await this.getCurrentUser();
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/pages/shippingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { data } from '@utils/testData';
import { helpers } from '@utils/helpers';
// import { shipping } from '@utils/interfaces';

export class shippingPage extends AdminPage {
export class ShippingPage extends AdminPage {
constructor(page: Page) {
super(page);
}
Expand Down
95 changes: 35 additions & 60 deletions tests/pw/tests/e2e/admin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,95 +1,70 @@
import { test, Page } from '@playwright/test';
import { LoginPage } from '@pages/loginPage';
import { AdminPage } from '@pages/adminPage';
// import { ApiUtils } from '@utils/apiUtils';
import { TaxPage } from '@pages/taxPage';
import { ShippingPage } from '@pages/shippingPage';
import { data } from '@utils/testData';
// import { payloads } from '@utils/payloads';

test.describe('Admin user functionality test', () => {
test.use(data.auth.noAuth);

let loginPage: LoginPage;
let page: Page;

test.beforeAll(async ({ browser }) => {
const context = await browser.newContext();
page = await context.newPage();
loginPage = new LoginPage(page);
});

test.afterAll(async () => {
await page.close();
});

test('admin can login @lite @a', async () => {
await loginPage.adminLogin(data.admin);
});

test('admin can logout @lite @a', async () => {
await loginPage.adminLogin(data.admin);
await loginPage.logoutBackend();
});
});

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);
});

test.afterAll(async () => {
await aPage.close();
});

// test('admin can add categories @lite', async ( ) => {
// await adminPage.addCategory(data.product.category.randomCategory());
// });
test('admin can login @lite @a', async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.adminLogin(data.admin);
});

// test('admin can add attributes @lite', async ( ) => {
// await adminPage.addAttributes(data.product.attribute.randomAttribute());
// });
test('admin can logout @lite @a', async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.adminLogin(data.admin);
await loginPage.logoutBackend();
});

// settings

// tax settings
// test('admin can set standard tax rate', async ( ) => {
// await adminPage.addStandardTaxRate(data.tax)
// })

// shipping settings
// test('admin can set flat rate shipping', async ( ) => {
// await adminPage.addShippingMethod(data.shipping.shippingMethods.flatRate);
// });
test('admin can set standard tax rate @lite @a', async () => {
await taxPage.addStandardTaxRate(data.tax);
});

// test('admin can set free shipping', async ( ) => {
// await adminPage.addShippingMethod(data.shipping.shippingMethods.freeShipping)
// })
// shipping settings

// test('admin can set local pickup shipping', async ( ) => {
// await adminPage.addShippingMethod(data.shipping.shippingMethods.localPickup)
// })
test.skip('admin can set flat rate shipping @lite @a', async () => {
await shippingPage.addShippingMethod(data.shipping.shippingMethods.flatRate);
});

// test('admin can set table rate shipping', async ( ) => {
// await adminPage.addShippingMethod(data.shipping.shippingMethods.tableRateShipping)
// })
test.skip('admin can set free shipping @lite @a', async () => {
await shippingPage.addShippingMethod(data.shipping.shippingMethods.freeShipping);
});

// test('admin can set distance rate shipping', async ( ) => {
// await adminPage.addShippingMethod(data.shipping.shippingMethods.distanceRateShipping)
// })
test.skip('admin can set local pickup shipping @lite @a', async () => {
await shippingPage.addShippingMethod(data.shipping.shippingMethods.localPickup);
});

// test('admin can set vendor shipping', async ( ) => {
// await adminPage.addShippingMethod(data.shipping.shippingMethods.vendorShipping)
// })
test.skip('admin can set table rate shipping @pro @a', async () => {
await shippingPage.addShippingMethod(data.shipping.shippingMethods.tableRateShipping);
});

test('dokan notice @lite @a', async () => {
await adminPage.dokanNotice();
test.skip('admin can set distance rate shipping @pro @a', async () => {
await shippingPage.addShippingMethod(data.shipping.shippingMethods.distanceRateShipping);
});

test('dokan promotion @lite @a', async () => {
await adminPage.dokanPromotion();
test.skip('admin can set vendor shipping @pro @a', async () => {
await shippingPage.addShippingMethod(data.shipping.shippingMethods.vendorShipping);
});
});
3 changes: 1 addition & 2 deletions tests/pw/tests/e2e/productAddons.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const { VENDOR_ID } = process.env;
test.describe('Product addon functionality test', () => {
let vendor: ProductAddonsPage;
let vPage: Page;
let addonId: string;
let addonName: string;
let addonFieldTitle: string;
let apiUtils: ApiUtils;
Expand All @@ -28,7 +27,7 @@ test.describe('Product addon functionality test', () => {
vendor = new ProductAddonsPage(vPage);

apiUtils = new ApiUtils(await request.newContext());
[addonId, addonName, addonFieldTitle] = await createVendorProductAddon();
[, addonName, addonFieldTitle] = await createVendorProductAddon();
});

test.afterAll(async () => {
Expand Down
36 changes: 22 additions & 14 deletions tests/pw/tests/e2e/productAdvertising.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test.describe('Product Advertising test', () => {
let aPage: Page, vPage: Page;
let apiUtils: ApiUtils;
let productName: string;
let advertisedProduct: string;

test.beforeAll(async ({ browser }) => {
const adminContext = await browser.newContext(data.auth.adminAuth);
Expand All @@ -23,7 +24,7 @@ test.describe('Product Advertising test', () => {

apiUtils = new ApiUtils(await request.newContext());
[, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth);
await apiUtils.createProductAdvertisement(payloads.createProduct(), payloads.vendorAuth);
[, , advertisedProduct] = await apiUtils.createProductAdvertisement(payloads.createProduct(), payloads.vendorAuth);
});

test.afterAll(async () => {
Expand All @@ -32,6 +33,8 @@ test.describe('Product Advertising test', () => {
await apiUtils.dispose();
});

//admin

test('dokan product advertising menu page is rendering properly @pro @exp', async () => {
await admin.adminProductAdvertisingRenderProperly();
});
Expand All @@ -41,7 +44,7 @@ test.describe('Product Advertising test', () => {
});

test('admin can search advertised product @pro @a', async () => {
await admin.searchAdvertisedProduct(productName);
await admin.searchAdvertisedProduct(advertisedProduct);
});

test('admin can filter advertised product by stores @pro @a', async () => {
Expand All @@ -57,28 +60,33 @@ test.describe('Product Advertising test', () => {
});

test('admin can delete advertised product @pro @a', async () => {
await admin.updateAdvertisedProduct(productName, 'delete');
const [, , advertisedProduct] = await apiUtils.createProductAdvertisement(payloads.createProduct(), payloads.vendorAuth);
await admin.updateAdvertisedProduct(advertisedProduct, 'delete');
});

test('admin can perform product advertising bulk action @pro @a', async () => {
// await apiUtils.createProductAdvertisement(payloads.createProduct(), payloads.vendorAuth);
test.skip('admin can perform product advertising bulk action @pro @a', async () => {
// todo: might cause other tests to fail in parallel
await admin.productAdvertisingBulkAction('delete');
});

// vendor

test('vendor can buy product advertising @pro @v', async () => {
//todo: p1_v1 status gets pending review; need to resolve
[, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth);
const [, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth);
const orderId = await vendor.buyProductAdvertising(productName);
await apiUtils.updateOrderStatus(orderId, 'wc-completed', payloads.adminAuth);
});

// test('vendor can buy booking product advertising @pro @v', async ( ) => { // todo:
// const orderId = await vendor.buyProductAdvertising(data.productAdvertisement.advertisedProduct);
// await apiUtils.updateOrderStatus(orderId, 'wc-completed', payloads.adminAuth);
// });
test.skip('vendor can buy booking product advertising @pro @v', async () => {
// todo: create booking product via api
const orderId = await vendor.buyProductAdvertising(data.productAdvertisement.advertisedProduct);
await apiUtils.updateOrderStatus(orderId, 'wc-completed', payloads.adminAuth);
});

// test('vendor can buy auction product advertising @pro @v', async ( ) => { // todo:
// const orderId = await vendor.buyProductAdvertising(data.productAdvertisement.advertisedProduct);
// await apiUtils.updateOrderStatus(orderId, 'wc-completed', payloads.adminAuth);
// });
test.skip('vendor can buy auction product advertising @pro @v', async () => {
// todo: create auction product via api
const orderId = await vendor.buyProductAdvertising(data.productAdvertisement.advertisedProduct);
await apiUtils.updateOrderStatus(orderId, 'wc-completed', payloads.adminAuth);
});
});
18 changes: 7 additions & 11 deletions tests/pw/tests/e2e/productEnquiry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,37 @@ import { ApiUtils } from '@utils/apiUtils';
import { dbUtils } from '@utils/dbUtils';
import { data } from '@utils/testData';
import { dbData } from '@utils/dbData';
import { payloads } from '@utils/payloads';
// import { payloads } from '@utils/payloads';

const { VENDOR_ID, CUSTOMER_ID } = process.env;
const { VENDOR_ID, CUSTOMER_ID, PRODUCT_ID } = process.env;

test.describe('Product Enquiry test', () => {
let customer: ProductEnquiryPage;
let guest: ProductEnquiryPage;
let cPage: Page, gPage: Page;
let cPage: Page;
let apiUtils: ApiUtils;

test.beforeAll(async ({ browser }) => {
const customerContext = await browser.newContext(data.auth.customerAuth);
cPage = await customerContext.newPage();
customer = new ProductEnquiryPage(cPage);

const guestContext = await browser.newContext(data.auth.noAuth);
gPage = await guestContext.newPage();
guest = new ProductEnquiryPage(gPage);

apiUtils = new ApiUtils(await request.newContext());
const productId = await apiUtils.getProductId(data.predefined.simpleProduct.product1.name, payloads.vendorAuth);
await dbUtils.createAbuseReport(dbData.dokan.createAbuseReport, productId, VENDOR_ID, CUSTOMER_ID);
// const productId = await apiUtils.getProductId(data.predefined.simpleProduct.product1.name, payloads.vendorAuth); //todo: might not needed
await dbUtils.createAbuseReport(dbData.dokan.createAbuseReport, PRODUCT_ID, VENDOR_ID, CUSTOMER_ID);
});

test.afterAll(async () => {
await cPage.close();
await gPage.close();
await apiUtils.dispose();
});

test('customer can enquire product @pro @c', async () => {
await customer.enquireProduct(data.predefined.simpleProduct.product1.name, data.product.enquiry);
});

test('guest customer can enquire product @pro @g', async () => {
test('guest customer can enquire product @pro @g', async ({ page }) => {
guest = new ProductEnquiryPage(page);
await guest.enquireProduct(data.predefined.simpleProduct.product1.name, data.product.enquiry);
});
});
Loading

0 comments on commit d7f86dc

Please sign in to comment.