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

chore(clients-signature-collection): add tests #15125

Merged
merged 7 commits into from
Jun 13, 2024
Merged

Conversation

juni-haukur
Copy link
Member

@juni-haukur juni-haukur commented Jun 6, 2024

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • Tests

    • Improved test configuration to support .tsx files and updated test coverage paths.
    • Added tests for signature collection functionalities.
  • Refactor

    • Adjusted visibility of methods in SignatureCollectionClientService for better code accessibility.
  • Chores

    • Simplified TypeScript configuration by removing redundant compiler options.

Copy link
Contributor

coderabbitai bot commented Jun 6, 2024

Walkthrough

The changes span several configurations and code updates within the libs/clients/signature-collection directory. These include modifications to jest.config.ts, project.json, and tsconfig.json for better support and structure, along with modifications in the signature-collection.service for improved access control and functionality. A new test file, signature-collection.service.spec.ts, was added to enhance and verify the service's capabilities.

Changes

File Change Summary
libs/.../jest.config.ts Updated transform configuration to support .tsx files, removed 'html' from moduleFileExtensions, and changed coverageDirectory path.
libs/.../project.json Updated output path for test coverage reports.
libs/.../signature-collection.service.spec.ts Introduced functionality for testing signature collections, including signing, creating, removing lists, and eligibility checks.
libs/.../signature-collection.service.ts Made getApiWithAuth public, added an import for filter from rxjs.
libs/.../tsconfig.json Removed several compiler options related to strictness and overrides.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SignatureCollectionClientService
    participant MedmaelalistarApi
    participant MedmaelasofnunApi

    User ->> SignatureCollectionClientService: createList()
    SignatureCollectionClientService ->> MedmaelalistarApi: Call createList API
    MedmaelalistarApi -->> SignatureCollectionClientService: API Response
    SignatureCollectionClientService -->> User: List Created

    User ->> SignatureCollectionClientService: signList()
    SignatureCollectionClientService ->> MedmaelasofnunApi: Check Eligibility
    MedmaelasofnunApi -->> SignatureCollectionClientService: Eligible/Not Eligible
    alt Eligible
        SignatureCollectionClientService ->> SignatureCollectionClientService: Add Signature
    else Not Eligible
        SignatureCollectionClientService -->> User: Not Eligible to Sign
    end

    User ->> SignatureCollectionClientService: getLists()
    SignatureCollectionClientService ->> MedmaelalistarApi: Retrieve Lists
    MedmaelalistarApi -->> SignatureCollectionClientService: Lists Data
    SignatureCollectionClientService -->> User: Lists Data
Loading

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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

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.
  • 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.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 6, 2024

Datadog Report

All test runs cac90ba 🔗

7 Total Test Services: 0 Failed, 7 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 2 increased, 15 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 4.68s 1 no change Link
api-domains-criminal-record 0 0 0 5 0 17.43s 1 no change Link
api-domains-health-insurance 0 0 0 4 0 18.34s 1 no change Link
application-system-api 0 0 0 111 2 3m 25.27s 1 no change Link
application-template-api-modules 0 0 0 109 0 2m 31.35s 1 decreased (-0.01%) Link
application-templates-parental-leave 0 0 0 162 0 47.25s 1 increased (+0.1%) Link
application-ui-shell 0 0 0 74 0 1m 18.63s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-template-api-modules - jest 26.11% (-0.01%) - Details

Copy link

codecov bot commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 36.99%. Comparing base (be82e15) to head (4ad1573).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15125      +/-   ##
==========================================
- Coverage   37.00%   36.99%   -0.02%     
==========================================
  Files        6432     6428       -4     
  Lines      131151   130974     -177     
  Branches    37535    37485      -50     
==========================================
- Hits        48535    48452      -83     
+ Misses      82616    82522      -94     
Flag Coverage Δ
api 3.51% <ø> (ø)
api-domains-criminal-record 47.01% <ø> (ø)
api-domains-health-insurance 33.79% <ø> (ø)
application-template-api-modules 24.36% <ø> (-0.02%) ⬇️
application-templates-parental-leave 28.46% <ø> (+0.11%) ⬆️
application-ui-shell 21.61% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...collection/src/lib/signature-collection.service.ts 9.93% <0.00%> (ø)

... and 31 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be82e15...4ad1573. Read the comment docs.

Copy link
Member

@alexdiljar alexdiljar left a comment

Choose a reason for hiding this comment

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

lgtm, all major test cases covered

@juni-haukur juni-haukur marked this pull request as ready for review June 12, 2024 15:50
@juni-haukur juni-haukur requested a review from a team as a code owner June 12, 2024 15:50
@juni-haukur juni-haukur added the automerge Merge this PR as soon as all checks pass label Jun 12, 2024
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c03383e and 643a75f.

Files selected for processing (5)
  • libs/clients/signature-collection/jest.config.ts (1 hunks)
  • libs/clients/signature-collection/project.json (1 hunks)
  • libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts (1 hunks)
  • libs/clients/signature-collection/src/lib/signature-collection.service.ts (3 hunks)
  • libs/clients/signature-collection/tsconfig.json (1 hunks)
Files skipped from review due to trivial changes (2)
  • libs/clients/signature-collection/project.json
  • libs/clients/signature-collection/tsconfig.json
Additional context used
Path-based instructions (3)
libs/clients/signature-collection/jest.config.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/clients/signature-collection/src/lib/signature-collection.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
GitHub Check: linting (clients-signature-collection)
libs/clients/signature-collection/src/lib/signature-collection.service.ts

[warning] 13-13:
'CanCreateInput' is defined but never used. Allowed unused vars must match /^_[a-zA-Z0-9]*$/u


[warning] 25-25:
'filter' is defined but never used. Allowed unused vars must match /^_[a-zA-Z0-9]*$/u

Additional comments not posted (6)
libs/clients/signature-collection/jest.config.ts (3)

8-10: The update to include .tsx files in the transform configuration is appropriate for projects using JSX in TypeScript. This change ensures that both .ts and .tsx files are properly handled by ts-jest.


13-13: Removing 'html' from moduleFileExtensions is a good practice if HTML files are not being imported directly in the tests. This helps keep the configuration clean and focused on relevant file types.


14-14: Using <rootDir> in the coverageDirectory path enhances portability and maintainability of the Jest configuration by resolving paths relative to the root directory of the project.

libs/clients/signature-collection/src/lib/signature-collection.service.ts (1)

38-38: Changing the access modifier of getApiWithAuth from private to public is acceptable if there is a need for external access. Consider adding documentation to clarify its intended use and any potential security implications.

libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts (2)

1-67: The structure and setup of the test file are correctly implemented following standard practices for unit testing in NestJS. Good use of @nestjs/testing for module setup and dependency injection.


69-369: The test cases are comprehensive and well-organized, covering a variety of scenarios and functionalities. Good use of mocking and assertions to ensure that each unit test is isolated and focused.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 643a75f and 171b03a.

Files selected for processing (1)
  • libs/clients/signature-collection/src/lib/signature-collection.service.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • libs/clients/signature-collection/src/lib/signature-collection.service.ts

@kodiakhq kodiakhq bot merged commit 8ecf0c7 into main Jun 13, 2024
33 checks passed
@kodiakhq kodiakhq bot deleted the chore-test-medmaelakerfi branch June 13, 2024 13:16
sigruntg pushed a commit that referenced this pull request Jun 14, 2024
* first tests

* update jest config

* moar tests

* remove unused import

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
lodmfjord pushed a commit that referenced this pull request Jun 14, 2024
* first tests

* update jest config

* moar tests

* remove unused import

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants