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 addon tests(automation suite) #2381

Merged
merged 7 commits into from
Sep 27, 2024

Conversation

shashwatahalder01
Copy link
Contributor

@shashwatahalder01 shashwatahalder01 commented Sep 27, 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 group products, reset filters, import, and export products.
    • Enhanced management of product addons, including importing and removing addon fields.
    • New methods for product management, such as importing products from CSV and resetting filters.
  • Bug Fixes

    • Improved handling of the "remember me" functionality on the login page.
  • Improvements

    • Streamlined selectors for product management, enhancing performance and maintainability.
    • Restructured interfaces to include new properties for better product and vendor data representation.
  • Tests

    • Expanded test coverage for product addons and vendor functionalities, ensuring robust validation of new features.

Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Walkthrough

The pull request introduces significant modifications across various files, enhancing vendor and customer functionalities related to product management and addons. Key changes include new features for vendors, such as managing product groups and filters, while streamlining customer interactions with product addons. Additionally, various methods and selectors have been updated or added to improve the overall structure and maintainability of the codebase. The changes reflect a comprehensive restructuring aimed at better handling product data and vendor settings.

Changes

Files Change Summary
tests/pw/feature-map/feature-map.yml Added new vendor capabilities for group products, filter reset, and product import/export. Modified customer ability to buy products with addons.
tests/pw/pages/loginPage.ts Introduced conditional check for storageState before invoking check method on rememberMe.
tests/pw/pages/productAddonsPage.ts Added methods for addon management, including editing, saving, importing, and exporting addons. Refactored existing methods for clarity.
tests/pw/pages/productsPage.ts Refactored product addition methods, removed redundant parameters, and added new methods for importing and resetting filters.
tests/pw/pages/selectors.ts Updated selectors to use CSS instead of XPath, added new selectors for product management.
tests/pw/pages/shortcodePage.ts Changed how the page title is set in addNewPage functionality.
tests/pw/pages/spmvPage.ts Simplified selectors for adding and editing products.
tests/pw/pages/vendorPage.ts Updated product title verification method after editing.
tests/pw/pages/vendorSettingsPage.ts Introduced new selectors and methods for managing vendor settings, including RMA and SEO settings.
tests/pw/tests/api/productReviews.spec.ts Changed endpoint for updating product reviews in test cases.
tests/pw/tests/e2e/catalogmode.spec.ts Updated method for setting catalog mode with new parameters.
tests/pw/tests/e2e/productAddons.spec.ts Enhanced functionality for global product addons, including new test cases for importing and exporting.
tests/pw/tests/e2e/products.spec.ts Streamlined product addition tests, added tests for group products, and reorganized existing tests.
tests/pw/tests/e2e/vendorBooking.spec.ts Added new imports and vendor RMA settings modifications in test setup.
tests/pw/tests/e2e/vendorTools.spec.ts Integrated API utilities for product deletion in test setup.
tests/pw/utils/apiEndPoints.ts Renamed function for updating reviews to better reflect its purpose.
tests/pw/utils/dbData.ts Added new RMA settings under vendor configuration.
tests/pw/utils/interfaces.ts Expanded product and vendor interfaces with new properties for better data representation.
tests/pw/utils/payloads.ts Updated payloads related to product addons and renamed relevant functions.
tests/pw/utils/sampleData/products.xml Updated XML export data reflecting changes in product details and metadata.
tests/pw/utils/testData.ts Added description fields and expanded product configurations for testing.

Possibly related PRs

Suggested labels

QA approved

Poem

🐇 In the garden where products bloom,
New features sprout, dispelling gloom.
Vendors can group, and filters reset,
With addons to manage, there's much to beget!
So hop with joy, let changes take flight,
For in this code, all feels just right! 🌼


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

🧹 Outside diff range and nitpick comments (23)
tests/pw/tests/e2e/vendorTools.spec.ts (2)

16-18: LGTM: API utility initialization and product cleanup added.

The addition of apiUtils initialization and the deleteAllProducts call in the beforeAll hook is a good practice. It ensures a clean state before running tests by removing all products associated with the vendor. This change aligns with the PR objective of enhancing the testing framework.

Consider adding a comment explaining the purpose of the 'p0_v1' parameter for better code readability:

// Delete all products for vendor 'p0_v1' before running tests
await apiUtils.deleteAllProducts('p0_v1', payloads.vendorAuth);

Line range hint 1-46: Suggestion: Consider expanding test coverage for product addons.

The changes made enhance the test setup by introducing API utilities and ensuring a clean state before running tests. However, to fully meet the PR objective of introducing an automation suite for testing product addons, consider the following suggestions:

  1. Add specific test cases for product addons functionality.
  2. Include tests that verify the interaction between the vendor tools and product addons.
  3. Implement tests that cover edge cases and potential error scenarios related to product addons.

These additions would provide a more comprehensive test suite aligned with the PR's primary objective.

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

75-75: Approved: Method update improves clarity and functionality.

The change from addCatalogMode(productName) to addProductCatalogMode(productName, true) is a good improvement. It makes the method's purpose more explicit and allows for more precise control over the catalog mode setting.

Consider adding a brief comment explaining the boolean parameter's purpose for improved readability:

// Enable catalog mode for the product
await vendor.addProductCatalogMode(productName, true);

Line range hint 1-108: Enhance error handling and assertions in tests

While the overall structure of the tests is good, consider the following improvements:

  1. Add more specific assertions to verify the expected outcomes of each test.
  2. Implement try-catch blocks for error handling, especially in tests that interact with the database or API.
  3. For the skipped test "vendor can disable hide product price in catalog mode", create a TODO or issue to track and address the Dokan issue mentioned.

These enhancements will improve the robustness and reliability of the test suite.

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

44-45: Approve changes with a suggestion for improvement

The changes look good and may improve the reliability of setting the page title by ensuring the title field is focused before typing. This aligns well with the PR objectives of enhancing the testing framework.

However, to improve clarity and ensure the field is cleared before typing, consider the following modification:

 await this.click(selector.admin.pages.addTitle);
+await this.page.evaluate(() => (document.querySelector(selector.admin.pages.addTitle) as HTMLInputElement).value = '');
 await this.type(selector.admin.pages.addTitle, pageTitle);

This addition explicitly clears the input field using JavaScript before typing, which can prevent any potential issues with pre-existing text in the title field.

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

9-9: LGTM: New constant added, but consider adding error handling.

The VENDOR_ID constant is correctly declared using destructuring assignment from process.env. This is a good practice for configuration management. However, consider adding error handling in case the environment variable is not set.

You could add a check to ensure the VENDOR_ID is set:

const { VENDOR_ID } = process.env;
if (!VENDOR_ID) {
  throw new Error('VENDOR_ID environment variable is not set');
}

34-35: LGTM: New operation added, but consider error handling and test isolation.

The new operation to disable vendor global RMA settings is correctly placed in the beforeAll hook and uses the newly added imports and constant. The purpose is clear from the comment. However, consider the following improvements:

  1. Add error handling for the setUserMeta operation.
  2. Consider the impact of this change on other tests and whether it should be isolated to specific test cases.

You could improve the code as follows:

try {
  await dbUtils.setUserMeta(VENDOR_ID, '_dokan_rma_settings', dbData.testData.dokan.rmaSettings, true);
} catch (error) {
  console.error('Failed to disable vendor global RMA settings:', error);
  throw error; // or handle it appropriately
}

Also, consider adding a corresponding operation in the afterAll hook to reset the RMA settings, ensuring test isolation:

test.afterAll(async () => {
  // ... existing cleanup code ...
  
  // Reset vendor global RMA settings
  try {
    await dbUtils.setUserMeta(VENDOR_ID, '_dokan_rma_settings', null, true); // or whatever the default value should be
  } catch (error) {
    console.error('Failed to reset vendor global RMA settings:', error);
  }
});

Line range hint 1-138: Summary: Good additions to the test suite, with room for minor improvements.

The changes in this file align well with the PR objectives of enhancing the testing framework for product addons. The new imports, constant, and operation in the beforeAll hook add more control over the test environment, which is good for test reliability.

However, there are opportunities to improve:

  1. Error handling for the VENDOR_ID environment variable.
  2. Error handling for the new setUserMeta operation.
  3. Test isolation by resetting the RMA settings in the afterAll hook.

These improvements would further enhance the robustness of the test suite and align even better with the PR's emphasis on code quality and best practices.

Overall, the changes are a positive step towards a more comprehensive automation suite for testing product addons.

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

73-76: LGTM! Consider enhancing the comment.

The simplification of the vendorAddSimpleProduct method call improves readability. The added comment provides clarity to the test structure.

Consider making the comment more specific:

- // add products
+ // Vendor product addition tests

This change would better describe the purpose of the following test cases.


95-96: LGTM! Consider adding a tag for consistency.

The addition of a test case for group products enhances the test coverage, which aligns with the PR objectives.

For consistency with other tests, consider adding the @exploratory tag:

