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

Productpro3 #59

Merged
merged 7 commits into from
Oct 7, 2024
Merged

Productpro3 #59

merged 7 commits into from
Oct 7, 2024

Conversation

shashwatahalder01
Copy link
Owner

@shashwatahalder01 shashwatahalder01 commented Oct 5, 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

    • Enhanced vendor capabilities for managing product attributes, bulk discounts, geolocation, and wholesale options.
    • Admin can now manage tax settings and vendor subscriptions more effectively.
    • Vendors can manage auction products and product reviews.
    • New features for managing EU compliance data and support tickets.
  • Bug Fixes

    • Removed unnecessary admin functionalities related to the Dokan plugin.
  • Tests

    • Added comprehensive tests for managing product attributes, bulk discounts, and geolocation features for vendors.

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

coderabbitai bot commented Oct 5, 2024

Walkthrough

The pull request introduces extensive modifications to feature permissions for different user roles, particularly focusing on enhancing vendor capabilities while limiting certain admin functionalities. Key changes include adjustments to permissions across various pages such as products, orders, and payments, with new methods added to the ProductsPage class for managing product attributes, bulk discounts, geolocation, and wholesale options. Additionally, new test cases were introduced to ensure the proper functionality of these enhancements for vendors.

Changes

File Path Change Summary
tests/pw/feature-map/feature-map.yml Updated feature permissions for admin and vendor roles across multiple pages, including removal and addition of capabilities.
tests/pw/pages/productsPage.ts Added new methods for managing product attributes, bulk discounts, geolocation, and wholesale options.
tests/pw/tests/e2e/productsDetails.spec.ts Introduced new test cases for managing product attributes, bulk discounts, and geolocation by vendors.

Possibly related PRs

Suggested labels

approved

Poem

🐇 In the meadow where vendors play,
New powers bloom, bright as day.
Attributes added, discounts galore,
Managing products, oh what a score!
With features enhanced, they leap and bound,
In the world of commerce, joy is found! 🌼


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 (10)
tests/pw/feature-map/feature-map.yml (6)

184-186: Enhanced pricing capabilities with bulk discount options

The addition of bulk discount features empowers vendors to create more sophisticated pricing strategies, potentially increasing sales and customer satisfaction. This is a valuable tool for vendors to manage promotions and incentivize larger purchases.

Consider adding a feature to allow vendors to schedule bulk discounts for specific time periods, enhancing their ability to run time-limited promotions.


187-189: New geolocation features for individual products

The addition of geolocation features for individual products can greatly enhance the shopping experience by allowing customers to find locally relevant items. However, there are two important considerations:

  1. Privacy: Ensure that the use of geolocation data complies with relevant privacy regulations and that customers are informed about how this data is used.

  2. Vendor Usability: Managing geolocation on an individual product basis might be time-consuming for vendors with large inventories.

Consider implementing the following enhancements:

  1. Add clear privacy notices and consent mechanisms for geolocation data usage.
  2. Develop a bulk geolocation management feature to improve efficiency for vendors with many products.
  3. Implement geolocation inheritance from store settings to reduce manual work for vendors.

Line range hint 590-591: New seller badge management features for admins

The addition of seller badge management features empowers admins to recognize and incentivize high-performing vendors. This can lead to improved marketplace quality and vendor motivation.

Consider implementing the following enhancements to the seller badge system:

  1. Add automated badge assignment based on predefined criteria (e.g., sales volume, customer ratings).
  2. Implement a notification system to inform vendors when they earn new badges.
  3. Create a public page showcasing top badge holders to incentivize vendor performance.

Line range hint 679-680: New product cloning features for vendors

The addition of product cloning capabilities can greatly enhance vendor efficiency, especially when listing multiple similar products. This feature can save time and reduce errors in product creation.

To further improve this feature, consider implementing the following:

  1. Ensure that unique identifiers (SKUs, etc.) are automatically generated or prompted for change during the cloning process.
  2. Add an option for vendors to choose which product attributes to clone and which to input manually.
  3. Implement a "cloned from" metadata field to help vendors track the origin of cloned products.

Line range hint 914-914: New wholesale product creation capability for vendors

The addition of wholesale product creation for vendors is a significant enhancement that can expand the marketplace's reach to business customers. This feature can potentially increase transaction volumes and attract a new segment of buyers.

When implementing this feature, consider the following aspects:

  1. Ensure clear separation and visibility controls between wholesale and retail prices.
  2. Implement minimum order quantities or values for wholesale purchases.
  3. Develop a robust user role system to properly identify and verify wholesale customers.
  4. Create guidelines for vendors on setting wholesale prices to maintain marketplace integrity.

Line range hint 922-936: Comprehensive WooCommerce Booking Integration features

The addition of booking capabilities is a major enhancement to the marketplace, allowing for the sale of services and time-dependent products. This feature set covers all necessary aspects for admins, vendors, and customers to effectively manage and use a booking system.

When implementing the booking system, consider the following crucial aspects:

  1. Develop a robust conflict resolution system to prevent double-bookings.
  2. Implement flexible cancellation and refund policies that can be customized by vendors.
  3. Create a notification system for booking reminders, changes, and cancellations.
  4. Ensure the booking calendar has adequate performance optimizations to handle a large number of bookings and availability checks.
  5. Implement a review system specific to bookable products/services.
  6. Consider adding features for recurring bookings and group bookings to enhance system capabilities.
tests/pw/tests/e2e/productsDetails.spec.ts (2)

366-366: Address the TODO comment for refactoring tests

The // todo: refactor below tests comment indicates that the following tests need refactoring. Maintaining clean and organized test code enhances readability and maintainability.

Would you like assistance in refactoring these tests, or should we create a GitHub issue to track this task?


388-388: Implement the missing test for adding an already added attribute

The // todo: vendor cant add already added attribute comment suggests a missing test case. Adding this test will increase the robustness of the test suite by ensuring that duplicate attributes cannot be added.

Would you like assistance in writing this test, or should we open a GitHub issue to track this enhancement?

tests/pw/pages/productsPage.ts (2)

1318-1322: Remove Redundant Visibility Check Before Saving

In the removeProductAttribute method, the check await this.notToBeVisible(productsVendor.attribute.savedAttribute(attribute)); is performed both before and after saving the product. The first check before saving might be redundant since the attribute might still be visible until the changes are saved. Consider removing the first check to streamline the method.


1350-1351: Update Method Comment to Reflect Functionality

The comment above removeProductBulkDiscountOptions incorrectly states "// add product discount options". It should be updated to accurately reflect that the method removes bulk discount options.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b2ce2cc and 0d21383.

📒 Files selected for processing (3)
  • tests/pw/feature-map/feature-map.yml (1 hunks)
  • tests/pw/pages/productsPage.ts (1 hunks)
  • tests/pw/tests/e2e/productsDetails.spec.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (8)
tests/pw/feature-map/feature-map.yml (1)

180-183: Expanded vendor capabilities for product attributes management

These new features significantly enhance the vendor's ability to manage product attributes, allowing for more detailed and flexible product listings. This improvement can lead to better product categorization and search functionality, ultimately benefiting both vendors and customers.

tests/pw/tests/e2e/productsDetails.spec.ts (7)

362-364: Well-implemented test for adding product attributes

The test effectively verifies that a vendor can add a product attribute, enhancing the test coverage for product attribute functionality.


392-394: Good addition of test for adding bulk discount options

The test correctly verifies that a vendor can add bulk discount options to a product, enhancing coverage for discount functionality.


396-398: Effective test for updating bulk discount options

This test ensures that vendors can update existing bulk discount options, which is essential for maintaining accurate product pricing.


400-402: Well-implemented test for removing bulk discount options

The test validates that a vendor can remove bulk discount options from a product, ensuring the functionality works as expected.


406-408: Addition of test for adding product geolocation

The test effectively verifies that a vendor can add geolocation data to a product, which is important for location-specific functionalities.


410-412: Test for updating product geolocation is appropriate

This test confirms that a vendor can update the geolocation information of a product, ensuring that location updates are handled correctly.


414-416: Correctly implemented test for removing product geolocation

The test ensures that a vendor can remove geolocation data from a product, which is vital for maintaining accurate product information.

Comment on lines +367 to +371
test('vendor can create product attribute term', { tag: ['@pro', '@vendor'] }, async () => {
const [, , , attributeName] = await apiUtils.createAttributeTerm(payloads.createAttribute(), payloads.createAttributeTerm(), payloads.adminAuth);
const [, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth);
await vendor.addProductAttribute(productName, { ...data.product.productInfo.attribute, attributeName: attributeName }, 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

Improve destructuring assignments for better readability

The destructuring assignments in lines 368 and 369 use multiple commas to skip elements, which can reduce code clarity. Consider returning objects from the createAttributeTerm and createProduct functions or using named variables in the destructuring to enhance readability.

For example, you could modify the destructuring as follows:

const { attributeName } = await apiUtils.createAttributeTerm(...);
const { productName } = await apiUtils.createProduct(...);

This approach improves code clarity and makes it easier to understand which variables are being used.

Comment on lines +373 to +378
test('vendor can remove product attribute', { tag: ['@pro', '@vendor'] }, async () => {
const [, attributeId, , attributeName, attributeTerm] = await apiUtils.createAttributeTerm(payloads.createAttribute(), payloads.createAttributeTerm(), payloads.adminAuth);
const attributes = { id: attributeId, name: attributeName, options: [attributeTerm] };
const [, , productName] = await apiUtils.createProduct({ ...payloads.createProduct(), attributes: [attributes] }, payloads.vendorAuth);
await vendor.removeProductAttribute(productName, attributeName);
});
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor to eliminate code duplication in test setup

The setup code in this test is similar to previous tests involving the creation of attributes and products. Extracting common setup logic into helper functions can reduce duplication and improve maintainability.

Consider creating helper functions like createAttributeWithTerm and createProductWithAttributes to encapsulate the repeated code.

Comment on lines +380 to +386
test('vendor can remove product attribute term', { tag: ['@pro', '@vendor'] }, async () => {
const [, attributeId, , attributeName, attributeTerm] = await apiUtils.createAttributeTerm(payloads.createAttribute(), payloads.createAttributeTerm(), payloads.adminAuth);
const [, , , , attributeTerm2] = await apiUtils.createAttributeTerm(payloads.createAttribute(), payloads.createAttributeTerm(), payloads.adminAuth);
const attributes = { id: attributeId, name: attributeName, options: [attributeTerm, attributeTerm2] };
const [, , productName] = await apiUtils.createProduct({ ...payloads.createProduct(), attributes: [attributes] }, payloads.vendorAuth);
await vendor.removeProductAttributeTerm(productName, attributeName, attributeTerm2);
});
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance variable naming and reduce repetition

The repeated use of destructuring with unnamed variables can affect code comprehension. Using meaningful variable names and refactoring repeated code can enhance readability.

Modify the destructuring to use named variables:

const { attributeId, attributeName, attributeTerm } = await apiUtils.createAttributeTerm(...);
const { attributeTerm: attributeTerm2 } = await apiUtils.createAttributeTerm(...);

This approach makes it clear which variables are being assigned and their purpose.

Comment on lines +1296 to +1313
// add product attribute
async addProductAttribute(productName: string, attribute: product['productInfo']['attribute'], addTerm: boolean = false): Promise<void> {
await this.goToProductEdit(productName);
await this.selectByLabel(productsVendor.attribute.customAttribute, attribute.attributeName);
await this.clickAndWaitForResponse(data.subUrls.ajax, productsVendor.attribute.addAttribute);
await this.check(productsVendor.attribute.visibleOnTheProductPage);
await this.click(productsVendor.attribute.selectAll);
await this.notToHaveCount(productsVendor.attribute.attributeTerms, 0);
if (addTerm) {
await this.click(productsVendor.attribute.addNew);
await this.clearAndType(productsVendor.attribute.attributeTermInput, attribute.attributeTerm);
await this.clickAndWaitForResponse(data.subUrls.ajax, productsVendor.attribute.confirmAddAttributeTerm);
await this.toBeVisible(productsVendor.attribute.selectedAttributeTerm(attribute.attributeTerm));
}
await this.clickAndWaitForResponse(data.subUrls.ajax, productsVendor.attribute.saveAttribute);
await this.saveProduct();
await this.toBeVisible(productsVendor.attribute.savedAttribute(attribute.attributeName));
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure Proper Error Handling When Adding Product Attributes

In the addProductAttribute method, consider adding error handling to handle cases where the attribute selection fails or the attribute term addition fails. This will enhance user feedback and improve robustness.

Comment on lines +1342 to +1343
await this.clearAndType(productsVendor.bulkDiscount.lotMinimumQuantity, quantityDiscount.minimumQuantity);
await this.clearAndType(productsVendor.bulkDiscount.lotDiscountInPercentage, quantityDiscount.discountPercentage);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add Validation for Discount Percentage Input

In the addProductBulkDiscountOptions method, consider adding validation to ensure that quantityDiscount.discountPercentage is within an acceptable range (e.g., 0 to 100). This will prevent invalid discount values and enhance data integrity.

Comment on lines +1363 to +1366
await this.uncheck(productsVendor.geolocation.sameAsStore);
await this.typeAndWaitForResponse(data.subUrls.gmap, productsVendor.geolocation.productLocation, location);
await this.press(data.key.arrowDown);
await this.press(data.key.enter);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add Error Handling for Geolocation Input

In the addProductGeolocation method, consider adding error handling to manage situations where the geolocation API fails or returns invalid results. This will improve the robustness of the method and provide better user feedback.

@shashwatahalder01 shashwatahalder01 changed the base branch from develop to develop_rk October 7, 2024 10:42
@shashwatahalder01 shashwatahalder01 merged commit 5a05f1b into develop_rk Oct 7, 2024
1 check passed
@shashwatahalder01 shashwatahalder01 deleted the productpro3 branch October 8, 2024 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant