Skip to content

Commit

Permalink
added test tags and refactor suit for parallism
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Feb 13, 2024
1 parent 0420dd8 commit fc2301f
Show file tree
Hide file tree
Showing 66 changed files with 707 additions and 681 deletions.
2 changes: 1 addition & 1 deletion tests/pw/e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineConfig({
// forbidOnly : !!process.env.CI, /* Fail the build on CI if you accidentally left test-only 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. */,
workers: process.env.CI ? 4 : 1 /* Opt out of parallel tests on CI. */,
workers: process.env.CI ? 4 : 4 /* Opt out of parallel tests on CI. */,
reportSlowTests: { max: 2, threshold: 25 } /* Whether to report slow test files. Pass null to disable this feature. */,
reporter: process.env.CI
? [
Expand Down
22 changes: 11 additions & 11 deletions tests/pw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
"pw:deps-only": "playwright install-deps chromium",
"test": "npx playwright test",
"test:site_setup": "npx playwright test --project=site_setup",
"test:api": "npx playwright test --project=api_tests --config=api.config.ts ",
"test:e2e": "npx playwright test --project=e2e_tests --config=e2e.config.ts ",
"test:api": "npx playwright test --project=api_tests --config=api.config.ts",
"test:e2e": "npx playwright test --project=e2e_tests --config=e2e.config.ts",
"test:e2e-i": "npx playwright test --project=e2e_tests --headed",
"test:e2e:lite": "npx playwright test --project=e2e_tests --grep '@lite|@liteOnly' --grep-invert '@pro' --config=e2e.config.ts ",
"test:api:lite": "npx playwright test --project=api_tests --grep '@lite|@liteOnly' --grep-invert @pro --config=api.config.ts ",
"test:e2e:lite:explo": "npx playwright test --project=e2e_tests --grep '(?=.*@lite)(?=.*@explo)' --config=e2e.config.ts ",
"test:api:pro": "npx playwright test --project=api_tests --grep '@lite|@pro' --grep-invert @liteOnly --config=api.config.ts ",
"test:e2e:pro": "npx playwright test --project=e2e_tests --grep '@lite' --grep-invert @liteOnly --config=e2e.config.ts ",
"test:e2e:pro_": "npx playwright test --project=e2e_tests --grep '@lite|@pro' --grep-invert @liteOnly --config=e2e.config.ts ",
"test:e2e:visual": "npx playwright test --project=e2e_tests --grep @visual --config=e2e.config.ts ",
"test:e2e:explo": "npx playwright test --project=e2e_tests --grep @explo --config=e2e.config.ts ",
"test:e2e:core": "npx playwright test --project=e2e_tests --grep @core --config=e2e.config.ts ",
"test:e2e:lite": "npx playwright test --project=e2e_tests --grep '@lite|@liteOnly' --grep-invert '@pro' --config=e2e.config.ts",
"test:api:lite": "npx playwright test --project=api_tests --grep '@lite|@liteOnly' --grep-invert @pro --config=api.config.ts",
"test:e2e:lite:explo": "npx playwright test --project=e2e_tests --grep '(?=.*@lite)(?=.*@exp)' --config=e2e.config.ts",
"test:api:pro": "npx playwright test --project=api_tests --grep '@lite|@pro' --grep-invert @liteOnly --config=api.config.ts",
"test:e2e:pro": "npx playwright test --project=e2e_tests --grep '@lite' --grep-invert @liteOnly --config=e2e.config.ts",
"test:e2e:pro_": "npx playwright test --project=e2e_tests --grep '@lite|@pro' --grep-invert @liteOnly --config=e2e.config.ts",
"test:e2e:visual": "npx playwright test --project=e2e_tests --grep @visual --config=e2e.config.ts",
"test:e2e:explo": "npx playwright test --project=e2e_tests --grep @exp --config=e2e.config.ts",
"test:e2e:core": "npx playwright test --project=e2e_tests --grep @core --config=e2e.config.ts",
"test:grep": "npx playwright test --grep",
"test:debug": "npx playwright test --debug",
"test:codegen": "playwright codegen",
Expand Down
5 changes: 1 addition & 4 deletions tests/pw/pages/shopPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ export class ShopPage extends CustomerPage {
}

// products on map
async productOnMap(productName?: string) {
async productOnMap() {
await this.goIfNotThere(data.subUrls.frontend.shop);
// await this.click(selector.customer.cShop.map.productOnMap.productOnMap);
// await this.toBeVisibleAnyOfThem([selector.customer.cShop.map.productOnMap.productPopup, selector.customer.cShop.map.productOnMap.productListPopup]); // implement this instead of if-else soln
const storePinIsVisible = await this.isVisible(selector.customer.cShop.map.productOnMap.productPin);
if (storePinIsVisible) {
await this.click(selector.customer.cShop.map.productOnMap.productPin);
Expand All @@ -93,7 +91,6 @@ export class ShopPage extends CustomerPage {
await this.toBeVisible(selector.customer.cShop.map.productOnMap.productListPopup);
await this.click(selector.customer.cShop.map.productOnMap.closePopup);
}
productName && (await this.toBeVisible(selector.customer.cShop.map.productOnMap.productOnList(productName)));
}

// go to product details
Expand Down
3 changes: 1 addition & 2 deletions tests/pw/tests/api/_env.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ setup.describe('setup test environment', () => {
await dbUtils.setDokanSettings(dbData.dokan.optionName.reverseWithdraw, dbData.dokan.reverseWithdrawSettings);
});

setup.skip('get test environment info @lite', async () => {
//todo: might not needed anymore
setup('get test environment info @lite', async () => {
const [, systemInfo] = await apiUtils.getSystemStatus(payloads.adminAuth);
helpers.writeFile(data.systemInfo, JSON.stringify(systemInfo));
});
Expand Down
4 changes: 1 addition & 3 deletions tests/pw/tests/api/modules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ test.describe('modules api test', () => {
});

test.afterAll(async () => {
await apiUtils.activateModules([randomModule]);
await apiUtils.dispose();
});

Expand All @@ -33,9 +34,6 @@ test.describe('modules api test', () => {
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
expect(responseBody).toMatchSchema(schemas.modulesSchema);

// reactivate module
// await apiUtils.activateModules(randomModule)
});

test('activate a module @pro', async () => {
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 @@ -325,7 +325,7 @@ setup.describe('setup dokan settings e2e', () => {
expect(product).toBeTruthy();
});

setup.skip('save store settings to update store on map @lite', async () => {
setup('save store settings to update store on map @lite', async () => {
await vendorPage.updateStoreMapViaSettingsSave();
});
});
25 changes: 15 additions & 10 deletions tests/pw/tests/e2e/abuseReports.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,51 @@ test.describe('Abuse report test', () => {
test.afterAll(async () => {
await aPage.close();
await cPage.close();
await gPage.close();
// await gPage.close();
await apiUtils.dispose();
});

test('dokan abuse report menu page is rendering properly @pro @explo', async () => {
test('dokan abuse report menu page is rendering properly @pro @exp @a', async () => {
await admin.adminAbuseReportRenderProperly();
});

test('admin can view abuse report details @pro @explo', async () => {
test('admin can view abuse report details @pro @exp @a', async () => {
await admin.abuseReportDetails();
});

test('admin can filter abuse reports by abuse reason @pro', async () => {
test('admin can filter abuse reports by abuse reason @pro @a', async () => {
await admin.filterAbuseReports('This content is spam', 'by-reason');
});

test('admin can filter abuse reports by product @pro', async () => {
test('admin can filter abuse reports by product @pro @a', async () => {
await admin.filterAbuseReports(data.predefined.simpleProduct.product1.name, 'by-product');
});

test('admin can filter abuse reports by vendor @pro', async () => {
test('admin can filter abuse reports by vendor @pro @a', async () => {
await admin.filterAbuseReports(data.predefined.vendorStores.vendor1, 'by-vendor');
});

test('admin can perform abuse report bulk action @pro', async () => {
test.skip('admin can perform abuse report bulk action @pro @a', async () => {
// todo: might cause other tests to fail in parallel
await admin.abuseReportBulkAction('delete');
});

// customer

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

test('guest customer can report product @pro', async () => {
test('guest customer can report product @pro @g', async ({ page }) => {
guest = new AbuseReportsPage(page); //todo: apply guest user like this where every test need seperate guest user
await guest.reportProduct(data.predefined.simpleProduct.product1.name, data.product.report);
});

test('only logged-in customer can report product @pro', async () => {
test.skip('guest customer need to log-in to report product @pro @g', async ({ page }) => {
// todo: might cause other tests to fail in parallel
guest = new AbuseReportsPage(page);
await dbUtils.setDokanSettings(dbData.dokan.optionName.productReportAbuse, { ...dbData.dokan.productReportAbuseSettings, reported_by_logged_in_users_only: 'on' });
await guest.reportProduct(data.predefined.simpleProduct.product1.name, data.product.report);
await dbUtils.setDokanSettings(dbData.dokan.optionName.productReportAbuse, dbData.dokan.productReportAbuseSettings);
});
});
8 changes: 4 additions & 4 deletions tests/pw/tests/e2e/admin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ test.describe('Admin user functionality test', () => {
await page.close();
});

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

test('admin can logout @lite', async () => {
test('admin can logout @lite @a', async () => {
await loginPage.adminLogin(data.admin);
await loginPage.logoutBackend();
});
Expand Down Expand Up @@ -85,11 +85,11 @@ test.describe('Admin functionality test', () => {
// await adminPage.addShippingMethod(data.shipping.shippingMethods.vendorShipping)
// })

test('dokan notice @lite', async () => {
test('dokan notice @lite @a', async () => {
await adminPage.dokanNotice();
});

test('dokan promotion @lite', async () => {
test('dokan promotion @lite @a', async () => {
await adminPage.dokanPromotion();
});
});
6 changes: 3 additions & 3 deletions tests/pw/tests/e2e/adminDashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ test.describe('Admin dashboard test', () => {
await apiUtils.dispose();
});

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

test('admin dashboard at a glance values are accurate @lite', async () => {
test('admin dashboard at a glance values are accurate @lite @a', async () => {
const summary = await apiUtils.getAdminReportSummary(payloads.adminAuth);
await admin.dokanAtAGlanceValueAccuracy(summary);
});

test('admin can add dokan news subscriber @lite', async () => {
test('admin can add dokan news subscriber @lite @a', async () => {
await admin.addDokanNewsSubscriber(data.user.userDetails);
});
});
30 changes: 17 additions & 13 deletions tests/pw/tests/e2e/announcements.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ApiUtils } from '@utils/apiUtils';
import { data } from '@utils/testData';
import { payloads } from '@utils/payloads';

test.describe('Announcements test', () => {
test.describe('Announcements test (admin)', () => {
let admin: AnnouncementsPage;
let aPage: Page;
let apiUtils: ApiUtils;
Expand All @@ -24,45 +24,49 @@ test.describe('Announcements test', () => {
await apiUtils.dispose();
});

test('dokan announcements menu page is rendering properly @pro @explo', async () => {
//admin

test('dokan announcements menu page is rendering properly @pro @exp @a', async () => {
await admin.adminAnnouncementsRenderProperly();
});

test('admin can send announcement @pro', async () => {
test('admin can send announcement @pro @a', async () => {
await admin.addAnnouncement({ ...data.announcement, title: data.announcement.randomTitle() });
});

test('admin can schedule announcement @pro', async () => {
test('admin can schedule announcement @pro @a', async () => {
await admin.addAnnouncement({ ...data.announcement, title: data.announcement.randomTitle(), publishType: 'schedule' });
});

test('admin can edit announcement @pro', async () => {
test('admin can edit announcement @pro @a', async () => {
await admin.editAnnouncement({ ...data.announcement, title: announcementTitle });
});

test('admin can trash announcement @pro', async () => {
test('admin can trash announcement @pro @a', async () => {
const [, , announcementTitle] = await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth);
await admin.updateAnnouncement(announcementTitle, 'trash');
});

test('admin can restore announcement @pro', async () => {
test('admin can restore announcement @pro @a', async () => {
const [, announcementId, announcementTitle] = await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth);
await apiUtils.deleteAnnouncement(announcementId, payloads.adminAuth);
await admin.updateAnnouncement(announcementTitle, 'restore');
});

test('admin can permanently delete announcement @pro', async () => {
test('admin can permanently delete announcement @pro @a', async () => {
const [, announcementId, announcementTitle] = await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth);
await apiUtils.deleteAnnouncement(announcementId, payloads.adminAuth);
await admin.updateAnnouncement(announcementTitle, 'permanently-delete');
});

test('admin can perform announcements bulk action @pro', async () => {
test.skip('admin can perform announcements bulk action @pro @a', async () => {
// todo: might cause other tests to fail in parallel
// await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth);
await admin.announcementBulkAction('trash');
});
});

test.describe('Announcements test vendor', () => {
test.describe('Announcements test (vendor)', () => {
let vendor: AnnouncementsPage;
let vPage: Page;
let apiUtils: ApiUtils;
Expand All @@ -84,15 +88,15 @@ test.describe('Announcements test vendor', () => {

// vendor

test('vendor announcement menu page is rendering properly @pro @explo', async () => {
test('vendor announcement menu page is rendering properly @pro @exp @v', async () => {
await vendor.vendorAnnouncementsRenderProperly();
});

test('vendor can view announcement details @pro', async () => {
test('vendor can view announcement details @pro @v', async () => {
await vendor.vendorViewAnnouncement(announcement);
});

test('vendor can delete announcement @pro', async () => {
test('vendor can delete announcement @pro @v', async () => {
await vendor.vendorDeleteAnnouncement(announcement.title);
});
});
22 changes: 13 additions & 9 deletions tests/pw/tests/e2e/coupons.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,40 +40,44 @@ test.describe('Coupons test', () => {
await apiUtils.dispose();
});

test('admin can add marketplace coupon @pro', async () => {
test('admin can add marketplace coupon @pro @a', async () => {
await admin.addMarketplaceCoupon({ ...data.coupon, title: data.coupon.couponTitle() });
});

test('vendor coupon menu page is rendering properly @pro @explo', async () => {
//vendor

test('vendor coupon menu page is rendering properly @pro @exp @v', async () => {
await vendor.vendorCouponsRenderProperly();
});

test('vendor can view marketPlace coupon @pro @explo', async () => {
test('vendor can view marketPlace coupon @pro @exp @v', async () => {
await vendor.viewMarketPlaceCoupon(marketplaceCouponCode);
});

test('vendor can add coupon @pro', async () => {
test('vendor can add coupon @pro @v', async () => {
await vendor.addCoupon({ ...data.coupon, title: data.coupon.couponTitle() });
});

test('vendor can edit coupon @pro', async () => {
test('vendor can edit coupon @pro @v', async () => {
await vendor.editCoupon({ ...data.coupon, title: couponCode });
});

test('vendor can delete coupon @pro', async () => {
test('vendor can delete coupon @pro @v', async () => {
const [, , couponCode] = await apiUtils.createCoupon([PRODUCT_ID], payloads.createCoupon(), payloads.vendorAuth);
await vendor.deleteCoupon(couponCode);
});

test('customer can view coupon on single store @pro', async () => {
//customer

test('customer can view coupon on single store @pro @c', async () => {
await customer.viewStoreCoupon(data.predefined.vendorStores.vendor1, couponCode);
});

test('customer can apply coupon @pro', async () => {
test('customer can apply coupon @pro @c', async () => {
await customer.applyCoupon(data.predefined.simpleProduct.product1.name, data.predefined.coupon.couponCode);
});

test('customer can buy product with coupon @pro', async () => {
test('customer can buy product with coupon @pro @c', async () => {
await customer.buyProductWithCoupon(data.predefined.simpleProduct.product1.name, data.predefined.coupon.couponCode);
});
});
Loading

0 comments on commit fc2301f

Please sign in to comment.