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 tests( shipping, tax, linked products) #2393

Merged
merged 8 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

Release Notes

  • New Features

    • Vendors can now add, update, and remove product shipping and tax details on the Products page.
    • Enhanced management of linked products (up-sells and cross-sells) for vendors.
    • New features for managing product add-ons, inquiries, and reviews have been introduced.
    • Improved vendor subscription management, including non-recurring subscription packs.
    • Expanded EU Compliance Fields for detailed compliance management.
  • Bug Fixes

    • Enhanced login process for backend users to ensure robust navigation and response handling.
  • Tests

    • New test cases added for shipping, tax, and linked product functionalities.
    • Updates to vendor settings tests, with some tests temporarily skipped.

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The changes in this pull request introduce significant enhancements to the vendor management features within the application. Key updates include the ability for vendors to manage product shipping, tax details, and linked products on the "Products" page. Additional features for vendor subscriptions and store support are also included. Furthermore, modifications to the login process and various test cases have been implemented to ensure comprehensive testing of these new functionalities.

Changes

File Path Change Summary
tests/pw/feature-map/feature-map.yml Added features for vendors to manage product shipping, tax, linked products, and subscription options.
tests/pw/pages/loginPage.ts Updated loginBackend method to improve navigation and response handling post-login.
tests/pw/pages/productsPage.ts Added methods for adding/removing product shipping, tax, and linked products; renamed parameter for clarity.
tests/pw/tests/e2e/productsDetails.spec.ts Added tests for shipping, tax, and linked products management functionalities for vendors.
tests/pw/tests/e2e/vendorSettings.spec.ts Added new test cases, modified existing ones, and skipped certain tests related to vendor settings.

Possibly related PRs

Suggested labels

QA approved

Suggested reviewers

  • mrabbani

Poem

🐰 In the meadow where vendors play,
New features bloom, bright as the day.
With shipping and tax, they leap with glee,
Managing products, as easy as can be!
A hop, a skip, through settings they go,
Enhancing their stores, putting on a show! 🌼


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

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

49-54: Summary of changes to loginBackend method

The modifications to the loginBackend method appear to be positive improvements:

  1. Enhanced page loading reliability with gotoUntilNetworkidle.
  2. Updated redirection expectations after login.
  3. Increased flexibility by removing the hardcoded status code.

These changes should lead to more robust and maintainable tests. However, please ensure that:

  1. The new redirection behavior (to admin dashboard) is consistent with the actual application behavior.
  2. Other test files are updated if they rely on the previous login behavior.
  3. The removal of the hardcoded status code doesn't introduce any regressions in error handling.

Consider adding a comment explaining the expected login flow and why the redirection URL was changed. This will help future maintainers understand the reasoning behind these modifications.

tests/pw/tests/e2e/vendorSettings.spec.ts (2)

123-123: Approved: Minor improvement in test description readability.

The removal of the colon from the test description improves readability. This change is good and doesn't affect the test's functionality.

For consistency, consider applying this change to other similar test descriptions in the file. For example:

test('vendor can set rma settings (warranty included limited)', { tag: ['@pro', '@vendor'] }, async () => {

could be changed to:

test('vendor can set rma settings (warranty included limited)', { tag: ['@pro', '@vendor'] }, async () => {

Skipped tests lack explanations.

The tests 'vendor can set store banner settings' and 'vendor can set store profile picture settings' are currently skipped without any accompanying comments explaining the reason. It's recommended to add comments clarifying whether these tests are under development, temporarily disabled due to known issues, or deprecated. This will improve code maintainability and clarity for future contributors.

🔗 Analysis chain

Line range hint 1-138: Overall test suite structure is comprehensive, but some tests are skipped.

The test suite covers a wide range of vendor settings, which is excellent for ensuring comprehensive coverage. The use of tags (@lite, @Pro, @Vendor) allows for flexible test execution.

However, there are two skipped tests:

  1. 'vendor can set store banner settings'
  2. 'vendor can set store profile picture settings'

Could you please clarify why these tests are skipped? Are they under development or temporarily disabled due to known issues? Consider adding a comment explaining the reason for skipping these tests, or create issues to track their implementation if they're not yet developed.

To verify the status of these skipped tests, you can run the following command:

This will help us understand if there are any comments or surrounding code that explain why these tests are skipped.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for skipped tests and their surrounding context
rg --type typescript -C 5 "test\.skip\(" tests/pw/tests/e2e/vendorSettings.spec.ts

Length of output: 119


Script:

#!/bin/bash
# Search for skipped tests and their surrounding context without specifying type
rg "test\.skip\(" -C 5 tests/pw/tests/e2e/vendorSettings.spec.ts

Length of output: 704


Script:

#!/bin/bash
# Search for comments before skipped tests
rg "test\.skip\(" -B 3 tests/pw/tests/e2e/vendorSettings.spec.ts | rg "//|/\*"

Length of output: 102

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

322-332: LGTM! Shipping tests look good.

The new tests for product shipping (add, update, remove) are well-structured and follow the existing patterns. They cover the essential scenarios for managing product shipping details.

Suggestion for improvement:
Consider adding a test case for invalid shipping data to ensure proper error handling.


334-340: LGTM! Tax tests are well-implemented.

The new tests for product tax (with and without tax class) are properly structured and cover the main scenarios for adding product tax.

Suggestion for improvement:
Consider adding a test case for updating and removing product tax to ensure complete coverage of tax-related operations.


344-358: LGTM! Linked products tests are comprehensive.

The new tests for linked products (up-sells and cross-sells) cover both adding and removing scenarios, which is great for ensuring proper functionality.

Suggestion for improvement:
Consider adding a test case for updating linked products to ensure that existing links can be modified correctly.


319-358: Great job on expanding the test coverage!

The new tests for shipping, tax, and linked products align well with the PR objectives of introducing tests for the product form, specifically targeting additional options within the catalog. These additions significantly enhance the test coverage for product management features.

The tests are well-structured, properly tagged, and follow the established patterns in the existing test suite. They cover essential scenarios for each feature, including adding, updating, and removing (where applicable) the respective product details.

To further improve the test suite:

  1. Consider adding error handling scenarios for each new feature.
  2. Ensure that all edge cases are covered, such as updating existing data or handling invalid inputs.
  3. If not already present elsewhere in the test suite, consider adding integration tests that combine these new features with other product management operations.

Overall, these additions greatly contribute to the robustness of the test suite and help ensure the reliability of the product management features.

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

171-179: New vendor features for product management look good!

The additions to the "Products" page features for vendors are well-structured and consistent with the existing format. These new capabilities enhance the vendor's ability to manage product details more comprehensively. Here's a breakdown of the new features:

  1. Product shipping management (add, update, remove)
  2. Product tax management (add, including tax class)
  3. Linked products management (add and remove up-sells and cross-sells)

These features align well with common e-commerce functionalities and should provide vendors with more control over their product listings.

However, to ensure completeness, consider the following suggestions:

  1. Add a feature for updating product tax, similar to the shipping features.
  2. Consider adding features for managing product attributes and variations, if not already present elsewhere in the file.

Line range hint 1-1037: Overall structure is good, but some improvements could enhance consistency and clarity.

The feature map is comprehensive and well-organized. However, there are a few areas where consistency and clarity could be improved:

  1. Standardize feature descriptions: Some features are very specific (e.g., "admin can add standard tax rate [lite]"), while others are more general (e.g., "no test is written for elementor module (out of scope)"). Consider adopting a consistent level of detail across all features.

  2. Address duplicate entries: There are comments indicating duplicate entries (e.g., "admin can set Dokan geolocation settings [duplicate]"). Consider removing or consolidating these to avoid confusion.

  3. Resolve TODO items: Some features are marked as "false" without explanation (e.g., "admin can import dummy data: false"). Consider adding comments to explain why these features are set to false or if they are planned for future implementation.

  4. Consistent use of tags: The "[lite]" tag is used inconsistently. Consider reviewing its usage and ensuring it's applied uniformly where appropriate.

  5. Group related features: Some closely related features are spread across different sections. Consider grouping them together for better organization (e.g., all EU compliance features in one section).

Would you like assistance in restructuring any specific sections of the file to improve consistency?


Line range hint 1-1037: Overall, the changes and feature map are well-structured with room for minor improvements.

The additions to the vendor product management features in the "Products" page section are valuable enhancements that will provide vendors with more control over their listings. The new capabilities for managing product shipping, taxes, and linked products are well-aligned with e-commerce best practices.

The feature map as a whole is comprehensive and provides a clear overview of the Dokan system's capabilities across different user roles and pages. However, there are opportunities to improve consistency in feature descriptions, resolve duplicate entries, and group related features more effectively.

Key points to consider:

  1. Implement the suggested consistency improvements throughout the file.
  2. Ensure proper security measures are in place when implementing the new features.
  3. Consider adding any missing features related to product attribute and variation management.
  4. Regularly review and update the feature map to keep it in sync with the actual implementation.

To maintain the quality and usefulness of this feature map:

  1. Consider implementing a automated process to keep this feature map in sync with the actual codebase implementation.
  2. Develop clear guidelines for adding new features to the map, ensuring consistency in description detail and tag usage.
  3. Periodically review the entire feature map to identify areas for consolidation or expansion based on system evolution.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between dedf360 and 07710cb.

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

49-49: Improved page navigation handling

The change from goIfNotThere(url) to gotoUntilNetworkidle(url) is a good improvement. This ensures that the page is fully loaded and the network is idle before proceeding with the login process, which can help prevent race conditions and improve test reliability.


54-54: Removed hardcoded status code

The hardcoded status code 302 has been removed from the clickAndWaitForResponseAndLoadState call. This change makes the method more flexible, as it can now handle various status codes that might be returned in different scenarios.

To ensure this change doesn't introduce any regressions, please run the following script:

#!/bin/bash
# Description: Check for other occurrences of hardcoded status codes in test files

# Test: Search for hardcoded status codes in test files
rg --type typescript '\d{3}' ./tests

This script will help us identify if there are any other instances of hardcoded status codes in the test files that might need similar updates for consistency.


54-54: Updated redirection URL after login

The URL in clickAndWaitForResponseAndLoadState has been changed from data.subUrls.backend.login to data.subUrls.backend.adminDashboard. This suggests that after a successful login, the user is now expected to be redirected to the admin dashboard instead of remaining on the login page.

To ensure this change is consistent with the application's behavior, please run the following script:

This script will help us verify if the login redirection logic in the application code matches this test expectation.

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

171-179: Consider security implications for new product management features.

While the new features for vendor product management are valuable additions, it's crucial to ensure proper security measures are in place during implementation:

  1. Access Control: Verify that only authorized vendors can modify their own products' shipping, tax, and linked product details.

  2. Input Validation: Implement thorough input validation for all new fields, especially for tax rates and shipping details, to prevent potential injection attacks or data inconsistencies.

  3. Audit Logging: Consider implementing audit logs for these operations to track changes and help with troubleshooting or dispute resolution.

  4. Rate Limiting: Implement rate limiting on these operations to prevent potential abuse or DOS attacks.

  5. Data Integrity: Ensure that adding or removing linked products (up-sells and cross-sells) maintains data integrity and doesn't create circular references.

To help verify these security considerations, you could run the following script:

This script will help identify if these security measures are being implemented in the codebase.

tests/pw/pages/productsPage.ts Outdated Show resolved Hide resolved
tests/pw/pages/productsPage.ts Outdated Show resolved Hide resolved
tests/pw/pages/productsPage.ts Outdated Show resolved Hide resolved
tests/pw/pages/productsPage.ts Outdated Show resolved Hide resolved
tests/pw/pages/productsPage.ts Outdated Show resolved Hide resolved
tests/pw/pages/productsPage.ts Show resolved Hide resolved
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: 0

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

1200-1200: Correct the Comment Above removeProductShipping Method

The comment at line 1200 incorrectly states "// add product shipping" before the removeProductShipping method. Please update it to "// remove product shipping" for accuracy and clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 07710cb and ccb5bb3.

📒 Files selected for processing (1)
  • tests/pw/pages/productsPage.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (4)
tests/pw/pages/productsPage.ts (4)

1184-1199: Well-Implemented addProductShipping Method

The addProductShipping method effectively adds shipping details to a product. The implementation is clear, follows best practices, and the code is concise.


1201-1206: removeProductShipping Method Implementation is Correct

The removeProductShipping method properly removes the shipping requirement from the product. The code is straightforward and functions as expected.


1219-1256: addProductLinkedProducts Method Functions Correctly

The addProductLinkedProducts method correctly adds linked products based on the choice parameter. The use of descriptive variable names like linkedProduct enhances readability.


1259-1294: removeProductLinkedProducts Method Works as Intended

The removeProductLinkedProducts method effectively removes linked products according to the choice parameter. The code is clean and maintains consistency with the addition method.

@shashwatahalder01 shashwatahalder01 added the QA approved This PR is approved by the QA team label Oct 7, 2024
@shashwatahalder01 shashwatahalder01 merged commit b2ce2cc into getdokan:develop Oct 7, 2024
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 7, 2024
12 tasks
@shashwatahalder01 shashwatahalder01 changed the title Add: product form tests (other options, catalog) Add: add product form tests( shipping, tax, linked products) Oct 7, 2024
@shashwatahalder01 shashwatahalder01 deleted the productpro2 branch October 8, 2024 05:02
@coderabbitai coderabbitai bot mentioned this pull request Oct 8, 2024
11 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