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 privacy policy tests (automation suite) #2378

Merged
merged 6 commits into from
Sep 24, 2024

Conversation

shashwatahalder01
Copy link
Contributor

@shashwatahalder01 shashwatahalder01 commented Sep 24, 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

    • Introduced new methods for enhanced navigation and response handling in various pages, including dropdown selection and store navigation.
    • Added a comprehensive array of menu options to the menu manager.
  • Bug Fixes

    • Updated test cases to ensure correct functionality and visibility assertions across multiple pages.
  • Documentation

    • Streamlined test setup and execution by removing unused variables and improving clarity.
  • Refactor

    • Improved navigation logic and visibility handling in the PrivacyPolicyPage and StoreListingPage classes.

@shashwatahalder01 shashwatahalder01 self-assigned this Sep 24, 2024
Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Walkthrough

The pull request introduces several enhancements across multiple page classes in the testing framework. Key changes include the addition of new methods for handling dropdown selections and navigation, modifications to existing methods for improved loading and visibility checks, and updates to CSS selectors for consistency. Additionally, the test suites have been adjusted to activate previously skipped tests and refine data structures used in settings. Overall, these changes aim to streamline navigation and interaction logic within the application.

Changes

Files Change Summary
tests/pw/pages/basePage.ts Added method selectByValueAndWaitForResponseAndLoadState to select dropdown options and wait for network responses.
tests/pw/pages/customerPage.ts Added method gotoSingleStore for navigating to a specific store's details page.
tests/pw/pages/privacyPolicyPage.ts Updated to extend CustomerPage, modified navigation methods for improved loading and visibility checks.
tests/pw/pages/selectors.ts Updated CSS selectors for storeContactForm to a more modern syntax.
tests/pw/pages/settingsPage.ts Changed method parameter type in setDokanMenuManagerSettings from dokanSettings['menuManager'] to string[].
tests/pw/pages/singleStorePage.ts Replaced goIfNotThere with gotoSingleStore in multiple methods, updated sorting method to use the new selection method, and added assertions for product cards.
tests/pw/pages/storeListingPage.ts Replaced goIfNotThere with gotoUntilNetworkidle, updated sorting logic, and simplified filtering method.
tests/pw/pages/withdrawsPage.ts Added visibility assertion for withdraw cell in WithdrawsPage.
tests/pw/tests/e2e/privacyPolicy.spec.ts Activated previously skipped test suite and simplified test setup.
tests/pw/tests/e2e/productAdvertising.spec.ts Marked three test cases as potentially slower with test.slow() annotation.
tests/pw/tests/e2e/settings.spec.ts Updated argument for setDokanMenuManagerSettings to focus on menus property.
tests/pw/tests/e2e/singleStore.spec.ts Activated previously skipped test case for viewing store terms and conditions.
tests/pw/utils/dbData.ts Modified privacyPolicySettings and sideBarsWidgets properties for clarity and introduced emptySideBarsWidgets.
tests/pw/utils/testData.ts Added a new menus array in menuManager with various menu options.

Possibly related PRs

  • Add Api tests, Fix coverage issue #2376: Updates the SingleStorePage class by changing method selectByValueAndWaitForResponse to selectByValueAndWaitForResponseAndLoadState, which is directly related to the new method added in this PR.

🐇 In the land of code where the rabbits play,
New methods hop in to brighten the day.
With selectors so sleek and tests that now run,
Navigation's a breeze, oh what coding fun!
So let’s celebrate with a joyful cheer,
For every new feature brings us all near! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range and nitpick comments (18)
tests/pw/tests/e2e/privacyPolicy.spec.ts (1)

Issue: Remaining references to customerPage found

The customerPage variable is still referenced in several test files, which may affect code cleanliness and functionality.

Please address the remaining references in the following files:

  • tests/pw/tests/e2e/wholesaleCustomers.spec.ts
  • tests/pw/tests/e2e/vendorReturnRequest.spec.ts
  • tests/pw/tests/e2e/euCompliance.spec.ts
  • tests/pw/tests/e2e/customer.spec.ts
Analysis chain

Line range hint 8-46: Approval: Removal of unused variable

The removal of the customerPage variable improves code cleanliness by eliminating unused declarations.

Please verify:

  1. The customerPage variable is indeed no longer needed in any of the tests.
  2. Its removal doesn't affect any test cases or setup.

You can run the following command to check if there are any remaining references to customerPage in this file or related test files:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to customerPage in test files

rg --type typescript 'customerPage' tests/pw/tests/e2e/

Length of output: 205


Script:

#!/bin/bash
# Description: Check for any remaining references to 'customerPage' in TypeScript test files

rg 'customerPage' tests/pw/tests/e2e/ --type-add 'typescript:*.ts' --type typescript

Length of output: 1742

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

22-22: LGTM! Consider adding a comment for clarity.

The change from goIfNotThere to gotoSingleStore is a good improvement for consistency. The new method signature with storeName parameter allows for more flexible testing.

Consider adding a brief comment explaining the purpose of gotoSingleStore for better code readability:

+  // Navigate to the specified store's page
   await this.gotoSingleStore(storeName);

62-64: LGTM! Consider adding error handling.

The changes improve the method's functionality and reliability. The new assertion ensures that products are present after sorting, which is a good addition.

Consider adding error handling to provide more informative feedback if the assertion fails:

   await this.gotoSingleStore(storeName);
   await this.selectByValueAndWaitForResponseAndLoadState(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), singleStoreCustomer.sortBy, sortBy);
-  await this.notToHaveCount(singleStoreCustomer.productCard.card, 0);
+  try {
+    await this.notToHaveCount(singleStoreCustomer.productCard.card, 0);
+  } catch (error) {
+    throw new Error(`No product cards found after sorting by ${sortBy}. Original error: ${error.message}`);
+  }

96-96: LGTM! Consider enhancing type safety.

The change from goIfNotThere to gotoSingleStore is consistent with the improvements in other methods, contributing to a more uniform test suite.

To improve type safety, consider using a type assertion or a type guard when accessing singleStoreCustomer.sharePlatForms[site]. This can help prevent runtime errors if an invalid site is provided:

type SharePlatform = keyof typeof singleStoreCustomer.sharePlatForms;

async storeShare(storeName: string, site: SharePlatform): Promise<void> {
  // ... existing code ...
  
  if (!(site in singleStoreCustomer.sharePlatForms)) {
    throw new Error(`Invalid share platform: ${site}`);
  }
  
  await this.toHaveAttribute(singleStoreCustomer.sharePlatForms[site], 'target', '_blank');
  await this.setAttributeValue(singleStoreCustomer.sharePlatForms[site], 'target', '_self');
  await this.clickAndWaitForUrl(new RegExp('.*' + site + '.*'), singleStoreCustomer.sharePlatForms[site]);
}

This change ensures that site is a valid key of sharePlatForms at compile-time and runtime.

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

Line range hint 105-111: Consistent use of test.slow() with suggestion for improvement

The addition of test.slow() here maintains consistency with the previous tests and is appropriate for this potentially time-consuming test involving auction product advertising.

Consider extracting the common test.slow() configuration to a higher level, such as the describe block or a custom test function, to improve maintainability. For example:

const slowTest = test.extend({
  test: async ({ test }, use) => {
    await use(test.slow());
  },
});

// Then use it like this:
slowTest('vendor can buy auction product advertising', async ({ page }) => {
  // Test logic here
});

This approach would allow you to easily apply the slow configuration to multiple tests without repeating the test.slow() call in each test.

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

73-75: Improved sorting logic and verification

The changes in this method are well-thought-out:

  1. Using goToStoreList() simplifies navigation and maintains consistency.
  2. selectByValueAndWaitForResponseAndLoadState ensures the page is fully loaded after sorting.
  3. The added check for store cards verifies the sorting operation's success.

These improvements enhance the reliability of the sorting test.

Consider adding an assertion message to the notToHaveCount check for better error reporting:

await this.notToHaveCount(storeList.storeCard.storeCardDiv, 0, 'No store cards found after sorting');

99-99: Consistent navigation and potential improvement

The change to use goToStoreList() is consistent with other methods and simplifies the navigation logic. This improves code maintainability and readability.

Consider adding error handling for the case where the store is not found after searching:

const storeVisible = await this.isVisible(storeList.visitStore(storeName));
if (!storeVisible) {
    throw new Error(`Store "${storeName}" not found after search`);
}

This addition would make the test more robust by explicitly handling failure cases.


108-108: Improved consistency and code cleanliness

The changes in this method are positive:

  1. Using goToStoreList() maintains consistency with other methods.
  2. Removal of commented-out code improves overall code cleanliness.

These changes enhance readability and maintainability.

Consider extracting the filter logic into separate private methods for each filter type. This would improve the method's readability and make it easier to maintain. For example:

private async filterByLocation(value: string): Promise<void> {
    await this.typeAndWaitForResponse(data.subUrls.gmap, storeList.filters.filterDetails.location, value);
    await this.click(storeList.mapResultFirst);
}

// Similar methods for other filter types

async filterStores(filterBy: string, value?: string): Promise<void> {
    await this.goToStoreList();
    await this.click(storeList.filters.filterButton);

    switch (filterBy) {
        case 'by-location':
            await this.filterByLocation(value!);
            break;
        // Other cases...
    }

    // Rest of the method...
}

This refactoring would make the filterStores method more concise and easier to understand.


144-144: Consistent navigation and potential improvement

The change to use goToStoreList() is consistent with other methods and simplifies the navigation logic. This improves code maintainability and readability.

Consider adding error handling for the case where the store is not found on the map:

if (storeName) {
    const storeOnList = await this.isVisible(storeList.map.storeOnMap.storeOnList(storeName));
    if (!storeOnList) {
        throw new Error(`Store "${storeName}" not found on the map`);
    }
}

This addition would make the test more robust by explicitly handling failure cases.

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

117-117: LGTM! Consider adding a timeout for better reliability.

The addition of this assertion is a good improvement to verify that the UI updates correctly after processing a withdraw request. It ensures that the withdraw cell for the given vendor is no longer visible, which is the expected behavior after approving, canceling, or deleting a request.

To improve the reliability of this test, especially in cases where the UI might take a moment to update, consider adding a timeout to the notToBeVisible assertion. For example:

await this.notToBeVisible(withdrawsAdmin.withdrawCell(vendorName), { timeout: 5000 });

This gives the UI up to 5 seconds to update, reducing the chance of false negatives in slower environments.


Line range hint 1-265: Great addition to improve test coverage. Consider expanding assertions for other scenarios.

The addition of the visibility check after updating a withdraw request is a valuable improvement to the test coverage. It ensures that the UI correctly reflects the changes made to withdraw requests, which is crucial for maintaining the integrity of financial operations in the system.

To further enhance the testing framework, consider the following suggestions:

  1. Add similar visibility checks to other methods that modify the state of withdraw requests, such as withdrawBulkAction.

  2. Implement more granular assertions for different action types in updateWithdrawRequest. For example, after an 'approve' action, you might want to check if the request moves to an 'approved' list or changes its status indicator.

  3. Consider adding error scenario testing. For instance, what happens if a withdraw request fails to update? How does the UI respond, and how can we assert this behavior?

  4. If not already implemented elsewhere, consider adding integration tests that cover the full lifecycle of a withdraw request from creation to final state (approved, cancelled, or deleted).

These suggestions aim to create a more comprehensive testing suite that covers various scenarios and edge cases, further improving the reliability of the withdraws feature.

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

48-50: LGTM! Consider adding error handling.

The new gotoSingleStore method is a good addition to the CustomerPage class. It uses the helpers.slugify function to create a URL-friendly version of the store name, which is a good practice. The method also uses the existing goIfNotThere method, promoting code reuse.

However, consider adding error handling for cases where the storeName might be invalid or the navigation fails.

Here's a suggestion to add basic error handling:

 async gotoSingleStore(storeName: string): Promise<void> {
+    if (!storeName) {
+        throw new Error('Store name cannot be empty');
+    }
-    await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), 'networkidle');
+    try {
+        await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), 'networkidle');
+    } catch (error) {
+        throw new Error(`Failed to navigate to store: ${storeName}. ${error.message}`);
+    }
 }

Line range hint 1-594: Consider improving class structure and documentation.

While the new gotoSingleStore method is a good addition, there are some general improvements that could enhance the overall quality and maintainability of the CustomerPage class:

  1. Group related methods: The class contains many methods. Consider grouping related methods using comments or regions for better organization.

  2. Add JSDoc comments: Add JSDoc comments to methods, especially public ones, to improve code documentation and IDE support.

  3. Consider breaking down large methods: Some methods like placeOrder and getOrderDetails are quite long. Consider breaking them down into smaller, more focused methods.

  4. Consistent error handling: Implement a consistent error handling strategy across all methods, similar to what was suggested for gotoSingleStore.

  5. Use TypeScript interfaces: For complex parameter objects (like in addBillingAddress), consider defining and using TypeScript interfaces for better type checking and code clarity.

Here's an example of how you could start implementing these suggestions:

/**
 * Represents a customer page with various customer-related operations.
 */
export class CustomerPage extends BasePage {
    constructor(page: Page) {
        super(page);
    }

    // Navigation methods
    // -----------------

    /**
     * Navigates to a single store page.
     * @param storeName The name of the store to navigate to.
     * @throws {Error} If the store name is empty or navigation fails.
     */
    async gotoSingleStore(storeName: string): Promise<void> {
        if (!storeName) {
            throw new Error('Store name cannot be empty');
        }
        try {
            await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), 'networkidle');
        } catch (error) {
            throw new Error(`Failed to navigate to store: ${storeName}. ${error.message}`);
        }
    }

    // ... other navigation methods ...

    // Order processing methods
    // ------------------------

    /**
     * Places an order with the specified payment method.
     * @param paymentMethod The payment method to use.
     * @param getOrderDetails Whether to return order details.
     * @param billingAddress Whether to add a billing address.
     * @param shippingAddress Whether to add a shipping address.
     * @returns The order number or order details object.
     */
    async placeOrder(
        paymentMethod: 'bank' | 'check' | 'cod' | 'stripe' | 'stripeExpress' = 'bank',
        getOrderDetails = false,
        billingAddress = false,
        shippingAddress = false
    ): Promise<string | object> {
        // ... implementation ...
    }

    // ... other methods ...
}

This structure provides better organization, documentation, and type safety.

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

Line range hint 272-286: LGTM! Consider adding error handling.

The changes to setDokanMenuManagerSettings improve its flexibility by accepting an array of menu names instead of a hardcoded list. This allows for dynamic configuration of menu items, which is a good improvement.

Consider adding error handling for cases where a menu item in the menus array doesn't have a corresponding switcher. This could be done by checking if the switcher exists before trying to enable it:

 async setDokanMenuManagerSettings(menus: string[]) {
     await this.goToDokanSettings();
     await this.click(settingsAdmin.menus.menuManager);

     // menuManager Settings
     for (const menu of menus) {
-        await this.enableSwitcher(settingsAdmin.menuManager.menuSwitcher(menu));
+        const switcher = settingsAdmin.menuManager.menuSwitcher(menu);
+        if (await this.isVisible(switcher)) {
+            await this.enableSwitcher(switcher);
+        } else {
+            console.warn(`No switcher found for menu: ${menu}`);
+        }
     }

     // save settings
     await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.menuManager.menuManagerSaveChanges);

     for (const menu of menus) {
-        await this.toHaveBackgroundColor(settingsAdmin.menuManager.menuSwitcher(menu) + '//span', 'rgb(0, 144, 255)');
+        const switcher = settingsAdmin.menuManager.menuSwitcher(menu);
+        if (await this.isVisible(switcher)) {
+            await this.toHaveBackgroundColor(switcher + '//span', 'rgb(0, 144, 255)');
+        }
     }
 }

This change will make the method more robust by handling potential mismatches between the input array and available switchers.


Line range hint 1-1024: Consider applying similar flexibility to other setting methods.

The improvement made to setDokanMenuManagerSettings by accepting an array of menu names could potentially be applied to other similar methods in this class. This would increase the overall flexibility and reusability of the SettingsPage class.

In future refactoring efforts, consider reviewing other methods in this class that use hardcoded lists or specific types. Applying a similar pattern of accepting arrays or more generic types could make the entire class more adaptable to changes in the Dokan settings structure.

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

1344-1344: Consider removing the redundant emptySideBarsWidgets property.

A new property emptySideBarsWidgets has been added with an empty wp_inactive_widgets array. This seems redundant as it's just an empty array and doesn't provide any additional functionality.

Consider removing this property if it's not used elsewhere in the codebase. If it is needed, please add a comment explaining its purpose.

Run the following script to check for any usage of emptySideBarsWidgets in the codebase:

#!/bin/bash
# Search for usage of emptySideBarsWidgets in the codebase
rg --type js --type ts "emptySideBarsWidgets"
tests/pw/pages/basePage.ts (1)

817-821: LGTM! Consider adding a JSDoc comment for consistency.

The new selectByValueAndWaitForResponseAndLoadState method is well-implemented and consistent with other similar methods in the class. It effectively combines selecting an option, waiting for a response, and waiting for the load state.

For consistency with other methods in this class, consider adding a JSDoc comment to describe the method's purpose, parameters, and return value. For example:

/**
 * Selects an option by value, waits for a specific response, and ensures the page has finished loading.
 * @param subUrl - The sub-URL to wait for in the response.
 * @param selector - The selector for the dropdown element.
 * @param value - The value to select in the dropdown.
 * @param code - The expected status code of the response (default: 200).
 * @returns A Promise that resolves to the Response object.
 */
tests/pw/utils/testData.ts (1)

1966-1988: LGTM! Consider adding a comment for the commented-out menu item.

The addition of the menus array to the menuManager object is a good enhancement. It provides a comprehensive list of vendor dashboard functionalities, which will improve the menu management system.

Consider adding a comment explaining why the 'Subscription' menu item is commented out. This will help other developers understand if it's a work in progress or if there's a specific reason for its exclusion.

 // 'Subscription',
+// TODO: Uncomment when subscription feature is ready
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4ce4e2d and 2917acb.

Files selected for processing (14)
  • tests/pw/pages/basePage.ts (1 hunks)
  • tests/pw/pages/customerPage.ts (1 hunks)
  • tests/pw/pages/privacyPolicyPage.ts (4 hunks)
  • tests/pw/pages/selectors.ts (1 hunks)
  • tests/pw/pages/settingsPage.ts (1 hunks)
  • tests/pw/pages/singleStorePage.ts (3 hunks)
  • tests/pw/pages/storeListingPage.ts (5 hunks)
  • tests/pw/pages/withdrawsPage.ts (1 hunks)
  • tests/pw/tests/e2e/privacyPolicy.spec.ts (1 hunks)
  • tests/pw/tests/e2e/productAdvertising.spec.ts (1 hunks)
  • tests/pw/tests/e2e/settings.spec.ts (1 hunks)
  • tests/pw/tests/e2e/singleStore.spec.ts (1 hunks)
  • tests/pw/utils/dbData.ts (3 hunks)
  • tests/pw/utils/testData.ts (1 hunks)
Additional context used
Biome
tests/pw/pages/privacyPolicyPage.ts

[error] 12-14: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

Additional comments not posted (19)
tests/pw/tests/e2e/singleStore.spec.ts (1)

38-40: Approved: Test case activation enhances coverage. Clarification needed on privacy policy testing.

The activation of this test case for store terms and conditions is a positive step towards improving the testing framework. However, I have a few points to discuss:

  1. The PR objectives mention adding privacy policy tests, but this test seems to focus on terms and conditions. Could you clarify if this test is intended to cover privacy policy aspects as well, or if there are plans to add separate privacy policy tests?

  2. If privacy policy testing is a separate concern, consider adding specific test cases for it to fully meet the PR objectives.

To ensure we're not missing any privacy policy related tests, let's check the entire test suite:

Verification successful

Verified: Privacy policy related tests are present in the test suite.

The search confirmed that there are existing privacy policy tests in the following files:

  • tests/pw/tests/e2e/privacyPolicy.spec.ts
  • tests/pw/tests/e2e/settings.spec.ts

This ensures that the PR's focus on activating and adding relevant tests aligns with the existing testing framework.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for privacy policy related tests in the test suite

# Test: Search for privacy policy related test cases
echo "Searching for privacy policy related tests:"
rg --type typescript 'test\(.*privacy policy' tests/

Length of output: 186


Script:

#!/bin/bash
# Description: Search for privacy policy related tests in the test suite

# Adjusted Test: Search for privacy policy related test cases without specifying type
echo "Searching for privacy policy related tests:"
rg 'test\(.*privacy policy' tests/

Length of output: 570

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

Line range hint 1-46: Summary: Improvements to Privacy Policy & Store Contact form test suite

The changes made to this test suite are generally positive:

  1. Activation of previously skipped tests
  2. Addition of cleanup steps in the afterAll hook
  3. Removal of unused variables

These changes align with good testing practices and should improve the overall quality and reliability of the test suite. Please ensure all suggested verifications are performed to confirm the changes don't introduce any unintended side effects.


23-23: Approval: Test environment cleanup

The addition of await dbUtils.setOptionValue('sidebars_widgets', dbData.widget.emptySideBarsWidgets); in the afterAll hook is a good practice for cleaning up the test environment.

Please verify:

  1. Is this cleanup necessary for all tests in the suite, or is it specific to certain tests?
  2. Are there any other options or states that should be reset after the tests?

You can run the following command to check for other places where 'sidebars_widgets' is being set or used:

#!/bin/bash
# Description: Check for other occurrences of 'sidebars_widgets' in the test files

rg --type typescript 'sidebars_widgets' tests/pw/tests/e2e/

8-8: Approval: Test suite activation

The change from test.describe.skip to test.describe activates the previously skipped test suite, which is a positive step towards increasing test coverage.

Please verify that:

  1. All tests in this suite are ready to be run.
  2. There are no outstanding issues that previously necessitated skipping these tests.
  3. The test environment is properly set up to support these tests.

You can run the following command to check if there are any remaining skipped tests or TODOs in this file:

#!/bin/bash
# Description: Check for skipped tests or TODOs in the privacyPolicy.spec.ts file

rg --type typescript '(test\.skip|TODO)' tests/pw/tests/e2e/privacyPolicy.spec.ts
tests/pw/pages/singleStorePage.ts (4)

69-69: LGTM! Consistent improvement.

The change from goIfNotThere to gotoSingleStore is consistent with the improvements made in other methods. This enhances the overall consistency of the test suite.


77-77: LGTM! Consistent improvement.

The change from goIfNotThere to gotoSingleStore maintains consistency with the improvements made in other methods. This enhances the overall reliability of the test suite.


89-89: LGTM! Consistent improvement.

The change from goIfNotThere to gotoSingleStore aligns with the improvements made in other methods. This contributes to a more consistent and maintainable test suite.


Line range hint 1-105: Overall, the changes improve test suite consistency and flexibility.

The modifications across all methods in this file follow a consistent pattern:

  1. Updating method signatures to include a storeName parameter.
  2. Replacing goIfNotThere with gotoSingleStore.

These changes enhance the test suite's flexibility by allowing easier testing of different stores. The consistent use of gotoSingleStore likely improves navigation reliability in tests.

A few minor suggestions have been made to further improve code clarity and type safety. Consider implementing these suggestions to make the test suite even more robust and maintainable.

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

89-95: Appropriate use of test.slow()

The addition of test.slow() is a good practice for this test. It acknowledges that this particular test may take longer to execute due to its multiple steps (creating a product, buying advertising, updating order status, and asserting the result). This change helps prevent potential timeout issues and improves the reliability of the test suite.


97-103: Consistent use of test.slow()

The addition of test.slow() here is consistent with the previous test and equally appropriate. This test involves creating a bookable product, which may be more complex and time-consuming than a simple product. The change helps ensure the test has sufficient time to complete all its steps without timing out.


Line range hint 89-111: Overall assessment of changes

The changes made to this file are consistent and appropriate. Adding test.slow() to these three vendor tests acknowledges their potentially longer execution times due to complex operations like creating products, buying advertising, and verifying results. This improvement enhances the reliability of the test suite by reducing the likelihood of timeout-related failures.

The changes align well with the PR objectives of enhancing the testing framework and ensuring proper functionality. They contribute to a more robust automation suite for privacy policy tests (and related e-commerce functionalities).

Consider the earlier suggestion about extracting the test.slow() configuration for improved maintainability. Otherwise, these changes are ready for approval.

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

60-60: LGTM! Consider verifying data structure usage.

The change from data.dokanSettings.menuManager to data.dokanSettings.menuManager.menus looks good. It appears to be a refinement in the test to be more specific about what's being set in the Dokan menu manager settings.

To ensure consistency across the codebase:

  1. Verify that this change in data structure is reflected in other parts of the codebase where data.dokanSettings.menuManager might be used.
  2. Update any relevant documentation to reflect this change in the data structure.

You can use the following script to check for other occurrences of data.dokanSettings.menuManager:

If there are any matches, consider updating them to use data.dokanSettings.menuManager.menus if appropriate.

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

24-24: Improved page loading strategy

The change from goIfNotThere to gotoUntilNetworkidle is a good improvement. This modification ensures that the page is fully loaded before proceeding, which can lead to more reliable and consistent test results.


80-80: Consistent navigation logic

The change to use goToStoreList() instead of conditional navigation is a good improvement. This modification aligns with changes in other methods, promoting consistency throughout the class. It simplifies the navigation logic and makes the code more maintainable.


Line range hint 1-168: Overall improvements enhance test suite reliability and maintainability

The changes made to this file consistently improve the navigation logic across multiple methods by using goToStoreList(). This standardization enhances the maintainability and readability of the test suite. The modifications, such as waiting for network idle states and adding verification steps, also contribute to increased reliability of the tests.

These improvements align well with best practices for test automation and will likely result in more stable and consistent test runs. The suggestions provided for error handling and code organization, if implemented, would further enhance the robustness of these tests.

Great job on these improvements! They significantly contribute to the overall quality of the test suite.

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

Line range hint 1-594: Overall, good addition with room for improvement.

The addition of the gotoSingleStore method is a positive change that extends the functionality of the CustomerPage class. However, as the class grows, consider implementing the suggested improvements to enhance code organization, documentation, and maintainability. These changes will make the code more robust and easier for other developers to understand and work with in the future.

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

1330-1334: Verify the impact of widget removal from wp_inactive_widgets and sidebar-store.

The changes in the widget configuration might affect the site's user interface:

  1. wp_inactive_widgets array has been emptied.
  2. sidebar-store array now only contains 'dokan-store-contact-widget-2'.

Please confirm if these changes are intentional and consider the following:

  1. Will the removal of widgets from wp_inactive_widgets affect any functionality?
  2. Is the removal of 'dokan-category-menu-2' and 'dokan-store-location-2' from sidebar-store intended?
  3. How will these changes impact the store's sidebar display?

Run the following script to check for any usage of the removed widgets in the codebase:

#!/bin/bash
# Search for usage of removed widgets in the codebase
rg --type php --type js --type ts "dokan-category-menu-2|dokan-store-location-2"

756-756: Verify the intention behind changing privacy_page to an empty string.

The privacy_page property in privacyPolicySettings has been changed from '2' to an empty string. This modification might affect the privacy policy functionality.

Please confirm if this change is intentional and consider the following:

  1. Does the system handle an empty privacy_page value correctly?
  2. Are there any parts of the code that expect a valid page ID for the privacy policy?
  3. Could this change potentially break any privacy policy-related features?

Run the following script to check for any usage of privacy_page in the codebase:

Verification successful

Change to privacy_page Verified as Safe

No active references to privacy_page were found in the codebase. Updating its value to an empty string does not impact the current functionality.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of privacy_page in the codebase
rg --type php --type js --type ts "privacy_page"

Length of output: 336

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

1966-1988: Summary: Good addition to enhance menu management.

The changes made to this file are focused and beneficial. The new menus array in the menuManager object provides a comprehensive list of vendor dashboard functionalities, which will improve the overall menu management system. The change is well-isolated and doesn't introduce any apparent issues to the existing code structure.

tests/pw/pages/privacyPolicyPage.ts Show resolved Hide resolved
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