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

Test Case :: Order Min Max #2367

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
46 changes: 46 additions & 0 deletions tests/pw/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tests/pw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.3.0",
"@types/randomstring": "^1.3.0",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"eslint": "8.57",
Expand All @@ -68,6 +69,7 @@
"dotenv": "^16.4.5",
"mysql2": "^3.11.0",
"php-serialize": "^5.0.1",
"randomstring": "^1.3.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using radomstring package. use Use faker.string.alpha() from faker-js package which is already available

"zod": "^3.23.8"
}
}
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);
}

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();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Great job with the Page Object class! Just one small improvement.

The MyAccountAuthPage class is well-structured and follows the Page Object Model pattern. The methods are named appropriately and encapsulate the interactions with the page elements.

However, as the static analysis tool correctly points out, the constructor is unnecessary since it only calls the super constructor without any additional logic.

Please apply this diff to remove the unnecessary constructor:

export default class MyAccountAuthPage extends BasePage {
-    constructor(page: Page) {
-        super(page);
-    }
 
    usernameInputField() {
        return this.page.locator('#username');
    }
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
export default class MyAccountAuthPage extends BasePage {
constructor(page: Page) {
super(page);
}
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();
}
}
export default class MyAccountAuthPage extends BasePage {
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();
}
}
Tools
Biome

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of creating a class with already implemented methods. use login methods from the LoginPage class

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);
}
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 in the AllMyOrdersPage class is unnecessary because it only calls the parent constructor with the provided Page object and doesn't add any additional functionality or initialization. You can remove the constructor and let the class inherit the parent constructor directly to simplify the code without changing the behavior.

Apply this diff to remove the unnecessary 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)


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

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();
}
}
16 changes: 16 additions & 0 deletions tests/pw/pages/frontend/shop/shop.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 ShopPage extends BasePage {
constructor(page: Page) {
super(page);
}

productTitle() {
return this.page.locator('.woocommerce-loop-product__title');
}

async clickOnProductWithTitle(productTitle: string) {
await this.productTitle().getByText(productTitle).click();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM with a minor suggestion!

The ShopPage class structure and method implementations look good. The productTitle method correctly returns the locator for the product title element, and the clickOnProductWithTitle method finds the product title element and clicks on it as expected.

However, as suggested by the static analysis tool, the constructor is unnecessary since it's not doing anything other than calling the super constructor. You can safely remove it to simplify the code.

Apply this diff to remove the unnecessary constructor:

 export default class ShopPage extends BasePage {
-    constructor(page: Page) {
-        super(page);
-    }
 
     productTitle() {
         return this.page.locator('.woocommerce-loop-product__title');
     }
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
export default class ShopPage extends BasePage {
constructor(page: Page) {
super(page);
}
productTitle() {
return this.page.locator('.woocommerce-loop-product__title');
}
async clickOnProductWithTitle(productTitle: string) {
await this.productTitle().getByText(productTitle).click();
}
}
export default class ShopPage extends BasePage {
productTitle() {
return this.page.locator('.woocommerce-loop-product__title');
}
async clickOnProductWithTitle(productTitle: string) {
await this.productTitle().getByText(productTitle).click();
}
}
Tools
Biome

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

20 changes: 20 additions & 0 deletions tests/pw/pages/frontend/shop/single-product.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class SingleProductPage extends BasePage {
constructor(page: Page) {
super(page);
}

addToCartButton() {
return this.page.locator('.single_add_to_cart_button');
}

errorMessageElement() {
return this.page.locator('//ul[@class="woocommerce-error"]/li');
}

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

export default class VendorDashboardSidebarPage extends BasePage {
constructor(page: Page) {
super(page);
}

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

async clickOnOrdersTab() {
await this.sidebarMenu('orders').click();
}

async clickOnProductsTab() {
await this.sidebarMenu('products').click();
}

async clickOnSettingsTab() {
await this.sidebarMenu('settings').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);
}

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);
}
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 simply calling the super method with the page object, which is already being done in the BasePage class. The constructor is not adding any additional functionality and can be safely removed.

Apply this diff to remove the unnecessary 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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { BasePage } from '@pages/basePage';
import { Page } from '@playwright/test';

export default class VendorProductAddEditPage extends BasePage {
constructor(page: Page) {
super(page);
}
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 static analysis tool has correctly flagged the constructor as unnecessary. Since the constructor is empty and doesn't add any additional functionality, it can be safely removed without affecting the class behavior.

Apply this diff to remove the unnecessary 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)


simpleProductMinQtyInputField() {
return this.page.locator('#dokan_simple_product_min_quantity');
}

simpleProductMaxQtyInputField() {
return this.page.locator('#dokan_simple_product_max_quantity');
}

productStatusSelectField() {
return this.page.locator('#post_status');
}

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

async enterSimpleProductMinQty(quantity: string) {
await this.simpleProductMinQtyInputField().fill(quantity);
}

async enterSimpleProductMaxQty(quantity: string) {
await this.simpleProductMaxQtyInputField().fill(quantity);
}

async selectProductStatus(status: 'publish' | 'draft' | 'pending') {
await this.productStatusSelectField().selectOption(status);
}

async clickOnSaveProduct() {
await this.saveProductButton().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 VendorProductListPage extends BasePage {
constructor(page: Page) {
super(page);
}

productTitle() {
return this.page.locator(`//td[@data-title="Name"]/strong/a`);
}

async clickOnProductWithTitle(productTitle: string) {
await this.productTitle().getByText(productTitle).click();
}
}
Loading
Loading