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: product form tests (other options, catalog) #2391

Merged
merged 1 commit 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 options, including status, visibility, purchase notes, and reviews.
    • Expanded permissions for vendors to manage catalog modes and product-related settings.
    • Improved customer features for viewing and managing orders.
  • Bug Fixes

    • Updated RMA settings tests to cover various warranty scenarios, enhancing accuracy in vendor settings management.
  • Tests

    • Added comprehensive test cases for new product management features and RMA settings.

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The changes in this pull request involve significant updates to the feature-map.yml file, enhancing vendor capabilities in product management. New features for vendors include the ability to add and remove various product options and manage catalog modes. Additionally, the ProductsPage class has been updated with new methods for handling these options, and corresponding tests have been added to ensure functionality. The vendor settings tests have also been modified to include new RMA scenarios, further refining the testing coverage for vendor-related features.

Changes

File Path Change Summary
tests/pw/feature-map/feature-map.yml Added multiple features for vendors, including product options and catalog mode management.
tests/pw/pages/productsPage.ts Added methods addProductOtherOptions and removeProductCatalogMode to handle product attributes.
tests/pw/tests/e2e/productsDetails.spec.ts Introduced new tests for managing product options and catalog modes for vendors.
tests/pw/tests/e2e/vendorSettings.spec.ts Enhanced RMA settings tests with new warranty scenarios and updated existing test descriptions.

Possibly related PRs

Suggested labels

QA approved

Poem

🐇 In fields of code where vendors play,
New features bloom, bright as the day.
Options to add, and modes to hide,
A world of products, now open wide!
With tests in place, all's set to go,
Hopping along, watch our features grow! 🌼


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

🧹 Outside diff range and nitpick comments (8)
tests/pw/tests/e2e/vendorSettings.spec.ts (3)

123-125: LGTM! Consider adding an assertion.

The test case for RMA settings with no warranty is well-implemented. It correctly uses the setRmaSettings method with the appropriate parameters.

Consider adding an assertion after calling setRmaSettings to verify that the settings were applied correctly. For example:

await vendor.setRmaSettings({ ...data.vendor.rma, type: 'no_warranty' });
// Add an assertion here to verify the settings were applied
await expect(vendor.getRmaSettings()).resolves.toEqual({ ...data.vendor.rma, type: 'no_warranty' });

127-129: LGTM! Consider explicitly specifying the warranty type for consistency.

The test case for RMA settings with limited warranty is well-implemented. It correctly uses the setRmaSettings method with the default data.vendor.rma object.

For consistency with the other test cases and to make the warranty type explicit, consider modifying the test case as follows:

test('vendor can set rma settings (warranty included limited)', { tag: ['@pro', '@vendor'] }, async () => {
    await vendor.setRmaSettings({ ...data.vendor.rma, type: 'included_warranty', length: 'limited' });
});

This change makes it clear that we're testing a limited warranty scenario and maintains consistency with the structure of the other test cases.


131-133: LGTM! Consider explicitly specifying the warranty type for clarity.

The test case for RMA settings with lifetime warranty is well-implemented. It correctly uses the setRmaSettings method with the appropriate parameters.

For clarity and consistency with the suggested changes in the previous test case, consider modifying the test case as follows:

test('vendor can set rma settings (warranty included lifetime)', { tag: ['@pro', '@vendor'] }, async () => {
    await vendor.setRmaSettings({ ...data.vendor.rma, type: 'included_warranty', length: 'lifetime' });
});

This change makes it explicit that we're testing an included warranty scenario with a lifetime length.

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

300-308: LGTM: Test cases for adding catalog mode.

The test cases for adding catalog mode are well-implemented:

  1. Adding catalog mode without hidden price is correctly tested.
  2. Adding catalog mode with hidden price is properly tested.

Both tests follow the established pattern, use correct database option updates, and are properly tagged.

Consider adding a comment explaining the purpose of the database option updates for better readability and maintainability.


310-318: LGTM: Test cases for removing catalog mode.

The test cases for removing catalog mode are well-implemented:

  1. Removing catalog mode without the price hidden option is correctly tested.
  2. Removing catalog mode with the price hidden option is properly tested.

Both tests follow the established pattern, use correct database option updates, and are properly tagged.

Consider adding a comment explaining the purpose of the database option updates for better readability and maintainability, similar to the suggestion for the adding catalog mode tests.


269-318: Overall assessment: High-quality additions to the test suite.

The new test cases for product other options and catalog mode are well-implemented and comprehensive. They cover important functionality such as:

  1. Adding and removing product status, visibility, purchase notes, and reviews.
  2. Adding and removing catalog mode with various options.

All tests follow the established patterns in the file, use appropriate methods, and are correctly tagged. The use of database utils to set up the test environment is a good practice.

To further improve the code:

  1. Consider adding comments explaining the purpose of the database option updates in the catalog mode tests.
  2. Ensure that error handling and edge cases are covered in future iterations of these tests.
tests/pw/feature-map/feature-map.yml (2)

161-170: New vendor capabilities added for product management

These additions enhance the vendor's ability to manage product options and catalog modes. Here's a summary of the new features:

  1. Product status and visibility options
  2. Purchase note management
  3. Product review settings
  4. Catalog mode controls, including price hiding

These features provide vendors with more control over their product listings and how they're presented to customers. The additions are consistent with the existing structure and naming conventions in the file.

Consider the following suggestions to further improve the feature set:

  1. Add a feature for vendors to set product visibility in search results.
  2. Consider adding a feature for vendors to schedule product visibility changes.
  3. For catalog mode, you might want to add a feature for vendors to customize the "Request a Quote" button text when price is hidden.

Detected Issues in feature-map.yml:

  1. Commented-out Duplicate Entries:

    • Multiple lines contain commented-out features marked as duplicates. These should be reviewed and removed if they are no longer necessary to reduce clutter.
  2. Inconsistent Naming Conventions:

    • Numerous inconsistencies in naming conventions have been identified throughout the file. Standardizing the naming scheme will enhance readability and maintainability.

Recommendations:

  • Remove Unnecessary Duplicates: Eliminate commented-out duplicate entries that are no longer relevant to streamline the feature map.
  • Standardize Naming Conventions: Adopt a consistent naming convention (e.g., camelCase, snake_case) across all features to improve clarity.
🔗 Analysis chain

Line range hint 1-1037: Overall structure and potential improvements

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

  1. Consistency: Ensure consistent use of boolean values (true/false) instead of mixing with string values in some places.
  2. Duplicates: There are some commented-out features marked as duplicates. Consider removing these to reduce clutter.
  3. Grouping: Some related features are spread across different sections. Consider grouping them together for better organization.
  4. Naming conventions: Ensure consistent naming conventions across all features. For example, some use camel case while others use snake case.

To improve the overall structure and maintainability of the file, consider the following actions:

  1. Remove commented-out duplicate entries to reduce file size and improve readability.
  2. Group related features together, possibly creating sub-sections within each page.
  3. Standardize the naming conventions across all features.
  4. Review and update the false entries to ensure they accurately reflect the current state of the application.

To identify potential inconsistencies or duplicates, you can run the following script:

This script will help identify areas that may need attention for improving the overall quality and consistency of the feature map.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Identify potential inconsistencies and duplicates in the feature map

# Check for inconsistent boolean values
echo "Inconsistent boolean values:"
grep -nE ': (true|false)' tests/pw/feature-map/feature-map.yml | grep -vE ': (true|false)$'

# Check for commented-out duplicate entries
echo -e "\nCommented-out duplicate entries:"
grep -n "duplicate" tests/pw/feature-map/feature-map.yml

# Check for inconsistent naming conventions
echo -e "\nInconsistent naming conventions:"
grep -nE '^ {6}[a-z]' tests/pw/feature-map/feature-map.yml | grep -vE '^ {6}[a-z]+( [a-z]+)*:'

Length of output: 4081

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 51bf060 and 705971e.

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

135-137: LGTM! Well-implemented test case.

The test case for RMA settings with warranty as an addon is well-implemented. It correctly uses the setRmaSettings method with the appropriate parameters, testing a specific scenario (addon warranty) which enhances the overall test coverage.


123-138: Great addition of RMA settings test cases!

The new test cases for RMA settings with different warranty types significantly improve the test coverage. They are well-structured, consistent in their approach, and cover various scenarios (no warranty, limited warranty, lifetime warranty, and addon warranty).

A few minor suggestions have been made to improve clarity and consistency across the test cases. Overall, these additions enhance the robustness of the test suite for vendor settings.

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

272-274: LGTM: Test case for adding product status.

The test case follows the established pattern and correctly tests the ability to add product status as part of other options.


276-278: LGTM: Test case for adding product visibility.

The test case is well-structured and correctly tests the ability to add product visibility as part of other options.


280-286: LGTM: Test cases for adding and removing purchase note.

Both test cases are well-implemented:

  1. Adding a purchase note is correctly tested.
  2. Removing a purchase note is properly tested by setting it to an empty string.

The tests follow the established pattern and are correctly tagged.


288-294: LGTM: Test cases for adding and removing product reviews.

The test cases for adding and removing product reviews are well-implemented:

  1. Adding product reviews is correctly tested.
  2. Removing product reviews is properly tested by setting enableReview to false.

Both tests follow the established pattern and are correctly tagged.

tests/pw/pages/productsPage.ts Show resolved Hide resolved
tests/pw/pages/productsPage.ts Show resolved Hide resolved
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 dedf360 into getdokan:develop Oct 7, 2024
2 checks passed
shashwatahalder01 added a commit to shashwatahalder01/dokan that referenced this pull request Oct 7, 2024
* Add: product form tests (other options, catalog)

* Add: add product form tests( shipping, tax, linked products)

* Add: product form tests (other options, catalog) (getdokan#2391)

* Fix: PR reviews

* Fix: pr reviews

* Update: remove duplicate method

* Update: update login method

* Fix: pr reviews
@shashwatahalder01 shashwatahalder01 deleted the productpro branch October 8, 2024 05:02
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