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

Add: add product form test(attribute, bulk discount, geolocation) #2395

Merged
merged 7 commits into from
Oct 7, 2024

Conversation

shashwatahalder01
Copy link
Contributor

@shashwatahalder01 shashwatahalder01 commented Oct 7, 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, including adding, removing, and creating terms.
    • Expanded options for bulk discounts and geolocation management for products.
    • New functionalities for shipping and order management for vendors.
    • Added features for customer interactions, including store following and support ticket management.
    • Comprehensive updates for EU compliance management.
  • Bug Fixes

    • Adjusted permissions for admin roles, specifically regarding plugin management.
  • Tests

    • Introduced new test cases for validating vendor functionalities in product management, including attributes, discounts, and geolocation.

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The pull request includes significant modifications to the feature map configuration and the ProductsPage class, focusing on user role permissions and enhancing vendor capabilities. Key changes involve the removal of certain admin plugin permissions, the addition of various vendor functionalities related to product attributes, discounts, and geolocation, as well as the introduction of corresponding tests to ensure these features work as intended.

Changes

File Path Change Summary
tests/pw/feature-map/feature-map.yml Extensive modifications to permissions across user roles, including new vendor capabilities and restrictions on admin functionalities.
tests/pw/pages/productsPage.ts Added methods for managing product attributes, bulk discounts, and geolocation features in the ProductsPage class.
tests/pw/tests/e2e/productsDetails.spec.ts Introduced new test cases for vendor functionalities related to product attributes, discounts, and geolocation management.

Possibly related PRs

Suggested labels

QA approved

Poem

🐇 In the garden of features, new blooms arise,
Vendors now flourish, beneath open skies.
Attributes added, discounts in tow,
A world of permissions, watch them all grow!
With tests in the meadow, ensuring all's right,
Hoppity joy fills the day and the night! 🌼


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
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: 1

🧹 Outside diff range and nitpick comments (6)
tests/pw/tests/e2e/productsDetails.spec.ts (4)

366-371: Approve test, but address TODO comment

The test case for creating a product attribute term is comprehensive, involving multiple steps to set up the test scenario. However, there's a TODO comment suggesting that this test needs refactoring.

Consider addressing the TODO comment by refactoring this test. Perhaps you could extract the attribute and product creation into a separate setup method to improve readability and maintainability.


388-388: Implement test for adding already added attribute

There's a TODO comment about testing the scenario where a vendor attempts to add an already added attribute. This is an important edge case that should be covered in your test suite.

Consider implementing this test case to improve the robustness of your attribute management tests. It will help ensure that the system properly handles duplicate attribute additions.


396-398: Approve test, but consider clarifying method name

The test case for updating product bulk discount options is structurally sound. However, it uses the same addProductBulkDiscountOptions method as the "add" test case.

Consider renaming the addProductBulkDiscountOptions method to setProductBulkDiscountOptions or creating a separate updateProductBulkDiscountOptions method to clearly distinguish between adding and updating operations. This will improve the clarity and maintainability of your tests.


406-416: LGTM: Comprehensive tests for product geolocation, with a suggestion

These test cases effectively cover the CRUD operations for product geolocation. They are well-structured, correctly tagged, and follow the established pattern in the file.

For the update test (lines 410-412), consider renaming the addProductGeolocation method to setProductGeolocation or creating a separate updateProductGeolocation method to clearly distinguish between adding and updating operations. This will improve the clarity and maintainability of your tests.

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

1326-1336: Consider consolidating redundant steps in removeProductAttributeTerm.

After saving the product, clicking on the saved attribute and checking for the term's non-existence (lines 1334-1335) might be redundant since you've already verified it's not visible before saving. You may consider removing these lines to streamline the code.

Apply this diff to remove redundant steps:

- await this.saveProduct();
- await this.click(productsVendor.attribute.savedAttribute(attribute));
- await this.notToBeVisible(productsVendor.attribute.selectedAttributeTerm(attributeTerm));
+ await this.saveProduct();

1351-1356: Consistency in method naming: Update method comment in removeProductBulkDiscountOptions.

The comment above the removeProductBulkDiscountOptions method incorrectly states "// add product discount options". Updating the comment to reflect the correct action improves code readability.

Apply this diff to correct the comment:

- // add product discount options
+ // remove product bulk discount options
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b19b0ea and d7f249f.

📒 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 (11)
tests/pw/tests/e2e/productsDetails.spec.ts (6)

362-364: LGTM: New test for adding product attribute

The test case for adding a product attribute is well-structured and follows the existing pattern in the file. It's correctly tagged and named, which will help in test organization and execution.


373-378: LGTM: Comprehensive test for removing product attribute

This test case effectively covers the removal of a product attribute. It properly sets up the test scenario using API calls and then tests the removal functionality. The test is well-structured and clearly named.


380-386: LGTM: Detailed test for removing product attribute term

This test case thoroughly covers the removal of a specific product attribute term. It sets up a complex scenario with multiple attribute terms and tests the precise removal of one term. The test is well-structured and named appropriately.


392-394: LGTM: New test for adding product bulk discount options

The test case for adding product bulk discount options is well-structured and follows the existing pattern in the file. It's correctly tagged and named, which will help in test organization and execution.


400-402: LGTM: Test for removing product bulk discount options

This test case effectively covers the removal of product bulk discount options, completing the CRUD operations for this feature. It follows the established pattern in the file and is correctly tagged and named.


359-416: Overall assessment: Valuable additions to the test suite

The new tests for product attributes, bulk discount options, and geolocation are well-implemented and significantly enhance the test coverage for these important product features. They follow the established patterns in the file and are correctly tagged for proper categorization.

A few minor suggestions have been made to improve clarity and maintainability:

  1. Address the TODO comment about refactoring the 'vendor can create product attribute term' test.
  2. Implement the missing test case for adding an already added attribute.
  3. Consider renaming some methods to clearly distinguish between add and update operations.

These changes will further improve the robustness and readability of the test suite.

tests/pw/feature-map/feature-map.yml (1)

180-189: Excellent additions to vendor capabilities!

These new permissions significantly enhance the vendor's ability to manage products:

  1. Product attributes management (lines 180-183)
  2. Bulk discount options (lines 184-186)
  3. Product geolocation features (lines 187-189)

These additions align well with the PR objectives and provide vendors with more control over their product listings, potentially improving their ability to create more detailed and attractive product offerings.

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

1316-1323: removeProductAttribute method looks good.

The method correctly removes the specified attribute from the product and ensures it is no longer visible.


1339-1348: addProductBulkDiscountOptions method is well-implemented.

The method correctly adds bulk discount options to the product and verifies the values.


1361-1370: Add verification for location selection in addProductGeolocation.

After entering the location and simulating the arrow down and enter keys, it's important to verify that the intended location is correctly selected. Consider adding a verification step to ensure that the geolocation matches the expected value.

Modify the code to verify the selected location:

await this.press(data.key.enter);
+ await this.toHaveValue(productsVendor.geolocation.productLocation, location);
await this.saveProduct();

1373-1378: removeProductGeolocation method functions correctly.

The method appropriately reverts the geolocation to "same as store" by checking the option and verifying it.

tests/pw/pages/productsPage.ts Show resolved Hide resolved
@shashwatahalder01 shashwatahalder01 added the QA approved This PR is approved by the QA team label Oct 7, 2024
@shashwatahalder01 shashwatahalder01 merged commit d41c6ee into getdokan:develop Oct 7, 2024
2 checks passed
@shashwatahalder01 shashwatahalder01 deleted the productpro6 branch October 8, 2024 04:58
@coderabbitai coderabbitai bot mentioned this pull request Oct 8, 2024
11 tasks
This was referenced Oct 24, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 1, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QA approved This PR is approved by the QA team Test Automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant