Skip to content

Commit

Permalink
Fix type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Aug 17, 2024
1 parent 1f193a0 commit 41acceb
Show file tree
Hide file tree
Showing 24 changed files with 89 additions and 63 deletions.
2 changes: 1 addition & 1 deletion tests/pw/e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default defineConfig({
/* Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference' */
// colorScheme: 'dark' ,
/* Whether to run tests on headless or non-headless mode */
headless: NON_HEADLESS ? false : true,
headless: !NON_HEADLESS,
/* Whether to ignore HTTPS errors during navigation. */
ignoreHTTPSErrors: true,
/* Record trace only when retrying a test for the first time. */
Expand Down
8 changes: 7 additions & 1 deletion tests/pw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"test:e2e:pro": "DOKAN_PRO=true npx playwright test --project=e2e_tests --config=e2e.config.ts ",
"test:e2e:coverage": "npx playwright test --project=coverage_report --config=e2e.config.ts --reporter=null",
"test:e2e:headed": "npx playwright test --project=e2e_tests --config=e2e.config.ts --headed",
"test:e2e:ui": "npx playwright test --project=e2e_tests --config=e2e.config.ts --ui",
"test:e2e:debug": "npx playwright test --project=e2e_tests --config=e2e.config.ts --debug",
"test:codegen": "playwright codegen",
"test:report": "npx playwright show-report",
Expand All @@ -31,13 +32,18 @@
"reset:env": "wp-env destroy && wp-env start",
"wp-env": "wp-env",
"docker:testDbPort": "docker ps -f ancestor='mariadb' -f name='tests-mysql' --format='{{.Ports}}'",
"type": "npx tsc --noEmit",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prettier": "prettier . --check",
"prettier:fix": "prettier . --write"
},
"keywords": [],
"author": "",
"author": {
"name": "Rajkumar shashwata halder",
"email": "shashwatahalder01@gmail.com",
"url": "https://github.com/shashwatahalder01"
},
"license": "ISC",
"devDependencies": {
"@types/js-yaml": "^4.0.9",
Expand Down
3 changes: 3 additions & 0 deletions tests/pw/pages/customerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class CustomerPage extends BasePage {
await this.clearAndType(customerAccountDetails.email, customer.username + customer.customerInfo.emailDomain);
// await this.updatePassword(customer.customerInfo.password, customer.customerInfo.password1);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.editAccountCustomer, customerAccountDetails.saveChanges, 302);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.customer.account.updateSuccessMessage);

// cleanup: reset password
Expand All @@ -146,6 +147,7 @@ export class CustomerPage extends BasePage {
await this.clearAndType(customerAccountDetails.confirmNewPassword, newPassword);
if (saveChanges) {
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.editAccountCustomer, customerAccountDetails.saveChanges);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.customer.account.updateSuccessMessage);
}
}
Expand Down Expand Up @@ -228,6 +230,7 @@ export class CustomerPage extends BasePage {
if (addonIsVisible) this.selectByNumber(selector.customer.cSingleProduct.productAddon.addOnSelect, 1);
if (quantity) await this.clearAndType(selector.customer.cSingleProduct.productDetails.quantity, String(quantity));
await this.clickAndWaitForResponse(data.subUrls.frontend.productCustomerPage, selector.customer.cSingleProduct.productDetails.addToCart);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
if (!quantity) {
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, `“${productName}” has been added to your cart.`);
} else {
Expand Down
2 changes: 2 additions & 0 deletions tests/pw/pages/emailVerificationsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class EmailVerificationsPage extends BasePage {
await this.clearAndType(selector.customer.cRegistration.regPassword, user.password);
await this.click(selector.customer.cRegistration.regAsCustomer);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.myAccount, selector.customer.cRegistration.register, 302);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.dokanSettings.emailVerification.loginNotice);
}

Expand All @@ -24,6 +25,7 @@ export class EmailVerificationsPage extends BasePage {
await this.clearAndType(selector.frontend.username, user.username);
await this.clearAndType(selector.frontend.userPassword, user.password);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.myAccount, selector.frontend.logIn, 302);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.dokanSettings.emailVerification.loginNotice);
}
}
1 change: 1 addition & 0 deletions tests/pw/pages/myOrdersPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class MyOrdersPage extends CustomerPage {
async orderAgain(orderId: string, paymentMethod = 'bank') {
await this.goIfNotThere(data.subUrls.frontend.orderDetails(orderId));
await this.clickAndAcceptAndWaitForResponse(data.subUrls.frontend.orderAgain, selector.customer.cOrderDetails.orderAgain, 302);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'The cart has been filled with the items from your previous order.');
await this.goToCheckoutFromCart();
await this.paymentOrder(paymentMethod);
Expand Down
10 changes: 5 additions & 5 deletions tests/pw/pages/productAddonsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Page } from '@playwright/test';
import { VendorPage } from '@pages/vendorPage';
import { selector } from '@pages/selectors';
import { data } from '@utils/testData';
import { vendor } from '@utils/interfaces';
import { addon } from '@utils/interfaces';

// selectors
const addonsVendor = selector.vendor.vAddonSettings;
Expand Down Expand Up @@ -40,7 +40,7 @@ export class ProductAddonsPage extends VendorPage {
}

// update addon fields
async updateAddonFields(addon: vendor['addon'], add = true) {
async updateAddonFields(addon: addon, add = true) {
await this.clearAndType(addonsVendor.addon.name, addon.name);
await this.clearAndType(addonsVendor.addon.priority, addon.priority);

Expand Down Expand Up @@ -72,22 +72,22 @@ export class ProductAddonsPage extends VendorPage {
}

// add addon
async addAddon(addon: vendor['addon']) {
async addAddon(addon: addon) {
await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsAddon);
await this.clickAndWaitForLoadState(addonsVendor.createNewAddon);
await this.updateAddonFields(addon);
}

// edit addon
async editAddon(addon: vendor['addon']): Promise<void> {
async editAddon(addon: addon): Promise<void> {
await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsAddon);
await this.hover(addonsVendor.addonRow(addon.name));
await this.clickAndWaitForLoadState(addonsVendor.editAddon(addon.name));
await this.updateAddonFields(addon, false);
}

// delete addon
async deleteAddon(addon: vendor['addon']): Promise<void> {
async deleteAddon(addon: addon): Promise<void> {
await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsAddon);
await this.hover(addonsVendor.addonRow(addon.name));
await this.clickAndWaitForLoadState(addonsVendor.deleteAddon(addon.name));
Expand Down
1 change: 1 addition & 0 deletions tests/pw/pages/spmvPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class SpmvPage extends VendorPage {
await this.clickIfVisible(spmvCustomer.otherVendorAvailableTab);

await this.clickAndWaitForLoadState(spmvCustomer.availableVendorDetails.actions.addToCartByVendor(storeName));
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, `“${productName}” has been added to your cart.`);
}
}
5 changes: 1 addition & 4 deletions tests/pw/pages/vendorPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,8 @@ export class VendorPage extends BasePage {
await this.clearAndType(selector.vendor.vAccountDetails.email, vendor.username + vendor.vendorInfo.emailDomain);
// await this.updatePassword(vendor.vendorInfo.password, vendor.vendorInfo.password1);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.editAccountVendor, selector.vendor.vAccountDetails.saveChanges, 302);
await expect(this.page.getByText(selector.vendor.vAccountDetails.saveSuccessMessage)).toBeVisible();
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.vendor.vendorInfo.account.updateSuccessMessage);

// cleanup: reset password
// await this.updatePassword(vendor.vendorInfo.password1, vendor.vendorInfo.password, true);
}

// vendor update password
Expand Down
13 changes: 9 additions & 4 deletions tests/pw/pages/vendorProductSubscriptionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ export class VendorProductSubscriptionPage extends VendorPage {
}

// vendor view product subscription
// async viewProductSubscription(value: string) {
// todo: go to subscription details via link , get subscription id via api
// }
async viewProductSubscription(value: string) {
await this.goto(value);
// todo: go to subscription details via link , get subscription id via api
}

// filter product subscriptions
async filterProductSubscriptions(filterBy: string, inputValue: string): Promise<void> {
Expand Down Expand Up @@ -81,6 +82,7 @@ export class VendorProductSubscriptionPage extends VendorPage {
await this.goIfNotThere(data.subUrls.frontend.productSubscriptionDetails(subscriptionId));

await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productSubscriptionDetails(subscriptionId), subscriptionsCustomer.subscriptionDetails.actions.cancel, 302);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'Your subscription has been cancelled.');
}

Expand All @@ -93,6 +95,7 @@ export class VendorProductSubscriptionPage extends VendorPage {
}

await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productSubscriptionDetails(subscriptionId), subscriptionsCustomer.subscriptionDetails.actions.reActivate, 302);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'Your subscription has been reactivated.');
}

Expand All @@ -102,7 +105,8 @@ export class VendorProductSubscriptionPage extends VendorPage {

await this.clickAndWaitForLoadState(subscriptionsCustomer.subscriptionDetails.actions.changeAddress);
await this.customerPage.updateShippingFields(shippingInfo);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.shippingAddress, selector.customer.cAddress.shipping.shippingSaveAddress, 302);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.shippingAddress, selector.customer.cAddress.shipping.saveAddress, 302);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.customer.address.addressChangeSuccessMessage);
}

Expand All @@ -112,6 +116,7 @@ export class VendorProductSubscriptionPage extends VendorPage {
await this.clickAndWaitForLoadState(subscriptionsCustomer.subscriptionDetails.actions.changePayment);
// todo: change to new card
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productSubscriptionDetails(subscriptionId), subscriptionsCustomer.subscriptionDetails.changePaymentMethod);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'Payment method updated.');
}

Expand Down
4 changes: 4 additions & 0 deletions tests/pw/pages/vendorReturnRequestPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class VendorReturnRequestPage extends VendorPage {
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, vendorReturnRequest.view(orderNumber));
await this.clearAndType(vendorReturnRequest.returnRequestDetails.conversations.message, message);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, vendorReturnRequest.returnRequestDetails.conversations.sendMessage, 302);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.customer.rma.sendMessage);
}

Expand Down Expand Up @@ -99,6 +100,7 @@ export class VendorReturnRequestPage extends VendorPage {
await this.goto(data.subUrls.frontend.vDashboard.returnRequest);
await this.hover(vendorReturnRequest.returnRequestCell(orderNumber));
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, vendorReturnRequest.delete(orderNumber));
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'Return Request has been deleted successfully');
}

Expand Down Expand Up @@ -137,6 +139,7 @@ export class VendorReturnRequestPage extends VendorPage {
}
await this.clearAndType(selector.customer.cOrders.requestWarranty.warrantyRequestDetails, refund.refundRequestDetails);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.requestWarranty, selector.customer.cOrders.requestWarranty.warrantySubmitRequest, 302);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, refund.refundSubmitSuccessMessage);
}

Expand All @@ -146,6 +149,7 @@ export class VendorReturnRequestPage extends VendorPage {
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.viewRmaRequests, selector.customer.cRma.view(orderNumber));
await this.clearAndType(selector.customer.cRma.message, message);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.viewRmaRequests, selector.customer.cRma.sendMessage);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.customer.rma.sendMessage);
}
}
5 changes: 3 additions & 2 deletions tests/pw/pages/vendorShippingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Page, expect } from '@playwright/test';
import { VendorPage } from '@pages/vendorPage';
import { selector } from '@pages/selectors';
import { data } from '@utils/testData';
import { vendor, shipping } from '@utils/interfaces';
import { vendor } from '@utils/interfaces';

// selectors
const vendorShipping = selector.vendor.vShippingSettings;
Expand Down Expand Up @@ -72,6 +72,7 @@ export class VendorShippingPage extends VendorPage {

// vendor add shipping method
async addShippingMethod(shipping: any, forceAdd = false, skip?: boolean): Promise<void> {
// todo: add shipping type
await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsShipping);
// edit shipping zone
await this.hover(vendorShipping.shippingZoneCell(shipping.shippingZone));
Expand Down Expand Up @@ -168,7 +169,7 @@ export class VendorShippingPage extends VendorPage {
}

// vendor add shipping method
async deleteShippingMethod(shipping: shipping['shippingMethods']['flatRate']): Promise<void> {
async deleteShippingMethod(shipping: any): Promise<void> {
await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsShipping);

// edit shipping zone
Expand Down
1 change: 1 addition & 0 deletions tests/pw/pages/wholesaleCustomersPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export class WholesaleCustomersPage extends AdminPage {
const currentUser = await this.getCurrentUser();
await this.clickAndWaitForResponse(data.subUrls.api.dokan.wholesaleRegister, selector.customer.cDashboard.becomeWholesaleCustomer);
const neeApproval = await this.isVisible(selector.customer.cDashboard.wholesaleRequestReturnMessage);
await this.toBeVisible(selector.customer.cWooSelector.wooCommerceSuccessMessage);
if (!neeApproval) {
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.wholesale.becomeWholesaleCustomerSuccessMessage);
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default defineConfig({
/* Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference' */
// colorScheme: 'dark' ,
/* Whether to run tests on headless or non-headless mode */
headless: NON_HEADLESS ? false : true,
headless: !NON_HEADLESS,
/* Whether to ignore HTTPS errors during navigation. */
ignoreHTTPSErrors: true,
/* Record trace only when retrying a test for the first time. */
Expand Down
13 changes: 7 additions & 6 deletions tests/pw/tests/api/calculation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ test.describe.skip('Marketplace Coupon calculation test', () => {
taxRate = await apiUtils.setUpTaxRate(payloads.enableTax, payloads.createTaxRate);
// taxRate = await apiUtils.updateSingleWcSettingOptions('general', 'woocommerce_calc_discounts_sequentially', { value: 'no' });
sequentialCoupon = await apiUtils.getSingleWcSettingOptions('general', 'woocommerce_calc_discounts_sequentially');
// @ts-ignore
sequentialCoupon = sequentialCoupon?.value === 'yes' ? true : false;
// console.log('applySequentially:', sequentialCoupon);
[commission, feeRecipient] = await dbUtils.getSellingInfo();
Expand All @@ -117,7 +118,7 @@ test.describe.skip('Marketplace Coupon calculation test', () => {
// console.log(res);
console.log('Order id:', oid);
const discountTotal = res.discount_total;
const discountTax = res.discount_tax;
// const discountTax = res.discount_tax;
const shippingTotal = res.shipping_total;
const shippingTax = res.shipping_tax;
const cartTax = res.cart_tax;
Expand Down Expand Up @@ -166,8 +167,8 @@ test.describe.skip('Marketplace Coupon calculation test', () => {
test.describe.skip('commission test', () => {
let apiUtils: ApiUtils;
const taxRate: number = 10;
let commission: commission;
let feeRecipient: feeRecipient;
// let commission: commission;
// let feeRecipient: feeRecipient;

test.beforeAll(async () => {
apiUtils = new ApiUtils(await request.newContext());
Expand All @@ -182,7 +183,7 @@ test.describe.skip('commission test', () => {
test('percentage commission (global) test', { tag: ['@lite'] }, async () => {
// await dbUtils.setOptionValue(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, commission_type: 'percentage' });
// const [commission, feeRecipient] = await dbUtils.getSellingInfo();
const [, res, oid] = await apiUtils.createOrder(payloads.createProduct(), payloads.createOrder);
const [, res,] = await apiUtils.createOrder(payloads.createProduct(), payloads.createOrder);
console.log(res);
});

Expand Down Expand Up @@ -263,8 +264,8 @@ test.describe.skip('commission test', () => {
}

expect(Number(orderTotal)).toEqual(calculatedOrderTotal);
expect(Number(vendor_earning)).toEqual(calculatedVendorEarning);
expect(Number(admin_commission)).toEqual(calculatedAdminCommission);
// expect(Number(vendor_earning)).toEqual(calculatedVendorEarning);
// expect(Number(admin_commission)).toEqual(calculatedAdminCommission);
expect(Number(shippingFee)).toEqual(providedShippingFee);
expect(Number(shippingTax)).toEqual(calculatedShippingTax);
expect(Number(cartTax)).toEqual(calculatedProductTax);
Expand Down
Loading

0 comments on commit 41acceb

Please sign in to comment.