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

feat: update proxy tests for cm360 #3039

Merged
merged 9 commits into from
Feb 7, 2024

Conversation

utsabc
Copy link
Member

@utsabc utsabc commented Jan 29, 2024

What are the changes introduced in this PR?

The following changes introduces new structure for component tests for proxy routes for cm360. Tests are structured around

  • business scenarios
  • oauth scenarios
  • other 5XX sceanrios

Structure has been defined for central mocking for oauth based on destination platform example for cm360 its google
For common 5XX scenarios a central mock has been added.

Along with that zod validations are added based on type for input and output for proxy routes.

What is the related Linear task?

Resolves INT-1295

Please explain the objectives of your changes below

As part of the reliability efforts a test standardisation needs to be done this covers for component tests for proxy.

Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • Is the PR limited to 10 file changes?

  • Is the PR limited to one linear task?

  • Are relevant unit and component test-cases added?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

Summary by CodeRabbit

  • New Features
    • Introduced schemas for validating proxy and delivery requests and responses, enhancing data integrity.
    • Added mock responses for various Google Ads API error scenarios to improve testing robustness.
    • Expanded test scenarios for the Campaign Manager destination, covering API versions, OAuth functionality, and error handling.
  • Tests
    • Enhanced integration tests with new functions and constants for updated test structures.
    • Implemented Zod validations for test payloads, ensuring test data conforms to expected schemas.

Added new structure for proxy test scnearios for cm360 also added zod validations as part of tests
Copy link
Contributor

coderabbitai bot commented Jan 29, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The recent update introduces comprehensive schemas for validating proxy and delivery requests and responses, alongside extensive mock data for testing various error scenarios across Google Ads API and other HTTP responses. It enhances integration tests, especially for the Campaign Manager, by implementing new test scenarios, OAuth functionality tests, and error handling cases. Additionally, the update enriches test utilities with Zod validation and augments test case data structures for improved clarity and specificity in testing outcomes.

Changes

File(s) Change Summary
src/types/zodTypes.ts Introduced schemas for validating proxy and delivery requests and responses, including proxy metadata and requests of different versions.
test/integrations/common/google/network.ts Added mock responses for Google Ads API error scenarios.
test/integrations/common/network.ts Introduced networkCallsData containing mock data for various HTTP responses, including error scenarios.
test/integrations/component.test.ts Added validateTestWithZOD function and updated INTEGRATIONS_WITH_UPDATED_TEST_STRUCTURE to include 'campaign_manager'.
test/integrations/destinations/campaign_manager/... Significantly altered functionality to include new test scenarios, OAuth functionality tests, and error handling for different API versions.
test/integrations/testTypes.ts Added optional fields scenario, successCriteria, and comment to TestCaseData interface.
test/integrations/testUtils.ts Enhanced with Zod validations, new utility functions for generating payloads, and improved test file path handling.

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@utsabc
Copy link
Member Author

utsabc commented Jan 29, 2024

@coderabbitai review

@devops-github-rudderstack
Copy link
Contributor

Copy link

codecov bot commented Jan 29, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (30c4eca) 87.07% compared to head (7ce0a66) 87.13%.

❗ Current head 7ce0a66 differs from pull request most recent head 99f5cb2. Consider uploading reports for the commit 99f5cb2 to get more accurate results

Files Patch % Lines
src/types/zodTypes.ts 94.73% 1 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           fix.network-handlers    #3039      +/-   ##
========================================================
+ Coverage                 87.07%   87.13%   +0.05%     
========================================================
  Files                       530      531       +1     
  Lines                     28836    28860      +24     
  Branches                   6860     6865       +5     
========================================================
+ Hits                      25110    25148      +38     
+ Misses                     3379     3369      -10     
+ Partials                    347      343       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Review Status

Actionable comments generated: 25

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 30c4eca and 9dd8625.
Files ignored due to path filters (2)
  • package-lock.json is excluded by: !**/*.json
  • package.json is excluded by: !**/*.json
Files selected for processing (11)
  • src/types/zodTypes.ts (1 hunks)
  • test/integrations/common/google/network.ts (1 hunks)
  • test/integrations/common/network.ts (1 hunks)
  • test/integrations/component.test.ts (3 hunks)
  • test/integrations/destinations/campaign_manager/dataDelivery/business.ts (1 hunks)
  • test/integrations/destinations/campaign_manager/dataDelivery/data.ts (1 hunks)
  • test/integrations/destinations/campaign_manager/dataDelivery/oauth.ts (1 hunks)
  • test/integrations/destinations/campaign_manager/dataDelivery/other.ts (1 hunks)
  • test/integrations/destinations/campaign_manager/network.ts (4 hunks)
  • test/integrations/testTypes.ts (1 hunks)
  • test/integrations/testUtils.ts (3 hunks)
Additional comments: 13
test/integrations/destinations/campaign_manager/dataDelivery/data.ts (2)
  • 1-3: Imports from './business', './oauth', and './other' are correctly added to support the new structure of test scenarios.
  • 4-11: The updated data export correctly combines scenarios from business, OAuth, and other scenarios for both v0 and v1 APIs, aligning with the PR's objectives to enhance test coverage and standardize testing practices.
test/integrations/testTypes.ts (1)
  • 34-36: The addition of optional fields scenario, successCriteria, and comment to the TestCaseData interface is a good practice. It allows for more descriptive test cases, aiding in understanding the test's purpose and expected outcomes.
test/integrations/common/network.ts (1)
  • 1-61: The mock responses for various error scenarios, including SERVICE NOT AVAILABLE, INTERNAL SERVER ERROR, GATEWAY TIME OUT, and null responses, are well-defined. These mocks are essential for testing the robustness of the proxy routes against potential failures.
test/integrations/common/google/network.ts (1)
  • 1-108: The mock responses for Google-specific OAuth errors and common HTTP errors are correctly implemented. These mocks are crucial for testing the OAuth flow and error handling in the context of Google APIs, aligning with the PR's objectives to enhance reliability and standardize testing practices.
test/integrations/destinations/campaign_manager/network.ts (1)
  • 1-70: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-163]

The introduction of new data structures for common headers, encryption information, and test conversions, along with the updated mock data for network calls, is well-executed. These changes support the PR's objectives to enhance test coverage and standardize testing practices for the Campaign Manager destination.

src/types/zodTypes.ts (1)
  • 1-172: The introduction of Zod schemas for validating proxy requests and responses is a significant improvement towards enforcing type safety and improving code reliability. These schemas will help catch errors early in the development process, aligning with the PR's objectives.
test/integrations/component.test.ts (3)
  • 19-19: The addition of validateTestWithZOD to the testUtils module is a good practice for ensuring that test cases are validated against the defined Zod schemas, enhancing the reliability of tests.
  • 57-57: Modifying the REPORT_COMPATIBLE_INTEGRATION constant to INTEGRATIONS_WITH_UPDATED_TEST_STRUCTURE and adding 'campaign_manager' to its array reflects the inclusion of the Campaign Manager in the updated test structure. This change is consistent with the PR's objectives.
  • 151-152: The use of INTEGRATIONS_WITH_UPDATED_TEST_STRUCTURE and the call to validateTestWithZOD for certain integrations are correctly implemented to ensure that tests for these integrations are validated against the Zod schemas.
test/integrations/testUtils.ts (3)
  • 380-413: The generateProxyV0Payload function is correctly implemented to generate payloads for proxy v0 requests. This function supports the PR's objectives by facilitating the creation of standardized test payloads.
  • 416-455: The generateProxyV1Payload function is correctly implemented to generate payloads for proxy v1 requests. This addition is crucial for testing v1 API endpoints, aligning with the PR's objectives to enhance test coverage.
  • 462-497: The validateTestWithZOD function, which performs Zod validations for different testPayload versions and scenarios, is a significant addition. It ensures that test cases are validated against the defined Zod schemas, enhancing the reliability of tests.

utsabc and others added 3 commits January 29, 2024 18:26
…usiness.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…usiness.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@utsabc utsabc marked this pull request as ready for review January 29, 2024 13:00
@utsabc utsabc requested review from sivashanmukh and a team as code owners January 29, 2024 13:00
@devops-github-rudderstack
Copy link
Contributor

2 similar comments
@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

secret: {},
dontBatch: false,
},
error: 'Floodlight config id: 213123123 was not found., ',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
error: 'Floodlight config id: 213123123 was not found., ',
error: 'Floodlight config id: 213123123 was not found.',

Copy link
Member

@chandumlg chandumlg Jan 30, 2024

Choose a reason for hiding this comment

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

., is repeated in all the errors. Any reason?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is because of this line

Copy link
Member

Choose a reason for hiding this comment

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

We should correct it then.

Copy link
Contributor

@koladilip koladilip left a comment

Choose a reason for hiding this comment

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

Not full review, I will sync up with you

sourceId: z.string(),
destinationId: z.string(),
workspaceId: z.string(),
secret: z.record(z.unknown()),
Copy link
Contributor

Choose a reason for hiding this comment

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

is this mandatory?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

can we make it optional

src/types/zodTypes.ts Show resolved Hide resolved
src/types/zodTypes.ts Outdated Show resolved Hide resolved
src/types/zodTypes.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we rename these files to mockNetwork.ts ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The mockHandler identifies mock by file name network.ts

test/integrations/testUtils.ts Outdated Show resolved Hide resolved
@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

Copy link

sonarqubecloud bot commented Feb 5, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

6 New issues
0 Security Hotspots
93.0% Coverage on New Code
0.2% Duplication on New Code

See analysis details on SonarCloud

@utsabc utsabc merged commit 0504ffa into fix.network-handlers Feb 7, 2024
12 checks passed
@utsabc utsabc deleted the chore.cm360-update-proxy-test branch February 7, 2024 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants