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

Commission tests #83

Closed
wants to merge 2 commits into from
Closed

Commission tests #83

wants to merge 2 commits into from

Conversation

shashwatahalder01
Copy link
Owner

@shashwatahalder01 shashwatahalder01 commented Nov 30, 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

Release Notes

  • New Features

    • Enhanced admin and vendor roles with improved order and product management capabilities.
    • Admins can now view sub-orders and commission details on product and order lists.
    • Vendors can view earnings across various pages, including product and order details.
    • Introduced features for managing product reviews and support tickets.
    • Added search functionality for products in the admin interface.
  • Bug Fixes

    • Improved visibility checks for elements in support ticket management.
  • Documentation

    • Updated comments and structure in selector definitions for better clarity.

@shashwatahalder01 shashwatahalder01 added the enhancement New feature or request label Nov 30, 2024
@shashwatahalder01 shashwatahalder01 self-assigned this Nov 30, 2024
Copy link

coderabbitai bot commented Nov 30, 2024

Walkthrough

The pull request introduces significant enhancements to the feature-map.yml file, expanding permissions for admin and vendor roles across various functionalities, particularly in managing orders, products, and vendor interactions. Key updates include new methods and selectors in the CommissionPage class, improved visibility checks in the ProductsPage, and the addition of multi-vendor order handling in the ApiUtils class. The test suite has also been updated to reflect these changes, ensuring comprehensive coverage of the new features.

Changes

File Path Change Summary
tests/pw/feature-map/feature-map.yml Added multiple features for admin and vendor roles in the Commission, Catalog Mode, Privacy Policy, Product Reviews, Store Support, and Vendor Subscription sections.
tests/pw/pages/basePage.ts Updated multipleElementVisible method to enhance type safety and handle complex selector structures.
tests/pw/pages/commissionPage.ts Added new methods for viewing sub-orders, related orders, and commission details for both admin and vendors.
tests/pw/pages/productsPage.ts Introduced adminSearchProduct method for searching products in the admin interface; improved visibility checks in vendor product creation.
tests/pw/pages/selectors.ts Added new selectors for order commission, sub-orders, and refined product selectors with a new menus object.
tests/pw/pages/storeSupportsPage.ts Modified visibility check in vendorViewSupportTicketDetails method for better accuracy.
tests/pw/tests/e2e/commission.spec.ts Enhanced test coverage for vendor-related commission views and updated setup for vendor instance.
tests/pw/utils/apiUtils.ts Added createMultivendorOrder and createLineItemsEnhanced methods to facilitate multi-vendor order creation.
tests/pw/utils/payloads.ts Introduced VENDOR2_ID constant and createMultiVendorOrder function for handling multi-vendor orders.

Possibly related PRs

Suggested labels

approved

Poem

In fields of code, we hop and play,
With features bright, we pave the way.
Admins and vendors, side by side,
Managing orders with newfound pride.
So here’s to changes, big and small,
A leap for all, let’s code and sprawl! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

Copy link

@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: 6

🧹 Outside diff range and nitpick comments (8)
tests/pw/pages/storeSupportsPage.ts (1)

229-232: Consider adding error handling for visibility checks.

The visibility checks could benefit from try-catch blocks to handle cases where elements might not be present as expected, improving test reliability.

-            await this.toBeVisible(closeTicketText);
+            try {
+                await this.toBeVisible(closeTicketText);
+            } catch (error) {
+                console.error(`Failed to verify closeTicketText visibility: ${error.message}`);
+                throw error;
+            }
tests/pw/tests/e2e/commission.spec.ts (1)

Line range hint 82-89: Implement createDokanSubscriptionProduct function to enable subscription product tests

The tests for setting commission to Dokan subscription products are currently skipped because the createDokanSubscriptionProduct function is not implemented. Implementing this function will enable these tests to run and ensure proper coverage.

Would you like assistance in implementing the createDokanSubscriptionProduct function, or should we open a new GitHub issue to track this task?

tests/pw/pages/commissionPage.ts (1)

283-283: Avoid directly removing the class attribute to handle flakiness

Using removeAttribute to force row actions to be visible may lead to unintended side effects. Consider using more robust methods, such as ensuring the element is visible with explicit waits or adjusting the hover actions to prevent flakiness.

tests/pw/utils/apiUtils.ts (1)

2070-2070: Address the TODO: Replace createLineItems with createLineItemsEnhanced

The TODO comment indicates that createLineItems should be replaced with createLineItemsEnhanced, and the tests need updating. Completing this task will help remove deprecated code and ensure consistency.

Would you like assistance in updating the tests and refactoring the code to use createLineItemsEnhanced?

tests/pw/utils/payloads.ts (1)

403-403: Consider uncommenting post_author if product author assignment is needed

The post_author field is commented out in the product creation payload. If assigning the product to a specific author is required for your tests, please uncomment and set this field accordingly.

Apply this diff if necessary:

-// post_author: '',
+post_author: VENDOR_ID,
tests/pw/pages/productsPage.ts (3)

20-26: Add JSDoc documentation for the new method.

The adminSearchProduct method implementation looks good, but would benefit from JSDoc documentation describing its purpose, parameters, and return type.

+/**
+ * Searches for a product in the admin interface
+ * @param productName - The name of the product to search for
+ * @returns Promise<void>
+ */
 async adminSearchProduct(productName: string) {

313-313: Add error handling for earning element visibility check.

Consider adding a try-catch block to handle cases where the earning element might not be present, especially since this is a vendor-specific feature.

-        await this.toBeVisible(productsVendor.earning);
+        try {
+            await this.toBeVisible(productsVendor.earning);
+        } catch (error) {
+            console.warn('Earning element not visible for vendor:', error);
+            // Handle appropriately based on business requirements
+        }

Line range hint 1-1106: Consider breaking down the ProductsPage class into smaller, focused classes.

The ProductsPage class has grown quite large and handles both admin and vendor functionalities. Consider splitting it into separate classes like AdminProductsPage and VendorProductsPage for better maintainability and separation of concerns.

Address TODO comments in the codebase.

There are several TODO comments throughout the code that need attention:

  • Line 4: "TODO: Add tests"
  • Line 391: "todo: need a check for germanized plugin"
  • Line 573: "todo: add more assertions"
  • Line 595: "todo: add more assertions"
  • Line 617: "todo: add more assertions"

Would you like me to help create GitHub issues to track these TODOs or provide implementations for any of these missing pieces?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f6b2f86 and d694935.

📒 Files selected for processing (9)
  • tests/pw/feature-map/feature-map.yml (1 hunks)
  • tests/pw/pages/basePage.ts (3 hunks)
  • tests/pw/pages/commissionPage.ts (2 hunks)
  • tests/pw/pages/productsPage.ts (2 hunks)
  • tests/pw/pages/selectors.ts (6 hunks)
  • tests/pw/pages/storeSupportsPage.ts (1 hunks)
  • tests/pw/tests/e2e/commission.spec.ts (4 hunks)
  • tests/pw/utils/apiUtils.ts (3 hunks)
  • tests/pw/utils/payloads.ts (3 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
tests/pw/pages/basePage.ts

[error] 1434-1435: Unnecessary continue statement

Unsafe fix: Delete the unnecessary continue statement

(lint/correctness/noUnnecessaryContinue)

🔇 Additional comments (8)
tests/pw/pages/storeSupportsPage.ts (1)

230-230: LGTM! Correct usage of visibility check method.

The change from multipleElementVisible to toBeVisible is appropriate since closeTicketText is a single element selector.

tests/pw/utils/payloads.ts (1)

1957-2006: Ensure environment variables for product IDs are properly set

In the createMultiVendorOrder payload, PRODUCT_ID and PRODUCT_ID_V2 are used. If these environment variables are undefined, the product IDs will be empty strings, which can cause order creation to fail.

Run the following script to verify that PRODUCT_ID and PRODUCT_ID_V2 are defined and valid numbers:

tests/pw/pages/selectors.ts (6)

2981-2983: Looks good!

The commissionColumn selector for the orders table has been added correctly.


2991-2997: LGTM!

The table column selectors for the commission meta box have been added correctly under the table object.


3034-3045: Looks good!

The menus object has been added correctly under the products object to encapsulate the product-related menu selectors.


3053-3058: Verify the usage of the new selectors in the codebase.

The commissionColumn, firstRowProductCommission, and earningColumn selectors have been added correctly for the products table. However, ensure that these selectors are being used appropriately in the relevant test files to retrieve the commission and earning data for products.

Run the following script to verify the usage of these selectors:

✅ Verification successful

Based on the search results, I can generate the final response as I have sufficient information about the usage of these selectors in the codebase.

The selectors are properly used in the test files

The selectors are being used appropriately in tests/pw/pages/commissionPage.ts:

  • commissionColumn is used in both product and order list views
  • firstRowProductCommission is used to verify commission data in the products table
  • earningColumn is used in vendor-specific views for products and orders
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `commissionColumn`, `firstRowProductCommission`, and `earningColumn` selectors.

# Test: Search for the selector usage. Expect: At least one occurrence of each selector.
rg -A 5 $'commissionColumn|firstRowProductCommission|earningColumn' tests/

Length of output: 6141


2985-2987: Verify the usage of the new selectors in the codebase.

The firstRow and firstRowOrderCommission selectors have been added correctly. However, ensure that these selectors are being used appropriately in the relevant test files to retrieve the first order row and its commission value.

Run the following script to verify the usage of these selectors:

✅ Verification successful

The selectors are being used appropriately in the codebase

The verification shows that both selectors are part of a well-structured selectors object and are being used correctly:

  • firstRowOrderCommission is used in commissionPage.ts within the viewCommissionOnOrderList() method to verify commission visibility
  • firstRow is consistently used across different contexts (admin/vendor) for accessing first row elements in tables
  • The selectors follow the same XPath pattern as other similar selectors in the codebase
  • They are used in conjunction with page object methods like toBeVisible() for proper test assertions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `firstRow` and `firstRowOrderCommission` selectors.

# Test: Search for the selector usage. Expect: At least one occurrence of each selector.
rg -A 5 $'firstRow|firstRowOrderCommission' tests/

Length of output: 6259


3001-3014: Verify the usage of the new selectors in the codebase.

The subOrdersMetaBox object and its child selectors have been added correctly. However, ensure that these selectors are being used appropriately in the relevant test files to interact with the sub-orders meta box and retrieve its data.

Run the following script to verify the usage of these selectors:

✅ Verification successful

Let me generate another script to verify how these selectors are being used in the test files:

This will help us understand:

  1. The context in which subOrdersMetaBox is being used in tests
  2. If there are any other usages of the sub-orders related selectors that we should be aware of

Let me generate one final script to check if there are any test cases that actually use the viewSubOrdersMetaBox method:

This will help us confirm if the selectors are being used in actual test scenarios.


Selectors are properly integrated and used in test scenarios

The subOrdersMetaBox selectors are correctly integrated into the test framework and actively used in:

  • A dedicated test case that verifies sub-orders meta-box visibility on parent order details
  • The viewSubOrdersMetaBox method in commissionPage.ts that uses these selectors to verify the presence of meta-box elements
  • Part of a comprehensive test suite alongside related features (commission meta-box, related orders meta-box)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash 
# Description: Verify the usage of `subOrdersMetaBox` selectors.

# Test: Search for the selector usage. Expect: At least one occurrence of the main selector.
rg -A 10 $'subOrdersMetaBox' tests/

Length of output: 2025


Script:

#!/bin/bash
# Search for test files that use the multipleElementVisible method with subOrdersMetaBox
rg -B 5 -A 10 "multipleElementVisible.*subOrdersMetaBox" tests/

# Search for any other usage of individual selectors within subOrdersMetaBox
rg "dokan_sub_or_related_orders" tests/

Length of output: 3380


Script:

#!/bin/bash
# Search for test files that use viewSubOrdersMetaBox method
rg -B 5 -A 10 "viewSubOrdersMetaBox" tests/

Length of output: 2675

Comment on lines +351 to +359
admin can view sub orders meta-box on parent order details [lite]: true
admin can view related orders meta-box on child order details [lite]: true
admin can view commission on product list [lite]: true
admin can view commission on order list [lite]: true
vendor can view earning on product list [lite]: true
vendor can view earning on product add page [lite]: true
vendor can view earning on product edit page [lite]: true
vendor can view earning on order list [lite]: true
vendor can view earning on order details [lite]: true
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Correct the grouping of 'vendor' features under the appropriate role

The vendor features added in lines 355-359 are currently placed under the admin role within the Commission page. To maintain consistency and clarity, these features should be grouped under the vendor role, similar to other sections in the file.

Apply this diff to adjust the grouping:

   admin can set commission to Dokan subscription product (specific category based) [lite]: true
   admin can view commission meta-box on order details [lite]: true
   admin can view commission on product list [lite]: true
+vendor:
+  vendor can view earning on product list [lite]: true
+  vendor can view earning on product add page [lite]: true
+  vendor can view earning on product edit page [lite]: true
+  vendor can view earning on order list [lite]: true
+  vendor can view earning on order details [lite]: true

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +2083 to +2103
// create multivendor line items
async createLineItemsEnhanced(multivendorLineItem: { author: string; products: string | string[]; quantities: string | string[] }[]) {
const lineItems = [];
for (const item of multivendorLineItem) {
const { author, products, quantities } = item;

// Validate lengths only if both `products` and `quantities` are arrays
if (Array.isArray(products) && Array.isArray(quantities) && products.length !== quantities.length) {
throw new Error('products and quantities must be the same length');
}

const quantitiesArray = Array.isArray(quantities) ? quantities : [quantities];
const length = Array.isArray(products) ? products.length : Number(item.products);
for (let i = 0; i < length; i++) {
const productId = Array.isArray(products) ? products[i] : (await this.createProduct({ ...payloads.createProduct(), post_author: author }, payloads.adminAuth))[1];
const quantity = quantitiesArray[i % quantitiesArray.length];
lineItems.push({ product_id: productId, quantity: quantity });
}
}
return lineItems;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Validate inputs in createLineItemsEnhanced to prevent errors

  • Issue with length calculation: The length variable may become NaN if item.products is not a valid number when products is not an array. This can cause unexpected behavior in the loop starting at line 2096.

  • Potential undefined behavior: If quantities is not properly formatted, using quantitiesArray[i % quantitiesArray.length] may result in incorrect quantities or errors.

Apply this diff to improve input validation:

 const quantitiesArray = Array.isArray(quantities) ? quantities : [quantities];
 const length = Array.isArray(products) ? products.length : Number(item.products);
+if (isNaN(length) || length <= 0) {
+    throw new Error(`Invalid number of products specified: ${item.products}`);
+}
+if (!Array.isArray(quantitiesArray) || quantitiesArray.length === 0) {
+    throw new Error(`Quantities must be a non-empty array or a valid number`);
+}
 for (let i = 0; i < length; i++) {
     const productId = Array.isArray(products)
         ? products[i]
         : (await this.createProduct({ ...payloads.createProduct(), post_author: author }, payloads.adminAuth))[1];
     const quantity = quantitiesArray[i % quantitiesArray.length];
     lineItems.push({ product_id: productId, quantity: quantity });
 }
📝 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
// create multivendor line items
async createLineItemsEnhanced(multivendorLineItem: { author: string; products: string | string[]; quantities: string | string[] }[]) {
const lineItems = [];
for (const item of multivendorLineItem) {
const { author, products, quantities } = item;
// Validate lengths only if both `products` and `quantities` are arrays
if (Array.isArray(products) && Array.isArray(quantities) && products.length !== quantities.length) {
throw new Error('products and quantities must be the same length');
}
const quantitiesArray = Array.isArray(quantities) ? quantities : [quantities];
const length = Array.isArray(products) ? products.length : Number(item.products);
for (let i = 0; i < length; i++) {
const productId = Array.isArray(products) ? products[i] : (await this.createProduct({ ...payloads.createProduct(), post_author: author }, payloads.adminAuth))[1];
const quantity = quantitiesArray[i % quantitiesArray.length];
lineItems.push({ product_id: productId, quantity: quantity });
}
}
return lineItems;
}
// create multivendor line items
async createLineItemsEnhanced(multivendorLineItem: { author: string; products: string | string[]; quantities: string | string[] }[]) {
const lineItems = [];
for (const item of multivendorLineItem) {
const { author, products, quantities } = item;
// Validate lengths only if both `products` and `quantities` are arrays
if (Array.isArray(products) && Array.isArray(quantities) && products.length !== quantities.length) {
throw new Error('products and quantities must be the same length');
}
const quantitiesArray = Array.isArray(quantities) ? quantities : [quantities];
const length = Array.isArray(products) ? products.length : Number(item.products);
if (isNaN(length) || length <= 0) {
throw new Error(`Invalid number of products specified: ${item.products}`);
}
if (!Array.isArray(quantitiesArray) || quantitiesArray.length === 0) {
throw new Error(`Quantities must be a non-empty array or a valid number`);
}
for (let i = 0; i < length; i++) {
const productId = Array.isArray(products) ? products[i] : (await this.createProduct({ ...payloads.createProduct(), post_author: author }, payloads.adminAuth))[1];
const quantity = quantitiesArray[i % quantitiesArray.length];
lineItems.push({ product_id: productId, quantity: quantity });
}
}
return lineItems;
}

Comment on lines +2008 to +2019
multivendorLineItems: [
{
author: VENDOR_ID,
products: '3', // product Ids
quantities: '1',
},
{
author: VENDOR2_ID,
products: '3', // product Ids
quantities: '1',
},
],
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Replace hardcoded product IDs and quantities with dynamic values

The products and quantities fields in multivendorLineItems are hardcoded as strings '3' and '1'. This may lead to issues if the product IDs do not exist or if multiple instances require different products. Use dynamic values or retrieve actual product IDs to enhance flexibility and reliability.

Apply this diff to use dynamic product IDs:

 multivendorLineItems: [
     {
         author: VENDOR_ID,
-        products: '3', // product Ids
-        quantities: '1',
+        products: [PRODUCT_ID],
+        quantities: [1],
     },
     {
         author: VENDOR2_ID,
-        products: '3', // product Ids
-        quantities: '1',
+        products: [PRODUCT_ID_V2],
+        quantities: [1],
     },
 ],

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +3016 to +3030
relatedOrdersMetaBox: {
metaBoxDiv: 'div#dokan_sub_or_related_orders',
relatedOrdersText: '//h2[normalize-space()="Related orders"]',
relatedOrdersItemInfo: 'div#dokan_sub_or_related_orders div#woocommerce-order-items',
table: {
orderColumn: '//div[@id="dokan_sub_or_related_orders"]//th[normalize-space()="Order"]',
dateColumn: '//div[@id="dokan_sub_or_related_orders"]//th[normalize-space()="Date"]',
statusColumn: '//div[@id="dokan_sub_or_related_orders"]//th[normalize-space()="Status"]',
totalColumn: '//div[@id="dokan_sub_or_related_orders"]//th[normalize-space()="Total"]',
vendorColumn: '//div[@id="dokan_sub_or_related_orders"]//th[normalize-space()="Vendor"]',
},
relatedOrderTable: 'div#dokan_sub_or_related_orders table.woocommerce_order_items',
parentOrderRow: '//td[contains(.,"(Parent order)")]/..',
parentOrderVendor: '//td[contains(.,"(Parent order)")]/..//td[contains(.,"(no name)")]/..',
},
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

The selectors are only partially utilized in the test implementation

The verification reveals that while the relatedOrdersMetaBox selector object is defined with detailed child selectors, only a basic visibility check is implemented in commissionPage.ts. The child selectors (parentOrderRow, parentOrderVendor, relatedOrderTable, etc.) are not being used in any test cases, suggesting incomplete test coverage for the related orders functionality.

  • tests/pw/pages/commissionPage.ts: Only checks for the visibility of the meta box without validating individual components
  • Missing test coverage for:
    • Related orders table columns
    • Parent order row identification
    • Vendor information verification
    • Table structure validation
🔗 Analysis chain

Verify the usage of the new selectors in the codebase.

The relatedOrdersMetaBox object and its child selectors have been added correctly. However, ensure that these selectors are being used appropriately in the relevant test files to interact with the related orders meta box and retrieve its data.

Run the following script to verify the usage of these selectors:


Let me search for more specific usage of the child selectors to ensure they are being properly utilized.


Let me check for any test files that might be using these selectors in test cases.


Let me try one final search to look for any test implementations that might be using these selectors, even if they're not in .spec or .test files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `relatedOrdersMetaBox` selectors. 

# Test: Search for the selector usage. Expect: At least one occurrence of the main selector.
rg -A 10 $'relatedOrdersMetaBox' tests/

Length of output: 2096


Script:

#!/bin/bash
# Search for usage of specific child selectors of relatedOrdersMetaBox
rg "parentOrderRow|parentOrderVendor|relatedOrderTable|metaBoxDiv" tests/

Length of output: 730


Script:

#!/bin/bash
# Search for test files that might be using these related order selectors
rg -g "*.spec.ts" -g "*.test.ts" "dokan_sub_or_related_orders|Related orders" tests/

Length of output: 86


Script:

#!/bin/bash
# Search for any test implementations using the related orders meta box
rg -g "*.ts" "multipleElementVisible.*relatedOrdersMetaBox|elementVisible.*relatedOrdersMetaBox|click.*relatedOrdersMetaBox|expect.*relatedOrdersMetaBox" tests/

Length of output: 294

@shashwatahalder01 shashwatahalder01 deleted the commissionenhance branch December 7, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant