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"
}
}
27 changes: 27 additions & 0 deletions tests/pw/pages/frontend/cart.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { BasePage } from '@pages/basePage';

export default class CartPage extends BasePage {
quantityInputFieldFor(productTitle: string) {
return this.page.locator(`//div[@class="quantity"]/label[contains(text(), "${productTitle}")]/following-sibling::input`);
}

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

quantityErrorElement() {
return this.page.locator('//td[@class="product-quantity"]/div[@class="required"]');
}

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

async enterQuantityValue(productTitle: string, quantityValue: string) {
await this.quantityInputFieldFor(productTitle).fill(quantityValue);
}

async clickOnUpdateCartButton() {
await this.updateCartButton().click();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Locators are already defined in pages/selectors. Add new locators there if they are not already included. Using multiple files solely for locators can unnecessarily complicate the project.

27 changes: 27 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,27 @@
import { BasePage } from '@pages/basePage';

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

11 changes: 11 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,11 @@
import { BasePage } from '@pages/basePage';

export default class AllMyOrdersPage extends BasePage {
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();
}
}
23 changes: 23 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,23 @@
import { BasePage } from '@pages/basePage';

export default class CustomerOrderDetailsPage extends BasePage {
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();
}
}
11 changes: 11 additions & 0 deletions tests/pw/pages/frontend/navigation/main-menu.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { BasePage } from '@pages/basePage';

export default class StorefrontMainMenu extends BasePage {
cartContentLink() {
return this.page.locator('.cart-contents');
}

async clickOnCartContentLink() {
await this.cartContentLink().click();
}
}
11 changes: 11 additions & 0 deletions tests/pw/pages/frontend/shop/shop.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { BasePage } from '@pages/basePage';

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();
}
}
23 changes: 23 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,23 @@
import { BasePage } from '@pages/basePage';

export default class SingleProductPage extends BasePage {
quantityInputFieldFor(productTitle: string) {
return this.page.locator(`//div[@class="quantity"]/label[contains(text(), "${productTitle}")]/following-sibling::input`);
}

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

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

async enterQuantityValue(productTitle: string, quantityValue: string) {
await this.quantityInputFieldFor(productTitle).fill(quantityValue);
}

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

export default class VendorDashboardSidebarPage extends BasePage {
sidebarMenu(title: string) {
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,11 @@
import { BasePage } from '@pages/basePage';

export default class VendorAllOrdersPage extends BasePage {
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,59 @@
import { BasePage } from '@pages/basePage';

export default class VendorEditOrderPage extends BasePage {
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,35 @@
import { BasePage } from '@pages/basePage';

export default class VendorProductAddEditPage extends BasePage {
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,11 @@
import { BasePage } from '@pages/basePage';

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

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