Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark Order As Received Test Automation #2320

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tests/pw/pages/frontend/my-account/auth/my-account-auth.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class MyAccountAuthPage extends BasePage {
constructor(page: Page) {
super(page);
}
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary constructor.

The constructor is unnecessary as it only calls the parent constructor. Simplify the code by removing it.

-  constructor(page: Page) {
-      super(page);
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(page: Page) {
super(page);
}
Tools
Biome

[error] 5-7: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)


usernameInputField() {
return this.page.locator('#username');
}

passwordInputField() {
return this.page.locator('#password');
}

loginButton() {
return this.page.locator('//button[@name="login"]');
}

async enterUsername(username: string) {
await this.usernameInputField().fill(username);
}

async enterPassword(password: string) {
await this.passwordInputField().fill(password);
}

async clickOnLoginButton() {
await this.loginButton().click();
}
}
16 changes: 16 additions & 0 deletions tests/pw/pages/frontend/my-orders/all-my-orders.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class AllMyOrdersPage extends BasePage {
constructor(page: Page) {
super(page);
}
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary constructor.

The constructor is redundant as it only calls the parent constructor without adding any additional logic.

-  constructor(page: Page) {
-    super(page);
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(page: Page) {
super(page);
}
Tools
Biome

[error] 5-7: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)


viewButtonByOrderId(orderId: string) {
return this.page.locator(`//td[@class="order-number"]/a[contains(text(), "${orderId}")]/../following-sibling::td[5]/a`);
}

async clickOnViewButtonByOrderId(orderId: string) {
await this.viewButtonByOrderId(orderId).click();
}
}
28 changes: 28 additions & 0 deletions tests/pw/pages/frontend/my-orders/customer-order-details.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class CustomerOrderDetailsPage extends BasePage {
constructor(page: Page) {
super(page);
}
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary constructor.

The constructor is unnecessary as it only calls the parent constructor. Simplify the code by removing it.

-  constructor(page: Page) {
-      super(page);
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(page: Page) {
super(page);
}
Tools
Biome

[error] 5-7: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)


orderReceivedButtonByShipmentNumber(shipmentNumber: string) {
return this.page.locator(`//h4[@class="shippments-tracking-title"]/strong[text()="Shipment ${shipmentNumber} "]/../../div[1]/strong[@class="customer-status"]`);
}

trackingStatusByShipmentNumber(shipmentNumber: string) {
return this.page.locator(`//h4[@class="shippments-tracking-title"]/strong[text()="Shipment ${shipmentNumber} "]/../../div[1]/p/strong`);
}

dialogueBoxOkButton() {
return this.page.locator('//div[@role="dialog"]/div[6]/button[text()="OK"]');
}

async markOrderAsReceived(shipmentNumber: string) {
await this.orderReceivedButtonByShipmentNumber(shipmentNumber).click();
}

async clickOnDialogBoxOkButton() {
await this.dialogueBoxOkButton().click();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class VendorDashboardSidebarPage extends BasePage {
constructor(page: Page) {
super(page);
}
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary constructor.

The constructor does not add any new functionality and can be safely removed.

-  constructor(page: Page) {
-    super(page);
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(page: Page) {
super(page);
}
Tools
Biome

[error] 5-7: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)


sidebarMenu(title: string) {
return this.page.locator(`//li[@class="${title}"]/a`);
}

async clickOnOrdersTab() {
await this.sidebarMenu('orders').click();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class VendorAllOrdersPage extends BasePage {
constructor(page: Page) {
super(page);
}
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary constructor.

The constructor is redundant as it only calls the parent constructor without adding any additional logic.

-  constructor(page: Page) {
-    super(page);
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(page: Page) {
super(page);
}
Tools
Biome

[error] 5-7: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)


orderTitleById(orderId: string) {
return this.page.locator(`//td[@data-title="Order"]/a/strong[text()="Order ${orderId}"]`);
}

async clickOnOrderById(orderId: string) {
await this.orderTitleById(orderId).click();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class VendorEditOrderPage extends BasePage {
constructor(page: Page) {
super(page);
}
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary constructor.

The constructor is unnecessary as it only calls the parent constructor.

-  constructor(page: Page) {
-    super(page);
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(page: Page) {
super(page);
}
Tools
Biome

[error] 5-7: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)


createNewShipmentButton() {
return this.page.locator('#create-tracking-status-action');
}

shipmentItemCheckboxByIndex(itemNumber: string) {
return this.page.locator(`//form[@id="add-shipping-tracking-status-form"]/div/table/tbody[@id="order_line_items"]/tr[${itemNumber}]/td[1]/label/input`);
}

shippingStatusDropdown() {
return this.page.locator('#shipment-status');
}

shippingProviderDropdown() {
return this.page.locator('#shipping_status_provider');
}

shippingDateField() {
return this.page.locator('#shipped_status_date');
}

shippingTrackingNumberField() {
return this.page.locator('#tracking_status_number');
}

createShipmentButton() {
return this.page.locator('#add-tracking-status-details');
}

async clickOnCreateNewShipmentButton() {
await this.createNewShipmentButton().click();
}

async clickOnShipmentItemCheckboxByIndex(itemNumber: string) {
await this.shipmentItemCheckboxByIndex(itemNumber).click();
}

async selectShippingStatus(status: string) {
await this.shippingStatusDropdown().selectOption(status);
}

async selectShippingProvider(providerName: string) {
await this.shippingProviderDropdown().selectOption(providerName);
}

async enterShippingDate(date: string) {
await this.shippingDateField().fill(date);
}

async enterShippingTrackingNumber(trackingNumber: string) {
await this.shippingTrackingNumberField().fill(trackingNumber);
}

async clickOnCreateShipmentButton() {
await this.createShipmentButton().click();
}
}
16 changes: 16 additions & 0 deletions tests/pw/pages/wp-admin/common/sidebar.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class WpAdminSidebar extends BasePage {
constructor(page: Page) {
super(page);
}
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary constructor.

The constructor does not add any new functionality and can be safely removed.

-  constructor(page: Page) {
-    super(page);
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(page: Page) {
super(page);
}
Tools
Biome

[error] 5-7: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)


sideMenu(title: string) {
return this.page.locator('.wp-menu-name').getByText(title);
}

async clickOnProductsLink() {
await this.sideMenu('Products').click();
}
}
54 changes: 54 additions & 0 deletions tests/pw/pages/wp-admin/dokan/settings/shipping-status.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class DokanShippingStatusPage extends BasePage {
constructor(page: Page) {
super(page);
}
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary constructor.

The constructor is unnecessary as it only calls the parent constructor.

-  constructor(page: Page) {
-    super(page);
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(page: Page) {
super(page);
}
Tools
Biome

[error] 5-7: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)


shippingStatusTab() {
return this.page.locator('//div[@class="nav-title"][text()="Shipping Status"]');
}

allowShipmentTrackingCheckbox() {
return this.page.locator('(//p/../following-sibling::div/label/label)[1]');
}

allowMarkAsReceivedCheckbox() {
return this.page.locator('(//p/../following-sibling::div/label/label)[2]');
}

async shippingStatusItem(status: string) {
const list = this.page.locator('//ul[@class="dokan-settings-repeatable-list"]/li').all();

let locator;
for (const item of await list) {
const text = await item.textContent();
if (text?.includes(status)) {
locator = item;
}
}

return locator;
}
Comment on lines +21 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimize the method to find the shipping status item.

The method can be optimized by using array methods to find the item with the matching status.

-  async shippingStatusItem(status: string) {
-    const list = this.page.locator('//ul[@class="dokan-settings-repeatable-list"]/li').all();
-
-    let locator;
-    for (const item of await list) {
-      const text = await item.textContent();
-      if (text?.includes(status)) {
-        locator = item;
-      }
-    }
-
-    return locator;
-  }
+  async shippingStatusItem(status: string) {
+    const list = await this.page.locator('//ul[@class="dokan-settings-repeatable-list"]/li').all();
+    return list.find(async (item) => (await item.textContent())?.includes(status));
+  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async shippingStatusItem(status: string) {
const list = this.page.locator('//ul[@class="dokan-settings-repeatable-list"]/li').all();
let locator;
for (const item of await list) {
const text = await item.textContent();
if (text?.includes(status)) {
locator = item;
}
}
return locator;
}
async shippingStatusItem(status: string) {
const list = await this.page.locator('//ul[@class="dokan-settings-repeatable-list"]/li').all();
return list.find(async (item) => (await item.textContent())?.includes(status));
}


saveChangesButton() {
return this.page.locator('#submit');
}

async clickOnShippingStatusTab() {
await this.shippingStatusTab().click();
}

async clickOnAllowShipmentTrackingCheckbox() {
await this.allowShipmentTrackingCheckbox().click();
}

async clickOnAllowMarkAsReceivedCheckbox() {
await this.allowMarkAsReceivedCheckbox().click();
}

async clickOnSaveChangesButton() {
await this.saveChangesButton().click();
}
}
16 changes: 16 additions & 0 deletions tests/pw/pages/wp-admin/products/all-products.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class AllProductsPage extends BasePage {
constructor(page: Page) {
super(page);
}
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary constructor.

The constructor is redundant as it only calls the parent constructor without adding any additional logic.

-  constructor(page: Page) {
-    super(page);
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(page: Page) {
super(page);
}
Tools
Biome

[error] 5-7: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)


productTitleById(productId: string) {
return this.page.locator(`//tr[@id="post-${productId}"]/td[2]/strong/a`);
}

async clickOnProductTitleById(productId: string) {
await this.productTitleById(productId).click();
}
}
16 changes: 16 additions & 0 deletions tests/pw/pages/wp-admin/products/edit-product.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class EditProductPage extends BasePage {
constructor(page: Page) {
super(page);
}
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary constructor.

The constructor does not add any new functionality and can be safely removed.

-  constructor(page: Page) {
-    super(page);
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constructor(page: Page) {
super(page);
}
Tools
Biome

[error] 5-7: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)


publishButton() {
return this.page.locator('#publish');
}

async clickOnPublishButton() {
await this.publishButton().click();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { LoginPage } from '@pages/loginPage';
import DokanShippingStatusPage from '@pages/wp-admin/dokan/settings/shipping-status.page';
import test, { expect } from '@playwright/test';

let baseUrl: string;
let loginPage: LoginPage;
let shippingStatusPage: DokanShippingStatusPage;

test.describe('Mark Order As Received - 01', () => {
test.beforeEach(async ({ page }, testInfo) => {
loginPage = new LoginPage(page);
shippingStatusPage = new DokanShippingStatusPage(page);

console.log(testInfo.project.use.baseURL);
baseUrl = testInfo.project.use.baseURL as string;
await page.goto(baseUrl);
});

test('Receive status is added when Mark received by Customer is enabled', async ({ page }) => {
await loginPage.adminLogin({ username: 'admin1', password: '[email protected]' });
await page.goto(baseUrl + '/wp-admin/admin.php?page=dokan#/settings');
await shippingStatusPage.clickOnShippingStatusTab();
await shippingStatusPage.clickOnAllowShipmentTrackingCheckbox();
await shippingStatusPage.clickOnAllowMarkAsReceivedCheckbox();
await shippingStatusPage.clickOnSaveChangesButton();

const status = await shippingStatusPage.shippingStatusItem('Received');
expect(await status?.textContent()).toContain('Received');
});
});
Loading
Loading