- test('vendor can add group product', { tag: ['@pro', '@vendor'] }, async () => {
+ test('vendor can add group product', { tag: ['@pro', '@exploratory', '@vendor'] }, async () => {

This change would maintain consistency with the tagging structure used in other test cases.


99-104: LGTM! Consider adding tags for consistency.

The retention of the downloadable product test and the addition of the virtual product test contribute to a more comprehensive test suite, aligning with the PR objectives.

For consistency with other tests, consider adding the @exploratory tag to both test cases:

- test('vendor can add downloadable product', { tag: ['@lite', '@vendor'] }, async () => {
+ test('vendor can add downloadable product', { tag: ['@lite', '@exploratory', '@vendor'] }, async () => {

- test('vendor can add virtual product', { tag: ['@lite', '@vendor'] }, async () => {
+ test('vendor can add virtual product', { tag: ['@lite', '@exploratory', '@vendor'] }, async () => {

This change would maintain consistency with the tagging structure used in other test cases.


129-130: LGTM! Consider adding a tag for consistency.

The addition of a test case for resetting filters enhances the test coverage for product filtering functionality, which aligns with the PR objectives.

For consistency with other tests, consider adding the @exploratory tag:

- test('vendor can reset filter', { tag: ['@lite', '@vendor'] }, async () => {
+ test('vendor can reset filter', { tag: ['@lite', '@exploratory', '@vendor'] }, async () => {

This change would maintain consistency with the tagging structure used in other test cases.


133-135: LGTM! Consider adding error handling.

The addition of a test case for importing products enhances the test coverage for product management functionality, which aligns with the PR objectives. The deletion of all products before import ensures a clean state for testing, which is a good practice.

Consider adding error handling to ensure the test fails gracefully if the deletion or import operations encounter issues:

 test('vendor can import products', { tag: ['@pro', '@vendor'] }, async () => {
-    await apiUtils.deleteAllProducts('p0_v1', payloads.vendorAuth);
-    await vendor.importProducts('utils/sampleData/products.csv');
+    try {
+        await apiUtils.deleteAllProducts('p0_v1', payloads.vendorAuth);
+        await vendor.importProducts('utils/sampleData/products.csv');
+    } catch (error) {
+        console.error('Error during product import test:', error);
+        throw error;
+    }
 });

This change would improve the robustness of the test and provide more informative error messages if issues occur.


138-139: LGTM! Consider adding a tag for consistency.

The repositioning of the product export test improves the logical flow of the test suite, which aligns with the PR objectives of enhancing the testing framework.

For consistency with other tests, consider adding the @exploratory tag:

- test('vendor can export products', { tag: ['@pro', '@vendor'] }, async () => {
+ test('vendor can export products', { tag: ['@pro', '@exploratory', '@vendor'] }, async () => {

This change would maintain consistency with the tagging structure used in other test cases.


142-165: LGTM! Consider minor improvements for consistency and error handling.

The reorganization of product management tests improves the logical flow of the test suite, which aligns with the PR objectives of enhancing the testing framework. The retention of the "can't buy own product" test maintains important functionality coverage.

Consider the following improvements:

  1. Add the @exploratory tag to all tests for consistency:
- test('vendor can duplicate product', { tag: ['@pro', '@vendor'] }, async () => {
+ test('vendor can duplicate product', { tag: ['@pro', '@exploratory', '@vendor'] }, async () => {

- test('vendor can permanently delete product', { tag: ['@lite', '@vendor'] }, async () => {
+ test('vendor can permanently delete product', { tag: ['@lite', '@exploratory', '@vendor'] }, async () => {

- test('vendor can view product', { tag: ['@lite', '@vendor'] }, async () => {
+ test('vendor can view product', { tag: ['@lite', '@exploratory', '@vendor'] }, async () => {

- test("vendor can't buy own product", { tag: ['@lite', '@vendor'] }, async () => {
+ test("vendor can't buy own product", { tag: ['@lite', '@exploratory', '@vendor'] }, async () => {

- test('vendor can edit product', { tag: ['@lite', '@vendor'] }, async () => {
+ test('vendor can edit product', { tag: ['@lite', '@exploratory', '@vendor'] }, async () => {

- test('vendor can quick edit product', { tag: ['@pro', '@vendor'] }, async () => {
+ test('vendor can quick edit product', { tag: ['@pro', '@exploratory', '@vendor'] }, async () => {
  1. Add error handling to the product creation steps:
 test('vendor can duplicate product', { tag: ['@pro', '@exploratory', '@vendor'] }, async () => {
-    const [, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth);
-    await vendor.duplicateProduct(productName);
+    try {
+        const [, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth);
+        await vendor.duplicateProduct(productName);
+    } catch (error) {
+        console.error('Error during product duplication test:', error);
+        throw error;
+    }
 });

Apply similar error handling to other tests that create products.

These changes would improve consistency and robustness across the test suite.

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

Line range hint 1-200: Overall, the selector updates improve consistency and potential reusability.

The changes made to the selectors in this file are part of a broader refactoring effort to simplify and standardize selector paths. These updates should improve code maintainability and readability. However, to ensure these changes don't introduce any regressions, consider the following recommendations:

  1. Conduct a thorough review of selector usage across the entire codebase to ensure consistency.
  2. Update any documentation or developer guidelines related to selector naming conventions.
  3. Run the full test suite to catch any potential issues caused by these selector changes.
  4. Consider adding or updating tests specifically for these selectors to ensure they correctly identify the intended elements across different contexts (creation, editing, viewing).
tests/pw/tests/e2e/productAddons.spec.ts (1)

61-61: Ensure secure usage of serialization

When using serialize, be cautious of potential security risks, especially if the data can be manipulated by users. Ensure that the data being serialized is sanitized and validated.

Consider adding input validation:

const field = payloads.createGlobalProductAddons().fields[0];
+ // Validate the field before serialization
+ if (validateField(field)) {
    await vendor.importAddonField(addonId, serialize([field]), addonFieldTitle);
+ } else {
+   throw new Error('Invalid field data.');
+ }

+ function validateField(field) {
+   // Implement validation logic here
+   return true; // Placeholder
+ }
tests/pw/pages/vendorSettingsPage.ts (1)

444-446: Remove Commented-Out Code and Resolve TODO

The code contains commented-out lines with a TODO regarding a locator issue:

// await this.click(settingsShipStation.shippedOrderStatusDropdown);
// await this.clearAndType(settingsShipStation.shippedOrderStatusInput, shipStation.status);// todo: need to fix -> locator issue
// await this.toContainText(settingsShipStation.result, shipStation.status);

Commented-out code can clutter the codebase and should be avoided. Please either fix the locator issue and uncomment the code or remove it if it's no longer needed.

Do you need assistance resolving the locator issue? I can help troubleshoot and update the code. Would you like me to open a new GitHub issue for this task?

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

334-334: Address the TODO comment to add more assertions

The presence of a TODO indicates that additional assertions are needed to fully verify the product creation. Implement these assertions to ensure all aspects of the variable product are correctly saved.

Would you like assistance in generating the additional assertions for comprehensive verification?

tests/pw/utils/testData.ts (4)

219-219: Consider using dynamic descriptions for test data

The description field is statically set to 'test description' across multiple product definitions. Using dynamic values can help in identifying different products during testing and prevent potential confusion.

Also applies to: 232-232, 252-252, 270-270, 283-283, 294-294


440-473: Verify consistency and dynamic generation in 'productInfo' properties

The additions to the productInfo object enhance the test data. However, please consider the following:

  • Ensure that price values are consistent. Currently, price uses a dynamically generated amount with decimal separator replaced, while discount.discountPrice is hardcoded to '10'. Consider generating discountPrice dynamically for consistency.

  • Verify that date calculations using helpers.currentDate and helpers.addDays are accurate and suit the testing needs.

  • Check that file paths such as 'utils/sampleData/avatar.png' for images.cover, images.gallery, and downloadableOptions.fileUrl are correct and accessible during tests.


532-541: Ensure dynamic generation of add-on options

The addon object adds valuable test data for product add-ons. Consider using dynamic data for fields like enterAnOption and optionPriceInput to enhance variability in tests. This can help in testing with different price inputs and options.


1483-1483: Verify accessibility of SEO image paths

The facebookImage and twitterImage fields in the SEO settings are set to 'utils/sampleData/avatar.png'. Ensure that these image paths are correct and the images are accessible during testing to avoid any broken links or failed tests.

Also applies to: 1486-1486

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f137722 and 6e19f43.

⛔ Files ignored due to path filters (2)
  • tests/pw/utils/sampleData/banner.png is excluded by !**/*.png
  • tests/pw/utils/sampleData/products.csv is excluded by !**/*.csv
📒 Files selected for processing (21)
  • tests/pw/feature-map/feature-map.yml (2 hunks)
  • tests/pw/pages/loginPage.ts (1 hunks)
  • tests/pw/pages/productAddonsPage.ts (4 hunks)
  • tests/pw/pages/productsPage.ts (9 hunks)
  • tests/pw/pages/selectors.ts (24 hunks)
  • tests/pw/pages/shortcodePage.ts (1 hunks)
  • tests/pw/pages/spmvPage.ts (3 hunks)
  • tests/pw/pages/vendorPage.ts (1 hunks)
  • tests/pw/pages/vendorSettingsPage.ts (5 hunks)
  • tests/pw/tests/api/productReviews.spec.ts (1 hunks)
  • tests/pw/tests/e2e/catalogmode.spec.ts (1 hunks)
  • tests/pw/tests/e2e/productAddons.spec.ts (4 hunks)
  • tests/pw/tests/e2e/products.spec.ts (2 hunks)
  • tests/pw/tests/e2e/vendorBooking.spec.ts (2 hunks)
  • tests/pw/tests/e2e/vendorTools.spec.ts (1 hunks)
  • tests/pw/utils/apiEndPoints.ts (1 hunks)
  • tests/pw/utils/dbData.ts (1 hunks)
  • tests/pw/utils/interfaces.ts (13 hunks)
  • tests/pw/utils/payloads.ts (5 hunks)
  • tests/pw/utils/sampleData/products.xml (5 hunks)
  • tests/pw/utils/testData.ts (13 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/pw/utils/apiEndPoints.ts
🧰 Additional context used
🪛 Biome
tests/pw/pages/productAddonsPage.ts

[error] 117-117: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 118-118: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments (56)
tests/pw/tests/e2e/vendorTools.spec.ts (2)

1-1: LGTM: New imports enhance testing capabilities.

The addition of request, ApiUtils, and payloads imports aligns with the PR objective of introducing an automation suite for testing product addons. These imports enable API interactions and provide necessary utilities for the enhanced testing framework.

Also applies to: 3-3, 5-5


10-10: LGTM: ApiUtils instance declaration added.

The declaration of apiUtils: ApiUtils is consistent with the new imports and prepares for the usage of API utilities in the test suite. This addition supports the enhanced testing framework objective.

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

36-38: Logical improvement approved.

The addition of the conditional check for storageState before checking the "Remember Me" checkbox is a good improvement. It ensures that the checkbox is only checked when necessary, which aligns well with the purpose of the storageState parameter.

Consider adding JSDoc comments for better documentation.

To improve code readability and maintainability, consider adding JSDoc comments to explain the purpose of the storageState parameter and its impact on the method's behavior.

Here's a suggested addition at the beginning of the method:

/**
 * Logs in a user through the frontend.
 * @param user - The user object containing login credentials.
 * @param storageState - Optional. If provided, the "Remember Me" checkbox will be checked
 *                       and the login state will be saved to this path after successful login.
 */
async loginFrontend(user: user, storageState?: string): Promise<void> {
  // ... existing code ...
}

Reminder: Update or add tests for this change.

This behavioral change might require updates to existing tests or new tests to cover both cases (with and without storageState). Ensure that the test suite adequately covers this new conditional logic.

To verify the test coverage for this change, you can run the following command:

This will help identify if there are existing tests that cover the storageState parameter in the loginFrontend method. If no results are found, consider adding new test cases.

tests/pw/tests/e2e/catalogmode.spec.ts (1)

Line range hint 1-108: Summary: Good progress on catalog mode tests with room for improvement

The changes made to the catalog mode tests, particularly the update to the addProductCatalogMode method, align well with the PR objectives of enhancing the testing framework for product addons. The test suite covers various aspects of catalog mode functionality from admin, vendor, and customer perspectives.

To further improve the test suite:

  1. Implement the suggested comment for clarity on the boolean parameter.
  2. Enhance error handling and assertions throughout the tests.
  3. Address the skipped test related to the Dokan issue.

Overall, this PR makes a positive contribution to the project's testing capabilities.

tests/pw/utils/sampleData/products.xml (6)

1-1: LGTM: Updated WordPress version and export date

The changes to the generator version (now 6.6.2) and creation date (2024-09-15) are appropriate and reflect an updated WordPress environment.

Also applies to: 19-19


47-47: Verify if "test description" is the intended content

The content has been simplified to "test description". While this is suitable for testing purposes, please confirm if this is the intended content for your test case.

#!/bin/bash
# Verify the intended content for testing
echo "Current content: test description"
echo "Please confirm if this simplified content is sufficient for your test case or if more detailed content is required."

125-125: Verify category representation change and new meta keys

The following changes have been made:

  1. The chosen_product_cat value now uses an integer representation.
  2. New meta keys _nutrient_ids and _wp_old_slug have been added.

While these changes appear to be intentional, please confirm:

  1. The new category representation is compatible with your current category handling logic.
  2. The purpose and impact of the new meta keys in your product management system.
#!/bin/bash
# Verify category representation and new meta keys
echo "New chosen_product_cat representation: a:1:{i:0;i:15;}"
echo "New meta key: _nutrient_ids"
echo "New meta key: _wp_old_slug"
echo "Please confirm these changes align with your product attribute management strategy."

Also applies to: 128-129, 132-133


97-97: Verify the change in download settings

The download limit and expiry have been changed from -1 to 0. While both values typically represent "unlimited" in WooCommerce, please confirm that this change is intentional and that you understand its implications for product downloadability.

#!/bin/bash
# Verify the download settings change
echo "New download limit: 0"
echo "New download expiry: 0"
echo "Please confirm if changing these values from -1 to 0 is intentional and aligns with your product configuration strategy."

Also applies to: 101-101


41-43: Approve changes and verify product naming convention

The updates to the item title, link, publication date, and post ID are consistent with the new export environment. However, please verify if the change in product naming convention from "p1_v1" to "p0_v1" is intentional and aligns with your current naming standards.

Also applies to: 45-45, 49-51, 54-54

✅ Verification successful

Run verification scripts to ensure consistent product naming conventions

Please execute the following shell script to verify that all product names adhere to the "p0_v1" naming convention:


Product naming convention verified

All product names follow the 'p0_v1' naming convention as intended. No discrepancies found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the product naming convention
echo "New product name: p0_v1"
echo "Please confirm if this naming convention (starting from p0) is correct for your current standards."

Length of output: 517


Script:

#!/bin/bash
# Search for product names not following the 'p0_v1' convention
rg -i --color=never 'title>p[0-9]+_v[0-9]+</title>' tests/pw/utils/sampleData/products.xml | grep -v 'p0_v1' && echo "Inconsistent product naming conventions found." || echo "All product names follow the 'p0_v1' convention."

Length of output: 221


29-30: Verify the channel link and approve other changes

The updates to the channel title, publication date, and base URLs are appropriate for the new export environment. However, please verify if the channel link should indeed be "http://localhost:9999" as this might be specific to a local development setup.

Also applies to: 32-32, 35-36

✅ Verification successful

Channel link is correctly set to localhost for testing purposes

The usage of http://localhost:9999 in the specified files aligns with the testing environment configurations and does not affect the production setup. All instances are appropriately contained within the test directories.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify if the localhost link is intentional or if it should match the base URLs
echo "Channel link: http://localhost:9999"
echo "Base site URL: http://dokan5.test"
echo "Base blog URL: http://dokan5.test"
echo "Please confirm if the channel link should be different from the base URLs."

Length of output: 517


Script:

#!/bin/bash
# Extract the channel link from products.xml and verify its correctness
rg '<link>(.*?)<\/link>' tests/pw/utils/sampleData/products.xml --only-matching --replace '$1'

Length of output: 194


Script:

#!/bin/bash
# Extract the channel link from products.xml and verify its correctness
rg '<link>(.*?)</link>' tests/pw/utils/sampleData/products.xml --only-matching --replace '$1'

Length of output: 151


Script:

#!/bin/bash
# Search the codebase for occurrences of 'http://localhost:9999' to verify its intentional use
rg 'http://localhost:9999' --files-with-matches

Length of output: 189

tests/pw/tests/e2e/vendorBooking.spec.ts (1)

6-7: LGTM: New imports added correctly.

The new imports for dbUtils and dbData are correctly added and follow the existing import style. These imports are necessary for the new operation added in the beforeAll hook.

tests/pw/tests/e2e/products.spec.ts (1)

80-92: LGTM! Verify impact on called methods.

The simplification of product addition method calls improves code readability and maintains consistency across different product type tests. This change aligns with the PR objectives of enhancing the testing framework.

Please ensure that the removal of the false parameter doesn't affect the behavior of the called methods. Run the following script to verify the method signatures:

This will help confirm that the methods can handle calls without the additional parameter.

✅ Verification successful

Verified! The vendor product addition methods no longer require the false parameter, ensuring compatibility with the updated test code.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the signatures of vendor product addition methods

# Test: Search for the method definitions
rg --type typescript -A 5 'vendorAdd(Simple|Variable|SimpleSubscription|VariableSubscription|External)Product'

Length of output: 147


Script:

#!/bin/bash
# Description: Verify the signatures of vendor product addition methods by searching in .ts and .tsx files

# Find all TypeScript files and search for the method definitions
fd --extension ts --extension tsx --type file | xargs rg -A 5 'vendorAdd(Simple|Variable|SimpleSubscription|VariableSubscription|External)Product'

Length of output: 3216

tests/pw/pages/spmvPage.ts (3)

125-125: Consistent application of selector update.

The change from selector.vendor.product.edit.title to selector.vendor.product.title is consistently applied here, matching the update in the goToProductEditFromSpmv method. This consistency is commendable and helps maintain a standardized approach to selectors across the codebase.


104-104: Selector update improves reusability, but verify uniqueness.

The change from selector.vendor.product.edit.title to selector.vendor.product.title makes the selector more generic and potentially more reusable. However, ensure that this selector uniquely identifies the product title field across all relevant pages (e.g., product creation, editing, and viewing pages).

To verify the selector's uniqueness and consistency, run the following script:

#!/bin/bash
# Search for any remaining usage of the old selector
rg --type typescript "selector\.vendor\.product\.edit\.title"

# Search for usage of the new selector to ensure it's used consistently
rg --type typescript "selector\.vendor\.product\.title"

# Search for other selectors that might conflict with the new one
rg --type typescript "selector\.vendor\.product\.[^t][^i][^t][^l][^e].*title"

64-64: Selector update looks good, but verify usage across codebase.

The simplification of the selector from selector.vendor.product.create.addNewProduct to selector.vendor.product.addNewProduct improves readability. However, ensure that this change is consistent with other parts of the codebase that might use this selector.

To verify the selector usage, run the following script:

✅ Verification successful

Selector usage verified successfully. No remaining usage of the old selector found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of the old selector
rg --type typescript "selector\.vendor\.product\.create\.addNewProduct"

# Search for usage of the new selector to ensure it's used consistently
rg --type typescript "selector\.vendor\.product\.addNewProduct"

Length of output: 306


Script:

#!/bin/bash
# Search for any remaining usage of the old selector
rg --type ts "selector\.vendor\.product\.create\.addNewProduct"

# Search for usage of the new selector to ensure it's used consistently
rg --type ts "selector\.vendor\.product\.addNewProduct"

Length of output: 223

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

54-54: LGTM! Verify selector consistency across the codebase.

The change from productsVendor.edit.title to productsVendor.title looks good. This modification simplifies the selector structure, which can improve readability and maintenance.

To ensure consistency, please run the following script to check for any other occurrences of productsVendor.edit.title that might need updating:

✅ Verification successful

Previous script encountered an error. Please run the updated scripts to verify selector consistency.


Please run the following scripts to further verify selector consistency across the codebase.


Selector consistency verified. No remaining instances of productsVendor.edit.title or .edit in productsVendor were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other occurrences of the old selector structure

# Search for the old selector structure
echo "Searching for productsVendor.edit.title:"
rg --type typescript "productsVendor\.edit\.title"

# Search for other potential uses of .edit in the productsVendor object
echo "Searching for other potential uses of .edit in productsVendor:"
rg --type typescript "productsVendor\.edit\."

Length of output: 396


Script:

#!/bin/bash
# Description: Check for other occurrences of the old selector structure

# Searching for productsVendor.edit.title:
echo "Searching for productsVendor.edit.title:"
rg "productsVendor\.edit\.title" --glob "*.ts" --glob "*.tsx"

# Searching for other potential uses of .edit in productsVendor:
echo "Searching for other potential uses of .edit in productsVendor:"
rg "productsVendor\.edit\." --glob "*.ts" --glob "*.tsx"

Length of output: 348


Script:

#!/bin/bash
# Description: Use ast-grep to check for any remaining uses of `.edit` in `productsVendor`

# Searching for property accesses like productsVendor.edit.*
echo "Searching for productsVendor.edit.* using ast-grep:"
ast-grep --lang typescript --pattern 'productsVendor.edit.$$$'

# Searching for any method calls on productsVendor.edit
echo "Searching for method calls on productsVendor.edit using ast-grep:"
ast-grep --lang typescript --pattern 'productsVendor.edit.$_($_$)'

Length of output: 387

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

99-99: New vendor capability added: Group product creation

The addition of vendor can add group product: true expands vendor capabilities, allowing them to create group products. This aligns with the PR objective of enhancing product addon tests.


107-109: New vendor capabilities: Filter reset and product import/export

Three new capabilities have been added for vendors:

  1. vendor can reset filter [lite]: true
  2. vendor can import products: true
  3. vendor can export products: true

These additions enhance vendor control over their product management. The filter reset improves user experience, while import/export capabilities streamline bulk product operations.


110-111: Retained vendor capabilities: Product duplication and deletion

The following capabilities have been retained:

  1. vendor can duplicate product: true
  2. vendor can permanently delete product [lite]: true

Keeping these capabilities ensures vendors maintain control over their product lifecycle.


113-116: Modified vendor capability and removed line

The capability vendor can't buy own product [lite]: true has been retained, which is a good practice to prevent potential conflicts of interest.

There seems to be a removed line after this capability, as indicated by the blank line 116. This removal doesn't appear to cause any issues, but it's worth noting for context.


705-707: New vendor capabilities for product addon management

Three new capabilities have been added for vendors:

  1. vendor can import global product addon field: true
  2. vendor can export global product addon field: true
  3. vendor can remove product addon field: true

These additions significantly enhance vendors' ability to manage product addons, aligning well with the PR objective of improving product addon tests.


710-710: Modified customer capability for product addons

The capability customer can buy product with addon: false has been changed from the previous customer can buy product with addons: false. This change aligns with the AI-generated summary, which mentioned this modification.

However, it's worth noting that this capability is set to false. This might be intentional for testing purposes, but in a production environment, you may want to enable this feature to allow customers to purchase products with addons.

Could you confirm if setting customer can buy product with addon: false is intentional for testing purposes? If not, consider changing it to true to enable this feature for customers.


Line range hint 99-710: Summary of changes to the feature map

The changes in this file significantly enhance vendor capabilities, particularly in the areas of product management and addon handling. Key additions include:

  1. Ability to add group products
  2. Enhanced product filtering and import/export capabilities
  3. Expanded control over global product addon fields

These changes align well with the PR objective of improving product addon tests. The modification to customer capabilities regarding purchasing products with addons (now set to false) may need verification to ensure it's intentional for testing purposes.

Overall, these changes provide a solid foundation for more comprehensive product addon testing and management within the Dokan project.

tests/pw/utils/dbData.ts (2)

Line range hint 1-1422: Overall, the changes look good and well-integrated.

The addition of the rmaSettings object to the vendor property in the dbData object is a clean and structured way to introduce RMA configuration for vendors. The new settings align well with the existing structure of the file and don't introduce any apparent conflicts or issues.


1411-1422: New RMA settings object added for vendor configuration.

The addition of the rmaSettings object within the vendor property is a good enhancement to the configuration. It provides a structured way to manage Return Merchandise Authorization settings for vendors. Here are some observations:

  1. The object includes essential RMA properties such as label, type, policy, and reasons.
  2. Default values are provided for most properties, which is good for initialization.
  3. The reasons array is empty by default, allowing for flexible configuration.
  4. The addon_settings array is also empty, potentially for future extensibility.

To ensure this addition doesn't conflict with existing code, let's verify if there are any other occurrences of RMA-related settings:

This will help us confirm that this is the only place where RMA settings are defined for vendors.

✅ Verification successful

RMA settings addition verified successfully.

The rmaSettings object added to tests/pw/utils/dbData.ts is utilized appropriately across the codebase without any conflicts or duplications.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other RMA-related settings in the codebase
rg --type typescript "rma.*Settings" -g '!tests/pw/utils/dbData.ts'

Length of output: 104


Script:

#!/bin/bash
# Search for other RMA-related settings in TypeScript files excluding the specified file
rg "rma.*Settings" -g '*.ts' -g '!tests/pw/utils/dbData.ts' -A 2

Length of output: 1534

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

1087-1113: LGTM! Consider adding documentation.

The new createProductAddon method is a valuable addition, providing a structure for individual product add-ons. The use of faker for generating unique names is excellent for testing purposes.

To enhance maintainability:

  1. Consider adding a brief JSDoc comment explaining the purpose and usage of this method.
  2. If this is part of a new feature, ensure that corresponding test cases are created or updated.

178-214: Verify the impact of removing _dokan_min_max_meta.

The block related to _dokan_min_max_meta has been removed. This change could affect how minimum and maximum quantities are handled for products.

Please confirm that this removal is intentional and verify its impact on:

  1. Product quantity restrictions
  2. Order validation processes
  3. Any functions or components that relied on min/max quantity metadata

Run the following script to check for other occurrences of _dokan_min_max_meta in the codebase:

#!/bin/bash
# Search for other occurrences of _dokan_min_max_meta
rg --type typescript "_dokan_min_max_meta"

429-429: Verify the impact of changing default delivery time.

The _default_delivery_time value has been changed from -1 to 1. This change could significantly affect delivery time calculations throughout the system.

Please confirm that this change is intentional and verify its impact on:

  1. Order processing
  2. Shipping estimates
  3. Any functions or components that rely on the default delivery time

Run the following script to check for other occurrences of _default_delivery_time in the codebase:

#!/bin/bash
# Search for other occurrences of _default_delivery_time
rg --type typescript "_default_delivery_time"

Line range hint 717-746: LGTM! Consider reviewing for consistency.

The renaming of createProductAddons to createGlobalProductAddons is a good change that clarifies the method's purpose. The structure remains sound.

Note the minor change in the option label from 'Option 1' to 'option 1'. Ensure this change is consistent with your naming conventions across the codebase.

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

56-56: 🛠️ Refactor suggestion

Ensure correct usage of updated destructuring

Adjust the destructuring to use named properties for clarity.

Update the code:

- await vendor.editAddon({ ...data.vendor.addon(), name: addonName, title: addonFieldTitle });
+ await vendor.editAddon({ ...data.vendor.addon(), name: addonName, title: addonFieldTitle });

(Note: Confirm that addonName and addonFieldTitle are correctly obtained from the object.)

Likely invalid or redundant comment.


51-51: 🛠️ Refactor suggestion

Adjust function call to use named parameters

With the updated return type of createVendorProductAddon, use named properties when calling addAddon.

Update the code:

- await vendor.addAddon({ ...data.vendor.addon(), category: categoryName });
+ await vendor.addAddon({ ...data.vendor.addon(), category: categoryName });

(Note: If categoryName remains the same, ensure consistency in how parameters are passed.)

Likely invalid or redundant comment.

tests/pw/pages/vendorSettingsPage.ts (5)

12-15: Consistent Declaration of Selector Constants

The new selector constants for ShipStation, Social Profile, Store SEO, and RMA settings are appropriately defined and enhance code readability.


101-110: Visibility Checks Implemented Correctly for Social Profile Settings

The vendorSocialProfileSettingsRenderProperly method effectively verifies the visibility of all necessary social profile elements.


141-164: Efficient Handling of Store SEO Elements

The method vendorStoreSeoSettingsRenderProperly efficiently checks the visibility of Store SEO elements and uses destructuring to manage Facebook and Twitter selectors effectively.


428-429: Correctly Setting Minimum and Maximum Order Amounts

The code properly sets the minimum and maximum amounts required to place an order, ensuring correct functionality.


480-515: Ensure Proper Handling of RMA Settings Logic

The setRmaSettings method contains nested conditional logic based on rma.type and rma.length. Ensure that all possible types and lengths are correctly handled and that there are no missing cases.

To confirm that all rma.type and rma.length combinations are accounted for, run the following script:

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

6-6: Import statement is correct

The import of product from @utils/interfaces is appropriate and ensures type definitions are available.


13-13: Variable declaration aligns with naming conventions

The declaration of vendorTools enhances code readability and maintains consistency with existing variable names.


263-263: Validation of 'Add New Product' button visibility

Ensuring that the 'Add New Product' button is visible confirms the correct rendering of the vendor products page.


290-292: New method 'goToAddNewProduct' improves code reuse

The goToAddNewProduct method abstracts the navigation logic, promoting reusability and reducing code duplication.


381-381: [Duplicate] Address the TODO comment to add more assertions

As mentioned earlier, ensure that additional assertions are added to verify the variable subscription product is correctly saved and configured.


386-398: 'vendorAddExternalProduct' method is properly implemented

The method correctly handles the addition of an external product, setting all necessary fields appropriately.


402-418: 'vendorAddGroupProduct' method effectively adds grouped products

The method successfully adds grouped products by iterating over groupedProducts and verifying their inclusion.


486-489: 'saveProduct' method encapsulates save logic effectively

The saveProduct method centralizes the save action and success verification, improving maintainability.


540-540: Ensure import completion message is locale-independent

The assertion relies on the text 'Import complete!' to confirm success. If the application is localized, this text might change. Use identifiers or a localization-aware approach to ensure the test remains reliable across different languages.


637-644: 'addProductCatalogMode' method correctly updates catalog settings

The method appropriately modifies the product's catalog mode options and verifies the changes.


646-679: 'addProductEuCompliance' method thoroughly sets EU compliance fields

The method comprehensively sets all EU compliance fields and verifies their values, ensuring adherence to regulations.


681-690: 'addProductWholesaleOptions' method properly configures wholesale settings

The method effectively enables wholesale options for the product and confirms the settings are correctly applied.


296-306: 🛠️ Refactor suggestion

Verify necessity of post-save assertions

After calling saveProduct(), the method asserts the input fields' values. If the page reloads or navigates, these assertions might not be valid. Ensure that checking the field values after saving is necessary and reliable. Consider verifying the product creation by checking its presence in the product list instead.

tests/pw/utils/interfaces.ts (2)

52-57: LGTM!

The discount property is correctly defined with appropriate optional parameters. This addition enhances the product interface.


1039-1039: LGTM!

The properties facebookImage and twitterImage have been appropriately added to the seo interface.

Also applies to: 1042-1042

tests/pw/utils/testData.ts (5)

287-294: Addition of 'grouped' product type is well-implemented

The definition of the grouped product type is correctly added and follows the structure of other product types.


549-550: Confirm the increase of 'minimumQuantity' to '100' in quantity discounts

The minimumQuantity in quantityDiscount is updated from '10' to '100'. Ensure that this change aligns with the intended test scenarios and that any dependent tests or logic are adjusted accordingly.


555-555: Confirm 'minimumQuantity' value in wholesale options

The minimumQuantity in wholesaleOption is set to '10'. Verify that this value is appropriate for the tests and consistent with the intended wholesale policies.


1457-1457: Addition of 'threads' to social profiles

The addition of the 'threads' social media link is noted. Ensure that any functionality relying on this new link is properly implemented and tested.


1465-1473: Review the 'addon' configuration in RMA settings

An addon object has been added to the RMA settings with fields like cost, durationLength, and durationType. Verify that these fields are correctly utilized in the RMA logic and that they conform to the expected data structures.

tests/pw/tests/api/productReviews.spec.ts Show resolved Hide resolved
</wp:postmeta>
<wp:postmeta>
<wp:meta_key>_stock</wp:meta_key>
<wp:meta_value><![CDATA[]]></wp:meta_value>
<wp:meta_value><br /><![CDATA[]]></wp:meta_value>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Approve version update, but verify stock value change

The product version update to 9.2.3 is appropriate and likely reflects a WooCommerce update. However, the addition of a line break in the stock value is unusual and might cause issues with stock management.

Please remove the line break from the stock value to ensure proper stock management:

-			<wp:meta_value><br /><![CDATA[]]></wp:meta_value>
+			<wp:meta_value><![CDATA[]]></wp:meta_value>

Also applies to: 121-121

tests/pw/tests/e2e/productAddons.spec.ts Show resolved Hide resolved
Comment on lines +75 to +76
const [, , addonName] = await createVendorProductAddon();
await vendor.removeAddon({ ...data.vendor.addon(), name: addonName });
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify destructuring and parameter passing

With the updated return value, destructure the needed properties and pass them directly for improved readability.

Update the code:

- const [, , addonName] = await createVendorProductAddon();
+ const { addonName } = await createVendorProductAddon();

await vendor.removeAddon({ ...data.vendor.addon(), name: addonName });

Committable suggestion was skipped due to low confidence.

tests/pw/tests/e2e/productAddons.spec.ts Show resolved Hide resolved
tests/pw/utils/interfaces.ts Show resolved Hide resolved
tests/pw/utils/interfaces.ts Show resolved Hide resolved
tests/pw/utils/interfaces.ts Show resolved Hide resolved
tests/pw/utils/interfaces.ts Show resolved Hide resolved
Comment on lines +164 to 166
addTitle: 'h1.wp-block-post-title',
contentPlaceholder: 'p[aria-label="Add default block"]',
addContent: '//p[@data-title="Paragraph"]',
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use consistent selector types throughout the codebase.

The selectors addTitle and contentPlaceholder use CSS selectors, while addContent uses an XPath expression. To maintain consistency and improve readability, consider converting all selectors to CSS selectors wherever possible.

Apply this diff to update the addContent selector:

-            addContent: '//p[@data-title="Paragraph"]',
+            addContent: 'p[data-title="Paragraph"]',
📝 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
addTitle: 'h1.wp-block-post-title',
contentPlaceholder: 'p[aria-label="Add default block"]',
addContent: '//p[@data-title="Paragraph"]',
addTitle: 'h1.wp-block-post-title',
contentPlaceholder: 'p[aria-label="Add default block"]',
addContent: 'p[data-title="Paragraph"]',

@shashwatahalder01 shashwatahalder01 added the QA approved This PR is approved by the QA team label Sep 27, 2024
@shashwatahalder01 shashwatahalder01 merged commit 6f26f80 into getdokan:develop Sep 27, 2024
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Sep 30, 2024
12 tasks
@shashwatahalder01 shashwatahalder01 deleted the products branch September 30, 2024 04:18
@coderabbitai coderabbitai bot mentioned this pull request Oct 1, 2024
12 tasks
shashwatahalder01 added a commit to shashwatahalder01/dokan that referenced this pull request Oct 1, 2024
* Add product addon tests(automation suite) (getdokan#2381)

* Update: refactor product import tests

* Fix: fix a invalid endpoint reference

* Update: login rememberme condition

* Update: refactor vendor settings, products,

* Add: add product addon tests

* Fix: lint issues

* Update: update feature map

* fix: duplicate test methods in DokanTestCase.php (getdokan#2382)

* Add: add product edit tests

* Add product tests

* Fix: remove duplicate entry of feature map

---------

Co-authored-by: Al Amin Ahamed <[email protected]>
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