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

Conversation

StalinDurjo
Copy link
Contributor

@StalinDurjo StalinDurjo commented Jul 26, 2024

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

  • Full PR Link

Closes

  • Closes #

How to test the changes in this Pull Request:

  • Steps or issue link

Changelog entry

Title

Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.

Before Changes

Describe the issue before changes with screenshots(s).

After Changes

Describe the issue after changes with screenshot(s).

Feature Video (optional)

Link of detailed video if this PR is for a feature.

PR Self Review Checklist:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

  • New Features

    • Introduced several new page classes for managing user accounts, vendor dashboards, and product settings, enhancing automated testing capabilities.
    • Added functionality for marking orders as received through a new end-to-end test case, verifying shipping status management.
  • Bug Fixes

    • Resolved issues in existing tests which may have prevented accurate interaction with the shipping status functionality.
  • Tests

    • Implemented new end-to-end test cases to validate order management and shipping status updates, ensuring robust functionality across vendor and customer interactions.

Copy link
Contributor

coderabbitai bot commented Jul 26, 2024

Walkthrough

The changes introduce a series of new page object model classes for managing various functionalities in a web application, primarily focused on user accounts, orders, vendor interactions, and admin settings. Each class is designed to streamline automated testing using Playwright, encapsulating methods for element interaction and enhancing the maintainability of test scripts. New end-to-end tests validate critical workflows, ensuring that features operate as intended.

Changes

File(s) Change Summary
tests/pw/pages/frontend/my-account/auth/my-account-auth.page.ts Introduced MyAccountAuthPage for user authentication interactions, including methods for entering usernames and passwords, and clicking the login button.
tests/pw/pages/frontend/my-orders/all-my-orders.page.ts Added AllMyOrdersPage class to facilitate interactions with order view buttons based on order IDs.
tests/pw/pages/frontend/my-orders/customer-order-details.page.ts Created CustomerOrderDetailsPage to handle shipment details, including methods for order received buttons and tracking statuses.
tests/pw/pages/frontend/vendor-dashboard/common/vendor-sidebar.page.ts Defined VendorDashboardSidebarPage for navigating the vendor dashboard sidebar with methods for locating and clicking sidebar menu items.
tests/pw/pages/frontend/vendor-dashboard/orders/vendor-all-orders.page.ts Added VendorAllOrdersPage for managing interactions with vendor orders, including locating and clicking order titles.
tests/pw/pages/frontend/vendor-dashboard/orders/vendor-edit-order.page.ts Introduced VendorEditOrderPage for editing order details, with methods for handling shipments and shipping statuses.
tests/pw/pages/wp-admin/common/sidebar.page.ts Created WpAdminSidebar class for managing the WordPress admin sidebar with methods for navigation.
tests/pw/pages/wp-admin/dokan/settings/shipping-status.page.ts Introduced DokanShippingStatusPage for interacting with shipping status settings in the Dokan plugin.
tests/pw/pages/wp-admin/products/all-products.page.ts Added AllProductsPage for interacting with a list of products, enabling retrieval and interaction with product titles.
tests/pw/pages/wp-admin/products/edit-product.page.ts Introduced EditProductPage for managing product editing, specifically for the publish button.
tests/pw/tests/e2e/shipping-status/mark-order-as-received-01.spec.ts New end-to-end test for verifying the "mark as received" functionality in shipping status management.
tests/pw/tests/e2e/shipping-status/mark-order-as-received-02.spec.ts Added a comprehensive end-to-end test for the vendor-customer order flow, ensuring that tracking statuses are correctly marked.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Vendor
    participant Admin
    participant System

    User->>System: Log in
    User->>System: View Orders
    User->>System: Mark Order as Received
    System->>User: Confirm Status Updated
    Vendor->>System: Create Shipment
    Vendor->>System: Update Shipping Status
    Admin->>System: Access Shipping Status Settings
    Admin->>System: Save Changes
Loading

🐰 In the fields so bright and fair,
New pages leap, with joyous flair!
With clicks and types, our tests shall run,
Each order marked, the work is fun!
So hop along, let's automate,
For every change, we celebrate! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@shashwatahalder01 shashwatahalder01 added the Needs: Dev Review It requires a developer review and approval label Jul 26, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 13

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9e1d883 and 6a08fdd.

Files selected for processing (12)
  • tests/pw/pages/frontend/my-account/auth/my-account-auth.page.ts (1 hunks)
  • tests/pw/pages/frontend/my-orders/all-my-orders.page.ts (1 hunks)
  • tests/pw/pages/frontend/my-orders/customer-order-details.page.ts (1 hunks)
  • tests/pw/pages/frontend/vendor-dashboard/common/vendor-sidebar.page.ts (1 hunks)
  • tests/pw/pages/frontend/vendor-dashboard/orders/vendor-all-orders.page.ts (1 hunks)
  • tests/pw/pages/frontend/vendor-dashboard/orders/vendor-edit-order.page.ts (1 hunks)
  • tests/pw/pages/wp-admin/common/sidebar.page.ts (1 hunks)
  • tests/pw/pages/wp-admin/dokan/settings/shipping-status.page.ts (1 hunks)
  • tests/pw/pages/wp-admin/products/all-products.page.ts (1 hunks)
  • tests/pw/pages/wp-admin/products/edit-product.page.ts (1 hunks)
  • tests/pw/tests/e2e/shipping-status/mark-order-as-received-01.spec.ts (1 hunks)
  • tests/pw/tests/e2e/shipping-status/mark-order-as-received-02.spec.ts (1 hunks)
Additional context used
Biome
tests/pw/pages/wp-admin/products/edit-product.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/wp-admin/common/sidebar.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/vendor-dashboard/common/vendor-sidebar.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/wp-admin/products/all-products.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/vendor-dashboard/orders/vendor-all-orders.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/my-orders/all-my-orders.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/my-account/auth/my-account-auth.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/my-orders/customer-order-details.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/wp-admin/dokan/settings/shipping-status.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/vendor-dashboard/orders/vendor-edit-order.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/tests/e2e/shipping-status/mark-order-as-received-02.spec.ts

[error] 15-15: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

Additional comments not posted (45)
tests/pw/pages/wp-admin/products/edit-product.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for the publish button.


13-15: LGTM!

The method correctly clicks on the publish button.

tests/pw/pages/wp-admin/common/sidebar.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for the side menu item based on the title.


13-15: LGTM!

The method correctly clicks on the products link in the side menu.

tests/pw/pages/frontend/vendor-dashboard/common/vendor-sidebar.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for the sidebar menu item based on the title.


13-15: LGTM!

The method correctly clicks on the orders tab in the sidebar menu.

tests/pw/pages/wp-admin/products/all-products.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for a product title based on the product ID.


13-15: LGTM!

The method correctly clicks on the product title element based on the product ID.

tests/pw/pages/frontend/vendor-dashboard/orders/vendor-all-orders.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for an order title based on the order ID.


13-15: LGTM!

The method correctly clicks on the order title element based on the order ID.

tests/pw/pages/frontend/my-orders/all-my-orders.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for a view button based on the order ID.


13-15: LGTM!

The method correctly clicks on the view button element based on the order ID.

tests/pw/pages/frontend/my-account/auth/my-account-auth.page.ts (6)

9-11: LGTM!

The method correctly returns the locator for the username input field.


13-15: LGTM!

The method correctly returns the locator for the password input field.


17-19: LGTM!

The method correctly returns the locator for the login button.


21-23: LGTM!

The method correctly fills the username input field with the provided username.


25-27: LGTM!

The method correctly fills the password input field with the provided password.


29-31: LGTM!

The method correctly clicks on the login button.

tests/pw/pages/frontend/my-orders/customer-order-details.page.ts (5)

9-11: LGTM!

The method correctly returns the locator for the order received button by shipment number.


13-15: LGTM!

The method correctly returns the locator for the tracking status by shipment number.


17-19: LGTM!

The method correctly returns the locator for the OK button in the dialogue box.


21-23: LGTM!

The method correctly clicks the order received button by shipment number.


25-27: LGTM!

The method correctly clicks the OK button in the dialogue box.

tests/pw/tests/e2e/shipping-status/mark-order-as-received-01.spec.ts (1)

19-29: LGTM!

The test case correctly verifies the functionality of marking an order as received by enabling the relevant settings and checking the status.

tests/pw/pages/wp-admin/dokan/settings/shipping-status.page.ts (6)

9-11: LGTM!

The method correctly returns the locator for the shipping status tab.


13-15: LGTM!

The method correctly returns the locator for the shipment tracking checkbox.


17-19: LGTM!

The method correctly returns the locator for the mark as received checkbox.


35-37: LGTM!

The method correctly returns the locator for the save changes button.


39-41: LGTM!

The method correctly clicks on the shipping status tab.


43-45: LGTM!

The methods correctly click on their respective elements.

Also applies to: 47-49, 51-53

tests/pw/pages/frontend/vendor-dashboard/orders/vendor-edit-order.page.ts (8)

9-11: LGTM!

The method correctly returns the locator for the create new shipment button.


13-15: LGTM!

The method correctly returns the locator for a shipment item checkbox based on the item number.


17-19: LGTM!

The method correctly returns the locator for the shipping status dropdown.


21-23: LGTM!

The method correctly returns the locator for the shipping provider dropdown.


25-27: LGTM!

The method correctly returns the locator for the shipping date field.


29-31: LGTM!

The method correctly returns the locator for the shipping tracking number field.


33-35: LGTM!

The method correctly returns the locator for the create shipment button.


37-39: LGTM!

The methods correctly perform actions on their respective elements.

Also applies to: 41-43, 45-47, 49-51, 53-55, 57-59, 61-63

tests/pw/tests/e2e/shipping-status/mark-order-as-received-02.spec.ts (7)

1-13: LGTM!

The necessary imports are correctly included.


20-23: LGTM!

The setup for the test case is correct and necessary.


24-28: LGTM!

The customer creation logic is correct and necessary.


29-33: LGTM!

The vendor creation logic is correct and necessary.


34-52: LGTM!

The product creation logic is correct and necessary.


54-71: LGTM!

The product publishing logic is correct and necessary.


73-113: LGTM!

The order creation logic is correct and necessary.

Comment on lines +15 to +18
test.describe.only('Mark Order As Received - 02', () => {
test.beforeEach(async ({ page }, testInfo) => {
await page.goto(testInfo.project.use.baseURL as string);
});
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 only method from the test suite.

The only method is often used for debugging or during implementation. It should be removed to ensure all tests are executed.

- test.describe.only('Mark Order As Received - 02', () => {
+ test.describe('Mark Order As Received - 02', () => {
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
test.describe.only('Mark Order As Received - 02', () => {
test.beforeEach(async ({ page }, testInfo) => {
await page.goto(testInfo.project.use.baseURL as string);
});
test.describe('Mark Order As Received - 02', () => {
test.beforeEach(async ({ page }, testInfo) => {
await page.goto(testInfo.project.use.baseURL as string);
});
Tools
Biome

[error] 15-15: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

Comment on lines +114 to +167
const vendorBrowser = await chromium.launch(browserOptions);
const vendorPage = await vendorBrowser.newPage();

const vendorDashboardSidebarPage = new VendorDashboardSidebarPage(vendorPage);
const vendorAllOrdersPage = new VendorAllOrdersPage(vendorPage);
const vendorEditOrderPage = new VendorEditOrderPage(vendorPage);
const vendorMyAccountAuthPage = new MyAccountAuthPage(vendorPage);

// vendor login
await vendorPage.goto('/dashboard/');
await vendorMyAccountAuthPage.enterUsername(vendorEmail);
await vendorMyAccountAuthPage.enterPassword(process.env.USER_PASSWORD);
await vendorMyAccountAuthPage.clickOnLoginButton();

// create shipment
await vendorDashboardSidebarPage.clickOnOrdersTab();
await vendorAllOrdersPage.clickOnOrderById(`${orderId}`);
await vendorEditOrderPage.clickOnCreateNewShipmentButton();
await vendorEditOrderPage.clickOnShipmentItemCheckboxByIndex('1');

await vendorEditOrderPage.selectShippingStatus('Delivered');
await vendorEditOrderPage.selectShippingProvider('Fedex');
await vendorEditOrderPage.enterShippingDate('July 27, 2024');
await vendorEditOrderPage.enterShippingTrackingNumber('#KDJNS93');
await vendorEditOrderPage.clickOnCreateShipmentButton();

// close vendor browser
await vendorBrowser.close();

const customerBrowser = await chromium.launch(browserOptions);
const customerPage = await customerBrowser.newPage();

const customerMyAccountAuthPage = new MyAccountAuthPage(customerPage);
const allMyOrdersPage = new AllMyOrdersPage(customerPage);
const customerOrderDetailsPage = new CustomerOrderDetailsPage(customerPage);

// customer login
await customerPage.goto('/my-account/');
await customerMyAccountAuthPage.enterUsername(customerEmail);
await customerMyAccountAuthPage.enterPassword(process.env.USER_PASSWORD);
await customerMyAccountAuthPage.clickOnLoginButton();

// customer marks order as received
await customerPage.goto('/my-orders/');
await allMyOrdersPage.clickOnViewButtonByOrderId(`${orderId}`);
await customerOrderDetailsPage.markOrderAsReceived('#1');
await customerOrderDetailsPage.clickOnDialogBoxOkButton();

// temporary solution, will be replaced
await page.waitForTimeout(3000);

const status = await customerOrderDetailsPage.trackingStatusByShipmentNumber('#1').textContent();
expect(status?.trim()).toEqual('Received');
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace the temporary solution using waitForTimeout.

The waitForTimeout is a temporary solution and should be replaced with a more reliable method, such as waiting for a specific element to be visible or a network request to complete.

- // temporary solution, will be replaced
- await page.waitForTimeout(3000);
+ // replace with a more reliable method
+ await customerOrderDetailsPage.trackingStatusByShipmentNumber('#1').waitFor({ state: 'visible' });
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
const vendorBrowser = await chromium.launch(browserOptions);
const vendorPage = await vendorBrowser.newPage();
const vendorDashboardSidebarPage = new VendorDashboardSidebarPage(vendorPage);
const vendorAllOrdersPage = new VendorAllOrdersPage(vendorPage);
const vendorEditOrderPage = new VendorEditOrderPage(vendorPage);
const vendorMyAccountAuthPage = new MyAccountAuthPage(vendorPage);
// vendor login
await vendorPage.goto('/dashboard/');
await vendorMyAccountAuthPage.enterUsername(vendorEmail);
await vendorMyAccountAuthPage.enterPassword(process.env.USER_PASSWORD);
await vendorMyAccountAuthPage.clickOnLoginButton();
// create shipment
await vendorDashboardSidebarPage.clickOnOrdersTab();
await vendorAllOrdersPage.clickOnOrderById(`${orderId}`);
await vendorEditOrderPage.clickOnCreateNewShipmentButton();
await vendorEditOrderPage.clickOnShipmentItemCheckboxByIndex('1');
await vendorEditOrderPage.selectShippingStatus('Delivered');
await vendorEditOrderPage.selectShippingProvider('Fedex');
await vendorEditOrderPage.enterShippingDate('July 27, 2024');
await vendorEditOrderPage.enterShippingTrackingNumber('#KDJNS93');
await vendorEditOrderPage.clickOnCreateShipmentButton();
// close vendor browser
await vendorBrowser.close();
const customerBrowser = await chromium.launch(browserOptions);
const customerPage = await customerBrowser.newPage();
const customerMyAccountAuthPage = new MyAccountAuthPage(customerPage);
const allMyOrdersPage = new AllMyOrdersPage(customerPage);
const customerOrderDetailsPage = new CustomerOrderDetailsPage(customerPage);
// customer login
await customerPage.goto('/my-account/');
await customerMyAccountAuthPage.enterUsername(customerEmail);
await customerMyAccountAuthPage.enterPassword(process.env.USER_PASSWORD);
await customerMyAccountAuthPage.clickOnLoginButton();
// customer marks order as received
await customerPage.goto('/my-orders/');
await allMyOrdersPage.clickOnViewButtonByOrderId(`${orderId}`);
await customerOrderDetailsPage.markOrderAsReceived('#1');
await customerOrderDetailsPage.clickOnDialogBoxOkButton();
// temporary solution, will be replaced
await page.waitForTimeout(3000);
const status = await customerOrderDetailsPage.trackingStatusByShipmentNumber('#1').textContent();
expect(status?.trim()).toEqual('Received');
});
const vendorBrowser = await chromium.launch(browserOptions);
const vendorPage = await vendorBrowser.newPage();
const vendorDashboardSidebarPage = new VendorDashboardSidebarPage(vendorPage);
const vendorAllOrdersPage = new VendorAllOrdersPage(vendorPage);
const vendorEditOrderPage = new VendorEditOrderPage(vendorPage);
const vendorMyAccountAuthPage = new MyAccountAuthPage(vendorPage);
// vendor login
await vendorPage.goto('/dashboard/');
await vendorMyAccountAuthPage.enterUsername(vendorEmail);
await vendorMyAccountAuthPage.enterPassword(process.env.USER_PASSWORD);
await vendorMyAccountAuthPage.clickOnLoginButton();
// create shipment
await vendorDashboardSidebarPage.clickOnOrdersTab();
await vendorAllOrdersPage.clickOnOrderById(`${orderId}`);
await vendorEditOrderPage.clickOnCreateNewShipmentButton();
await vendorEditOrderPage.clickOnShipmentItemCheckboxByIndex('1');
await vendorEditOrderPage.selectShippingStatus('Delivered');
await vendorEditOrderPage.selectShippingProvider('Fedex');
await vendorEditOrderPage.enterShippingDate('July 27, 2024');
await vendorEditOrderPage.enterShippingTrackingNumber('#KDJNS93');
await vendorEditOrderPage.clickOnCreateShipmentButton();
// close vendor browser
await vendorBrowser.close();
const customerBrowser = await chromium.launch(browserOptions);
const customerPage = await customerBrowser.newPage();
const customerMyAccountAuthPage = new MyAccountAuthPage(customerPage);
const allMyOrdersPage = new AllMyOrdersPage(customerPage);
const customerOrderDetailsPage = new CustomerOrderDetailsPage(customerPage);
// customer login
await customerPage.goto('/my-account/');
await customerMyAccountAuthPage.enterUsername(customerEmail);
await customerMyAccountAuthPage.enterPassword(process.env.USER_PASSWORD);
await customerMyAccountAuthPage.clickOnLoginButton();
// customer marks order as received
await customerPage.goto('/my-orders/');
await allMyOrdersPage.clickOnViewButtonByOrderId(`${orderId}`);
await customerOrderDetailsPage.markOrderAsReceived('#1');
await customerOrderDetailsPage.clickOnDialogBoxOkButton();
// replace with a more reliable method
await customerOrderDetailsPage.trackingStatusByShipmentNumber('#1').waitFor({ state: 'visible' });
const status = await customerOrderDetailsPage.trackingStatusByShipmentNumber('#1').textContent();
expect(status?.trim()).toEqual('Received');
});

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 13

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9e1d883 and 6a08fdd.

Files selected for processing (12)
  • tests/pw/pages/frontend/my-account/auth/my-account-auth.page.ts (1 hunks)
  • tests/pw/pages/frontend/my-orders/all-my-orders.page.ts (1 hunks)
  • tests/pw/pages/frontend/my-orders/customer-order-details.page.ts (1 hunks)
  • tests/pw/pages/frontend/vendor-dashboard/common/vendor-sidebar.page.ts (1 hunks)
  • tests/pw/pages/frontend/vendor-dashboard/orders/vendor-all-orders.page.ts (1 hunks)
  • tests/pw/pages/frontend/vendor-dashboard/orders/vendor-edit-order.page.ts (1 hunks)
  • tests/pw/pages/wp-admin/common/sidebar.page.ts (1 hunks)
  • tests/pw/pages/wp-admin/dokan/settings/shipping-status.page.ts (1 hunks)
  • tests/pw/pages/wp-admin/products/all-products.page.ts (1 hunks)
  • tests/pw/pages/wp-admin/products/edit-product.page.ts (1 hunks)
  • tests/pw/tests/e2e/shipping-status/mark-order-as-received-01.spec.ts (1 hunks)
  • tests/pw/tests/e2e/shipping-status/mark-order-as-received-02.spec.ts (1 hunks)
Additional context used
Biome
tests/pw/pages/wp-admin/products/edit-product.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/wp-admin/common/sidebar.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/vendor-dashboard/common/vendor-sidebar.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/wp-admin/products/all-products.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/vendor-dashboard/orders/vendor-all-orders.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/my-orders/all-my-orders.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/my-account/auth/my-account-auth.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/my-orders/customer-order-details.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/wp-admin/dokan/settings/shipping-status.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/pages/frontend/vendor-dashboard/orders/vendor-edit-order.page.ts

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

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

tests/pw/tests/e2e/shipping-status/mark-order-as-received-02.spec.ts

[error] 15-15: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

Additional comments not posted (45)
tests/pw/pages/wp-admin/products/edit-product.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for the publish button.


13-15: LGTM!

The method correctly clicks on the publish button.

tests/pw/pages/wp-admin/common/sidebar.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for the sidebar menu item based on the provided title.


13-15: LGTM!

The method correctly clicks on the products link in the sidebar menu.

tests/pw/pages/frontend/vendor-dashboard/common/vendor-sidebar.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for the sidebar menu item based on the provided title.


13-15: LGTM!

The method correctly clicks on the orders tab in the sidebar menu.

tests/pw/pages/wp-admin/products/all-products.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for the product title based on the product ID.


13-15: LGTM!

The method correctly clicks on the product title element based on the product ID.

tests/pw/pages/frontend/vendor-dashboard/orders/vendor-all-orders.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for the order title based on the order ID.


13-15: LGTM!

The method correctly clicks on the order title element based on the order ID.

tests/pw/pages/frontend/my-orders/all-my-orders.page.ts (2)

9-11: LGTM!

The method correctly returns a locator for the view button based on the order ID.


13-15: LGTM!

The method correctly clicks on the view button element based on the order ID.

tests/pw/pages/frontend/my-account/auth/my-account-auth.page.ts (5)

9-11: LGTM!

The method is correctly implemented.


13-15: LGTM!

The method is correctly implemented.


17-19: LGTM!

The method is correctly implemented.


21-23: LGTM!

The method is correctly implemented.


25-31: LGTM!

The methods are correctly implemented.

tests/pw/pages/frontend/my-orders/customer-order-details.page.ts (5)

9-11: LGTM!

The method is correctly implemented.


13-15: LGTM!

The method is correctly implemented.


17-19: LGTM!

The method is correctly implemented.


21-23: LGTM!

The method is correctly implemented.


25-27: LGTM!

The method is correctly implemented.

tests/pw/tests/e2e/shipping-status/mark-order-as-received-01.spec.ts (1)

9-29: LGTM!

The test suite is correctly implemented.

tests/pw/pages/wp-admin/dokan/settings/shipping-status.page.ts (8)

9-11: LGTM!

The method correctly returns the locator for the shipping status tab.


13-15: LGTM!

The method correctly returns the locator for the shipment tracking checkbox.


17-19: LGTM!

The method correctly returns the locator for the mark as received checkbox.


35-37: LGTM!

The method correctly returns the locator for the save changes button.


39-41: LGTM!

The method correctly performs the click action on the shipping status tab.


43-45: LGTM!

The method correctly performs the click action on the shipment tracking checkbox.


47-49: LGTM!

The method correctly performs the click action on the mark as received checkbox.


51-53: LGTM!

The method correctly performs the click action on the save changes button.

tests/pw/pages/frontend/vendor-dashboard/orders/vendor-edit-order.page.ts (14)

9-11: LGTM!

The method correctly returns the locator for the create new shipment button.


13-15: LGTM!

The method correctly returns the locator for the shipment item checkbox based on the provided index.


17-19: LGTM!

The method correctly returns the locator for the shipping status dropdown.


21-23: LGTM!

The method correctly returns the locator for the shipping provider dropdown.


25-27: LGTM!

The method correctly returns the locator for the shipping date field.


29-31: LGTM!

The method correctly returns the locator for the shipping tracking number field.


33-35: LGTM!

The method correctly returns the locator for the create shipment button.


37-39: LGTM!

The method correctly performs the click action on the create new shipment button.


41-43: LGTM!

The method correctly performs the click action on the shipment item checkbox based on the provided index.


45-47: LGTM!

The method correctly performs the selection action in the shipping status dropdown.


49-51: LGTM!

The method correctly performs the selection action in the shipping provider dropdown.


53-55: LGTM!

The method correctly performs the fill action in the shipping date field.


57-59: LGTM!

The method correctly performs the fill action in the shipping tracking number field.


61-63: LGTM!

The method correctly performs the click action on the create shipment button.

Comment on lines +5 to +7
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 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)

Comment on lines +5 to +7
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 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)

Comment on lines +5 to +7
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 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)

Comment on lines +5 to +7
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 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)

Comment on lines +5 to +7
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 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)

Comment on lines +5 to +7
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 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)

Comment on lines +21 to +33
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;
}
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));
}

Comment on lines +5 to +7
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 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)

import { ApiUtils } from '@utils/apiUtils';
import { payloads } from '@utils/payloads';

test.describe.only('Mark Order As Received - 02', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove focus from the test.

The test.describe.only method is used for debugging and should be removed to ensure all tests are executed.

- test.describe.only('Mark Order As Received - 02', () => {
+ test.describe('Mark Order As Received - 02', () => {
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
test.describe.only('Mark Order As Received - 02', () => {
test.describe('Mark Order As Received - 02', () => {
Tools
Biome

[error] 15-15: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

Comment on lines +162 to +164
// temporary solution, will be replaced
await page.waitForTimeout(3000);

Copy link
Contributor

Choose a reason for hiding this comment

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

Replace the temporary solution with a more robust approach.

The use of page.waitForTimeout is a temporary solution and should be replaced with a more robust approach, such as waiting for a specific element or condition.

-  // temporary solution, will be replaced
-  await page.waitForTimeout(3000);
+  // wait for the tracking status to be updated
+  await customerOrderDetailsPage.trackingStatusByShipmentNumber('#1').waitFor({ state: 'visible' });
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
// temporary solution, will be replaced
await page.waitForTimeout(3000);
// wait for the tracking status to be updated
await customerOrderDetailsPage.trackingStatusByShipmentNumber('#1').waitFor({ state: 'visible' });

@shashwatahalder01 shashwatahalder01 added In Progress The issues is being worked on and removed Needs: Dev Review It requires a developer review and approval labels Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Progress The issues is being worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants