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

Update RFQ tests for new changes #2394

Merged
merged 14 commits into from
Oct 7, 2024

Conversation

shashwatahalder01
Copy link
Contributor

@shashwatahalder01 shashwatahalder01 commented Oct 7, 2024

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

  • Full PR Link

Closes

  • Closes #

How to test the changes in this Pull Request:

  • Steps or issue link

Changelog entry

Title

Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.

Before Changes

Describe the issue before changes with screenshots(s).

After Changes

Describe the issue after changes with screenshot(s).

Feature Video (optional)

Link of detailed video if this PR is for a feature.

PR Self Review Checklist:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a method to force links to open in the same tab for improved navigation consistency.
    • Enhanced quote management with new parameters for more granular control over quote rules.
  • Bug Fixes

    • Updated navigation methods to ensure proper URL handling and page reloading when necessary.
  • Documentation

    • Revised the structure of the request for quotation interface to include more detailed options for managing quotes.
  • Tests

    • Updated test cases to utilize unique identifiers for quotes, improving consistency and reliability in testing.
  • Chores

    • Standardized email addresses across various payloads for consistency in testing environments.

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The changes in this pull request involve significant modifications across multiple classes and test files. Key updates include enhancements to navigation methods in the BasePage class, the introduction of a new method to ensure links open in the same tab, and extensive refactoring of quote management logic in the RequestForQuotationsPage. Additionally, there are updates to various test files to standardize the use of quote identifiers and improve the structure of test data and schemas.

Changes

File Path Change Summary
tests/pw/pages/basePage.ts - Modified goIfNotThere method to include a force parameter.
- Added forceLinkToSameTab method.
tests/pw/pages/privacyPolicyPage.ts - Refactored goToPrivacyPolicy method to use forceLinkToSameTab.
tests/pw/pages/requestForQuotationsPage.ts - Extensive modifications to updateQuoteRuleFields, addQuoteRule, editQuoteRule, and updateQuote methods to enhance quote management logic.
- Added new parameters and conditional logic.
tests/pw/pages/selectors.ts - Renamed several selector properties for clarity.
- Updated viewQuoteDetails method to reference quotes by ID instead of title.
tests/pw/pages/singleStorePage.ts - Updated storeShare method to use forceLinkToSameTab.
tests/pw/pages/vendorPage.ts - Modified visitStore method to utilize forceLinkToSameTab.
tests/pw/pages/vendorVerificationsPage.ts - Refactored viewVerificationRequestDocument and vendorViewVerificationRequestDocument methods to call forceLinkToSameTab.
tests/pw/tests/api/quoteRequests.spec.ts - Skipped the test case for updating batch request quotes.
tests/pw/tests/e2e/catalogmode.spec.ts - Simplified product creation and quote rule handling in vendor tests.
tests/pw/tests/e2e/requestForQuoteRules.spec.ts - Enhanced tests for adding and editing quote rules with product associations.
tests/pw/tests/e2e/requestForQuotes.spec.ts - Standardized quote handling by replacing quoteTitle with quoteId across test cases.
- Added new import for dbUtils.
tests/pw/tests/e2e/vendorStaff.spec.ts - Renamed test suite descriptions for clarity.
tests/pw/utils/dbUtils.ts - Introduced updateQuoteRuleContent method for updating quote rule contents in the database.
tests/pw/utils/interfaces.ts - Expanded requestForQuotation interface with new properties and modified existing ones for better quote management.
tests/pw/utils/payloads.ts - Added VENDOR_ID environment variable and updated email addresses in various payloads.
tests/pw/utils/schemas.ts - Removed title, customer_name, and customer_email fields from quoteRequestSchema and added order_url and store_name.
tests/pw/utils/testData.ts - Updated email addresses and restructured requestForQuotation section for enhanced clarity and functionality.

Possibly related PRs

Suggested labels

QA approved

Suggested reviewers

  • mrabbani

Poem

In the warren where changes hop,
The BasePage now won't stop,
Links will open, oh so bright,
In the same tab, what a sight!
Quotes now dance with IDs new,
Hopping along, just for you! 🐇✨


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

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

32-32: Approve refactoring with a minor suggestion.

The refactoring of goToPrivacyPolicy method improves code readability and maintainability by introducing the forceLinkToSameTab method. This change aligns well with the DRY principle and encapsulates the functionality of ensuring the link opens in the same tab.

Consider adding a brief comment explaining why forcing the link to open in the same tab is necessary for this specific use case. This would provide context for future developers who might work on this code.

 async goToPrivacyPolicy(storeName: string) {
     await this.gotoSingleStore(storeName);
+    // Force the privacy policy link to open in the same tab to ensure consistent navigation in tests
     await this.forceLinkToSameTab(singleStoreCustomer.storeContactForm.privacyPolicyLink);
     await this.clickAndWaitForUrl(helpers.stringToRegex('privacy-policy'), singleStoreCustomer.storeContactForm.privacyPolicyLink);
 }
tests/pw/tests/e2e/requestForQuoteRules.spec.ts (4)

19-19: Create an issue to track the pending API update.

The TODO comment indicates that there's a pending fix related to the API update for the createQuoteRule method. To ensure this doesn't get overlooked, it would be beneficial to create an issue to track this task.

Would you like me to create a GitHub issue to track this TODO item?


36-37: Approve the enhancement with a minor suggestion.

Great improvement! Including a product in the quote rule makes the test more realistic and comprehensive.

To further enhance readability and maintainability, consider extracting the product creation logic into a separate helper method within the ApiUtils class or a dedicated setup function.

Here's a suggested refactor:

// In ApiUtils or a new helper file
async function createProductForTest() {
  const [, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth);
  return productName;
}

// In the test
const productName = await createProductForTest();
await admin.addQuoteRule({ ...data.requestForQuotation.quoteRule(), includeProducts: productName });

41-41: Approve the change and suggest an additional test case.

Good addition! Including the specificProducts flag in the edit operation makes the test more comprehensive.

To ensure full coverage of this feature, consider adding another test case where specificProducts is set to true. This will validate both scenarios of the flag.

Here's a suggested additional test case:

test('admin can edit quote rule with specific products', { tag: ['@pro', '@admin'] }, async () => {
  await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule(), title: quoteRuleTitle, specificProducts: true });
});

Line range hint 45-46: Approve the changes and suggest a potential optimization.

Excellent improvements! Creating a new quote rule for each test ensures proper isolation and reduces inter-test dependencies. This approach makes the tests more robust and reliable.

To potentially optimize these tests and reduce duplication, consider creating a helper function that encapsulates the quote rule creation and action execution. This could make the tests more concise and easier to maintain.

Here's a suggested helper function:

async function testQuoteRuleAction(action: 'trash' | 'restore' | 'permanently-delete', initialStatus: 'publish' | 'trash' = 'publish') {
  const [, , quoteRuleTitle] = await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), status: initialStatus }, payloads.adminAuth);
  await admin.updateQuoteRule(quoteRuleTitle, action);
}

// Usage in tests:
test('admin can trash quote rule', { tag: ['@pro', '@admin'] }, async () => {
  await testQuoteRuleAction('trash');
});

test('admin can restore quote rule', { tag: ['@pro', '@admin'] }, async () => {
  await testQuoteRuleAction('restore', 'trash');
});

test('admin can permanently delete quote rule', { tag: ['@pro', '@admin'] }, async () => {
  await testQuoteRuleAction('permanently-delete', 'trash');
});

This approach would make the tests more DRY and easier to maintain.

Also applies to: 50-51, 55-56

tests/pw/tests/api/quoteRequests.spec.ts (1)

Skipped Test Reduces Coverage for Batch Update Quotes

The test for updating batch request quotes has been skipped without a clear justification. This reduces test coverage for a critical functionality and may lead to potential regression issues.

  • Actions to Consider:
    1. Re-enable the Test: If the test was skipped accidentally or the underlying issue has been resolved, consider re-enabling it to ensure continued coverage.
    2. Document the Reason: If skipping the test is necessary (e.g., due to known issues), please add a comment explaining the reason and track it with a corresponding issue or ticket.
    3. Alternative Solutions: If the test is problematic, explore alternatives such as optimizing test performance or restructuring the test to avoid current issues.
🔗 Analysis chain

Line range hint 81-87: Clarify the reason for skipping the batch update test

The test for updating batch request quotes has been skipped. This reduces test coverage for an important functionality and may lead to potential regression issues.

  1. Could you please explain why this test is being skipped? Is it due to a failing test, ongoing refactoring, or performance issues?

  2. If the test is problematic, consider these alternatives:

    • If it's failing, fix the underlying issue rather than skipping the test.
    • If it's a performance concern, consider moving it to a separate, less frequently run test suite.
    • If the functionality is changing, update the test to match the new expected behavior.
  3. If skipping is temporary, please add a comment explaining the reason and create a ticket to track its re-enablement.

To help understand the context, let's check for any related changes or issues:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for recent changes to the batch update functionality
rg -i "batch.*update.*quote" --type ts
# Look for any TODO or FIXME comments related to quote requests
rg -i "TODO|FIXME" --type ts | rg -i "quote"
# Check for any open issues related to quote requests
gh issue list --label "quote-requests" --state open

Length of output: 1200

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

98-100: Approved: Good refactoring of link handling logic

The changes to the storeShare method improve code readability and potentially reusability by introducing the forceLinkToSameTab method. This aligns well with the DRY (Don't Repeat Yourself) principle mentioned in the PR objectives.

Consider adding a brief comment explaining the purpose of forceLinkToSameTab for better documentation:

// Ensure the share link opens in the same tab
await this.forceLinkToSameTab(singleStoreCustomer.sharePlatForms[site as keyof typeof singleStoreCustomer.sharePlatForms]);
tests/pw/tests/e2e/catalogmode.spec.ts (1)

Line range hint 1-124: Overall assessment of changes

The modifications in this file are focused on improving the 'vendor can enable RFQ in catalog mode' test case. The changes simplify product creation and add a workaround for an API limitation in quote rule creation. While these changes enhance the test's functionality and readability, they also highlight an underlying issue that needs to be addressed.

Recommendations:

  1. Create a tracking issue for the API fix mentioned in the TODO comment.
  2. Once the API is fixed, remove the workaround and update this test accordingly.
  3. Review other test files to ensure consistency in product creation and quote rule handling across the test suite.
  4. Consider adding a comment explaining why the quote rule content needs to be updated after creation, to provide context for future maintainers.

To improve the overall architecture and maintainability of the test suite, consider the following:

  1. If the product_switch setting is consistently required, update the createQuoteRule payload to include this by default.
  2. Evaluate if a helper function for creating and setting up quote rules would be beneficial across multiple test files.
  3. Document the expected behavior of the API regarding quote rule creation and updates in a central location for all developers to reference.
tests/pw/tests/e2e/requestForQuotes.spec.ts (1)

Line range hint 1-189: Overall improvements with some areas needing attention.

The changes in this file consistently replace quoteTitle with quoteId, which improves clarity and accuracy throughout the tests. This is a positive change that aligns with best practices for handling unique identifiers.

However, there are a few areas that require attention:

  1. Two tests have been skipped (lines 44 and 165). The reasons for skipping these tests should be documented and addressed in future updates.

  2. New quote rule functionality has been added (lines 141-142), which includes direct database manipulation. While this expands test coverage, it introduces a dependency on dbUtils that may need to be removed once the API is fixed.

Consider the following recommendations:

  1. Document the reasons for skipped tests in code comments or link to relevant issues.
  2. Create a tracking issue for removing the direct database manipulation once the API is fixed.
  3. Review the overall test structure to ensure it remains maintainable with these new additions.
tests/pw/pages/basePage.ts (2)

Line range hint 94-107: LGTM! Consider adding error handling.

The changes to the goIfNotThere method look good. The addition of the force parameter provides more flexibility in navigation scenarios.

Consider adding error handling for the navigation and reload operations. For example:

 async goIfNotThere(subPath: string, waitUntil: 'load' | 'domcontentloaded' | 'networkidle' | 'commit' = 'domcontentloaded', force = false): Promise<void> {
     const alreadyThere = this.isCurrentUrl(subPath);
     if (!alreadyThere) {
         const url = this.createUrl(subPath);
         await this.toPass(async () => {
-            await this.goto(url, { waitUntil: waitUntil });
+            try {
+                await this.goto(url, { waitUntil: waitUntil });
+            } catch (error) {
+                console.error(`Navigation failed: ${error}`);
+                throw error;
+            }
             const currentUrl = this.getCurrentUrl();
             expect(currentUrl).toMatch(subPath);
         });
     }
     if (force) {
-        await this.reload();
+        try {
+            await this.reload();
+        } catch (error) {
+            console.error(`Force reload failed: ${error}`);
+            throw error;
+        }
     }
 }

1621-1626: LGTM! Consider adding error handling.

The new forceLinkToSameTab method is a good addition to the BasePage class. It effectively ensures that a link opens in the same tab instead of a new one.

Consider adding error handling to make the method more robust. For example:

 async forceLinkToSameTab(selector: string): Promise<void> {
-    // ensure link suppose to open on new tab
-    await this.toHaveAttribute(selector, 'target', '_blank');
-    // force link to open on the same tab
-    await this.setAttributeValue(selector, 'target', '_self');
+    try {
+        // ensure link is supposed to open in a new tab
+        await this.toHaveAttribute(selector, 'target', '_blank');
+        // force link to open on the same tab
+        await this.setAttributeValue(selector, 'target', '_self');
+    } catch (error) {
+        console.error(`Failed to force link to same tab: ${error}`);
+        throw error;
+    }
 }

This change will help catch and report any errors that might occur during the attribute checks or modifications.

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

1696-1696: LGTM! Update documentation if necessary.

The change of the billing email domain from yopmail.com to email.com in the createOrderCod payload is consistent with the previous modification. This systematic update improves the consistency of test data across different order types.

Consider updating any relevant documentation or comments that may reference the old email domain to reflect this change.

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

111-115: Address the TODO: Implement 'expireLimit' functionality

The comment // todo: skipped until api is fixed indicates that the expireLimit feature is currently not implemented due to an API issue. This may leave the quote rule functionality incomplete.

Would you like assistance in implementing the expireLimit feature or opening a GitHub issue to track this task?


262-262: Address the TODO: Implement direct navigation to quotes

The comment // todo: add goto quote via direct url indicates the need to navigate directly to a quote using its ID.

Would you like assistance in implementing direct URL navigation to the quote, enhancing the efficiency of the editQuote method?

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

1292-1292: Add missing line number annotation for 'hidePriceText'

The hidePriceText property on line 1293 is missing a line number annotation. Ensure that all changed lines are properly annotated with line numbers and tildes for clarity and consistency.


1375-1383: Ensure consistent naming conventions in 'address' interface

In the guest address interface, some property names could be standardized:

  • countrySelectValue and stateSelectValue: If these represent country and state codes, consider renaming them to countryCode and stateCode for clarity and consistency.

  • postCode is used here, while zipCode is used elsewhere in the codebase. To maintain consistency, it's advisable to use one term throughout. Choose either postCode or zipCode based on the project's standard.

Apply the following changes for consistency:

- countrySelectValue: string;
+ countryCode: string;

- stateSelectValue: string;
+ stateCode: string;

- postCode: string;
+ zipCode: string;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b2ce2cc and 895665e.

📒 Files selected for processing (17)
  • tests/pw/pages/basePage.ts (3 hunks)
  • tests/pw/pages/privacyPolicyPage.ts (1 hunks)
  • tests/pw/pages/requestForQuotationsPage.ts (11 hunks)
  • tests/pw/pages/selectors.ts (10 hunks)
  • tests/pw/pages/singleStorePage.ts (1 hunks)
  • tests/pw/pages/vendorPage.ts (1 hunks)
  • tests/pw/pages/vendorVerificationsPage.ts (2 hunks)
  • tests/pw/tests/api/quoteRequests.spec.ts (1 hunks)
  • tests/pw/tests/e2e/catalogmode.spec.ts (1 hunks)
  • tests/pw/tests/e2e/requestForQuoteRules.spec.ts (2 hunks)
  • tests/pw/tests/e2e/requestForQuotes.spec.ts (9 hunks)
  • tests/pw/tests/e2e/vendorStaff.spec.ts (2 hunks)
  • tests/pw/utils/dbUtils.ts (1 hunks)
  • tests/pw/utils/interfaces.ts (3 hunks)
  • tests/pw/utils/payloads.ts (18 hunks)
  • tests/pw/utils/schemas.ts (1 hunks)
  • tests/pw/utils/testData.ts (5 hunks)
✅ Files skipped from review due to trivial changes (2)
  • tests/pw/pages/vendorPage.ts
  • tests/pw/pages/vendorVerificationsPage.ts
🧰 Additional context used
🔇 Additional comments (23)
tests/pw/tests/e2e/requestForQuoteRules.spec.ts (1)

Line range hint 1-68: Overall assessment: Improvements align well with PR objectives.

The changes in this file significantly enhance the test suite for Request for Quotation Rules. They improve test isolation, increase coverage of new features (like specificProducts), and make the tests more robust by ensuring each test operates on a valid quote rule instance.

These modifications align well with the PR objectives of updating RFQ tests for new changes. They also adhere to good testing practices, making the test suite more reliable and maintainable.

A few suggestions have been made to further improve code organization and test coverage, but overall, these changes represent a solid improvement to the test suite.

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

7-7: Improved test suite description clarity.

The updated test suite description 'Vendor staff test (vendor)' provides better context by explicitly stating that these tests are from the vendor's perspective. This change enhances the readability and understanding of the test suite's purpose, which is beneficial for maintainability.


48-48: Significant improvement in test suite description accuracy.

The updated test suite description 'Vendor staff test (vendorStaff)' now accurately reflects the content of the tests, which focus on vendor staff functionality. This change greatly enhances the clarity and maintainability of the test suite.

However, given the significant shift in perspective from the previous 'Wholesale test (customer)' description, it's important to verify that no customer-specific tests were inadvertently removed or altered during this update.

Could you please confirm that:

  1. No customer-specific tests were removed during this update?
  2. If any tests were removed, were they replaced with equivalent vendor staff tests?
  3. Does this change align with any recent updates to the RFQ functionality that might have shifted focus from customer to vendor staff perspectives?

To assist in verification, you can run the following script to check for any removed test cases:

✅ Verification successful

No customer-specific tests were removed.

The update to the test suite description has been verified, ensuring that no customer-specific tests were inadvertently removed or altered during this change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for removed test cases related to customer perspective

# Test: Search for removed test cases mentioning 'customer'
git diff HEAD~1 tests/pw/tests/e2e/vendorStaff.spec.ts | grep -E '^\-.*test\(.*customer' || echo "No customer-specific tests were removed."

Length of output: 181

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

98-100: Verify the implementation of forceLinkToSameTab

The forceLinkToSameTab method is used here but not defined in this file. To ensure the correct functionality:

  1. Verify that forceLinkToSameTab is properly implemented in the parent CustomerPage class or a relevant utility file.
  2. Confirm that it correctly sets the link's target attribute to '_self' or uses an equivalent method to ensure the link opens in the same tab.
✅ Verification successful

forceLinkToSameTab is properly implemented in basePage.ts.

  • Implementation Location:
    • tests/pw/pages/basePage.ts
  • Functionality:
    • Sets the target attribute of links to _self to ensure they open in the same tab.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the implementation of forceLinkToSameTab
rg --type typescript -A 5 'forceLinkToSameTab'

Length of output: 81


Script:

#!/bin/bash
# Search for the implementation of forceLinkToSameTab with corrected file type
rg --type ts -A 5 'forceLinkToSameTab'

Length of output: 4199


Script:

#!/bin/bash
# Alternative search using ast-grep for more precise results
ast-grep --lang typescript --pattern 'function forceLinkToSameTab($_)' 

Length of output: 72

tests/pw/tests/e2e/requestForQuotes.spec.ts (9)

6-6: LGTM: New import for database utilities.

The addition of the dbUtils import is appropriate as it's used later in the file for updating quote rule content.


15-15: LGTM: Variable renamed for consistency.

Changing quoteTitle to quoteId is a good practice as it more accurately represents the unique identifier for quotes. This change improves clarity and consistency throughout the tests.


24-24: LGTM: API call updated to use quote ID.

The quote creation API call has been correctly updated to use quoteId, maintaining consistency with the earlier variable renaming. This change ensures that the unique identifier for the quote is properly captured and used in subsequent tests.


44-45: Verify the reason for skipping the 'admin can edit quote' test.

The test for editing a quote has been skipped. Please provide the reason for skipping this test and ensure it's addressed in future updates.

Can you explain why this test has been skipped? Is there an ongoing issue or planned changes that necessitate this?


49-50: LGTM: Consistent use of quoteId in admin tests.

The changes in these lines consistently use quoteId instead of quoteTitle in API calls and method arguments. This improves the overall consistency and clarity of the tests.

Also applies to: 54-55, 59-60, 64-65, 69-70


93-93: LGTM: Consistent use of quoteId in vendor tests.

The vendor test suite has been updated to use quoteId instead of quoteTitle, maintaining consistency with the changes made in the admin suite. This improves the clarity and accuracy of the tests.

Also applies to: 106-106


141-142: Verify the need for direct database manipulation.

A new quote rule is being created and its content updated using dbUtils. The comment suggests this is a temporary solution until an API fix is implemented.

Is there an open issue or planned work to address the API limitation that necessitates this direct database manipulation? Please ensure this is tracked and removed once the API is fixed.


143-143: LGTM: Consistent use of quoteId in customer tests.

The quote request creation now correctly uses quoteId, maintaining consistency with the changes made in other test suites.


165-165: Verify the reason for skipping the 'customer can update quote request' test.

The test for updating a quote request has been skipped. This could indicate ongoing changes or issues with this functionality.

Can you provide the reason for skipping this test? Is there an open issue or planned work to address any problems with the customer's ability to update quote requests?

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

1597-1597: Improved email address configuration

The changes to the email addresses in the customer object are beneficial:

  1. They now use the CUSTOMER variable, making them consistent with other parts of the codebase.
  2. This approach allows for easier configuration and maintenance of email addresses.

Also applies to: 1601-1601


1805-1813: Added guest address information

A new address object has been added to the guest function:

  1. It includes fields for country, countrySelectValue, stateSelectValue, city, postCode, addressLine1, and addressLine2.
  2. This addition allows for more detailed address information collection for guest users.

This change enhances the ability to gather and manage guest user data, potentially improving shipping calculations and user experience for guest checkouts. Ensure that any forms or processes handling guest information are updated to accommodate these new fields.

To ensure proper implementation, please run the following script to check for any guest-related forms or processes that might need updating:

#!/bin/bash
# Search for guest-related forms or processes
rg --type typescript "guest.*address|country|city|postCode" -g '!tests/pw/utils/testData.ts'

1760-1772: Expanded quote information

The quote function has been updated with additional properties:

  1. New id, title, user, fullName, vendor, shippingCost, and offerProductQuantity fields have been added.
  2. The email field now uses the CUSTOMER variable, consistent with earlier changes.
  3. The product and quantity fields have been retained.

These changes provide a more comprehensive structure for quote information, allowing for better tracking and management of quotes. Ensure that all systems interacting with this quote object are updated to handle these new properties.

To ensure compatibility, please run the following script to check for any usage of the old quote structure:

#!/bin/bash
# Search for old quote structure usage
rg --type typescript "quote.*email|product|quantity" -g '!tests/pw/utils/testData.ts'

1736-1749: Enhanced quote rule configuration

The quoteRule function has been significantly refactored:

  1. New properties like applyOnAllProducts, specificProducts, includeProducts, specificCategories, categories, specificVendors, includeVendors, and excludeVendors have been added.
  2. The hideAddToCartButton property has been retained.
  3. A new hidePriceText property has been introduced.

These changes provide more fine-grained control over quote rules, allowing for better customization of product visibility and pricing display. However, ensure that all parts of the system using this object are updated to handle these new properties correctly.

To ensure compatibility, please run the following script to check for any usage of the old quoteRule structure:

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

1646-1646: LGTM! Consider checking for email domain consistency.

The change from a yopmail.com domain to an email.com domain for the billing email is appropriate. This update likely improves the consistency and reliability of test data.

Let's verify if this email domain change has been applied consistently across other payloads:

#!/bin/bash
# Search for email addresses still using yopmail.com
grep -n "yopmail.com" tests/pw/utils/payloads.ts

# Search for email addresses using the new email.com domain
grep -n "email.com" tests/pw/utils/payloads.ts

7-7: LGTM! Verify VENDOR_ID usage in payloads.

The addition of VENDOR_ID to the destructured process.env object is appropriate. This change suggests that vendor-specific operations are being introduced or expanded in the test scenarios.

To ensure this change is properly utilized, let's verify the usage of VENDOR_ID in the payloads:

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

371-375: Ensure correct parameter type for vendor quote updates

In the vendorUpdateQuoteRequest method, the parameter quote has been updated to requestForQuotation['vendorQuote']. Ensure that the vendorQuote interface includes all necessary fields used within this method.

Confirm that all properties accessed on quote are defined in requestForQuotation['vendorQuote'] and update the interface if necessary.


515-517: Confirm fields for 'expectedDelivery' and 'additionalMessage'

The code inputs expectedDelivery and additionalMessage. Verify that these fields are always present on the form and that their inclusion is necessary for the test scenarios.

Check if these fields are conditional and whether they need additional checks before interaction.


221-223: Verify the format of user selection inputs

The code is constructing the selector using ${quote.user}( ${quote.email} ). Ensure that this format matches the options presented in the dropdown for user selection.

Run the following script to confirm that the user selection format aligns with the expected pattern:

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

1294-1295: Verify consistency of optional boolean properties

In the quoteRule interface:

  • hideAddToCartButton?: boolean; is optional.
  • keepBothCartQuoteButton?: boolean; is optional.

These properties are related to button display logic. Verify that both properties are intended to be optional and that their defaults are handled correctly in the application logic to prevent unexpected behavior.

tests/pw/tests/e2e/catalogmode.spec.ts Show resolved Hide resolved
tests/pw/utils/dbUtils.ts Show resolved Hide resolved
tests/pw/utils/schemas.ts Show resolved Hide resolved
tests/pw/pages/requestForQuotationsPage.ts Show resolved Hide resolved
tests/pw/pages/requestForQuotationsPage.ts Show resolved Hide resolved
tests/pw/pages/requestForQuotationsPage.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
@shashwatahalder01 shashwatahalder01 added the QA approved This PR is approved by the QA team label Oct 7, 2024
@shashwatahalder01 shashwatahalder01 merged commit b19b0ea into getdokan:develop Oct 7, 2024
2 checks passed
@shashwatahalder01 shashwatahalder01 deleted the rfq branch October 8, 2024 05:03
@coderabbitai coderabbitai bot mentioned this pull request Oct 8, 2024
11 tasks
This was referenced Oct 24, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 1, 2024
12 tasks
@coderabbitai coderabbitai bot mentioned this pull request Nov 29, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QA approved This PR is approved by the QA team Test Automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant