Skip to content

Use LibraryConstants values in unit tests#1498

Merged
gcatanese merged 2 commits into
mainfrom
fix-test-headers
May 13, 2025
Merged

Use LibraryConstants values in unit tests#1498
gcatanese merged 2 commits into
mainfrom
fix-test-headers

Conversation

@gcatanese

Copy link
Copy Markdown
Contributor

PR to update unit tests in httpClient.spec.ts: use values from constants/libraryConstants to verify expectations.

This is necessary as the adyen-library-version is updated (incremented) during the Release workflows.

@gcatanese gcatanese requested a review from a team as a code owner May 13, 2025 12:31

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @gcatanese, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request updates the unit tests in httpClient.spec.ts to use values from constants/libraryConstants.ts for verifying expectations. This change is necessary because the adyen-library-version is automatically updated during release workflows, and hardcoding the version in the tests would cause them to fail after each release.

Highlights

  • Test Improvement: The unit tests now use constants for library name and version, making them more resilient to automated version updates.
  • Dependency Update: A new dependency on LibraryConstants is introduced in the test file.

Changelog

  • src/tests/httpClient.spec.ts
    • Imported LibraryConstants from ../constants/libraryConstants.
    • Replaced hardcoded library name and version strings with LibraryConstants.LIB_NAME and LibraryConstants.LIB_VERSION respectively in the user agent string.
    • Updated the expected user agent string to include the application name when it is set.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


In tests, constants reside,
Where versions safely hide.
No more hardcoded strings,
Automated release brings,
A future where tests confide.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The PR aims to improve the maintainability of unit tests by using constants for library name and version. This is a good approach to avoid hardcoding values and ensure consistency. The changes are straightforward and address the stated problem effectively.

Summary of Findings

  • String Concatenation: Consider using template literals for string concatenation to improve readability.

Merge Readiness

The changes are well-structured and improve the maintainability of the tests. The suggestions are minor and can be addressed at the author's discretion. I am unable to approve the pull request, and users should have others review and approve this code before merging.

@sonarqubecloud

Copy link
Copy Markdown

@gcatanese

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This PR updates the unit tests in httpClient.spec.ts to use values from constants/libraryConstants for verifying expectations. This is a good change as it ensures that the tests are aligned with the library version, which is updated during release workflows. The changes are straightforward and improve the maintainability of the tests.

Merge Readiness

The pull request is ready to be merged. The changes are straightforward and improve the maintainability of the tests by using constants for the library name and version. The suggestions are minor and can be addressed at the author's discretion. I am unable to directly approve the pull request, and other reviewers should review and approve this code before merging.

@gcatanese gcatanese merged commit 73c7992 into main May 13, 2025
7 checks passed
@gcatanese gcatanese deleted the fix-test-headers branch May 13, 2025 12:57
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.

2 participants