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 25e512b commit 49cde25
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 183 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,39 @@ import { AdminPage } from '@pages/adminPage';
import { selector } from '@pages/selectors';
import { data } from '@utils/testData';

export class ProPromoPage extends AdminPage {
export class NoticeAndPromotionPage extends AdminPage {
constructor(page: Page) {
super(page);
}

// dokan pro promo
async dokanProPromo() {
// dokan notice & promotion

// dokan notice
async dokanNoticeRenderProperly() {
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);
}

// dokan promotion
async dokanPromotionRenderProperly() {
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 pro promotion
async dokanProPromotionRenderProperly() {
// dokan promo banner
await this.goIfNotThere(data.subUrls.backend.dokan.dokan);

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);
});
});
30 changes: 30 additions & 0 deletions tests/pw/tests/e2e/noticeAndPromotion.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { test, Page } from '@playwright/test';
import { NoticeAndPromotionPage } from '@pages/noticeAndPromotionPage';
import { data } from '@utils/testData';

test.describe('Dokan pro feature promo test', () => {
let admin: NoticeAndPromotionPage;
let aPage: Page;

test.beforeAll(async ({ browser }) => {
const adminContext = await browser.newContext(data.auth.adminAuth);
aPage = await adminContext.newPage();
admin = new NoticeAndPromotionPage(aPage);
});

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

test('dokan notice is rendering properly @lite @exp @a', async () => {
await admin.dokanNoticeRenderProperly();
});

test('dokan promotion is rendering properly @lite @exp @a', async () => {
await admin.dokanPromotionRenderProperly();
});

test('dokan pro features promotions are rendering properly @liteOnly @exp @a', async () => {
await admin.dokanProPromotionRenderProperly();
});
});
30 changes: 0 additions & 30 deletions tests/pw/tests/e2e/proPromo.spec.ts

This file was deleted.

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

0 comments on commit 49cde25

Please sign in to comment.