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

開発用の依存関係について更新 #75

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

dc7290
Copy link
Member

@dc7290 dc7290 commented Mar 14, 2024

devDependenciesについて更新しました。
mswのアップデートでAPIに変更があったのでその対応をしています。

Summary by CodeRabbit

  • Tests
    • Updated various tests to use http and HttpResponse for handling requests and responses, improving reliability and consistency.
    • Enhanced error handling and response creation in tests for better test accuracy.
    • Refactored tests to align with new HTTP handling approach, ensuring more robust testing scenarios.

@dc7290 dc7290 marked this pull request as ready for review March 14, 2024 08:19
Copy link

coderabbitai bot commented Mar 14, 2024

Walkthrough

The recent updates across various test files mark a significant shift from using rest to http and HttpResponse for handling HTTP requests and responses within our testing suite. This change enhances the way we handle errors, structure our responses, and interact with HTTP methods, aligning our tests with a more streamlined and efficient HTTP handling approach.

Changes

Files Summary
tests/createClient.test.ts, tests/get.test.ts Updated to use http and HttpResponse from 'msw', with changes in error handling and response logic.
tests/getAllContentIds.test.ts, tests/getAllContents.test.ts Shifted to http and HttpResponse, updating request and response handling.
tests/mocks/handlers.ts Refactored to use http for requests, changing response generation and request handling.
tests/write.test.ts Transitioned to http and HttpResponse for HTTP requests, modifying request logic for various methods.

🐇✨
In the land of code and wire,
Changes swift as rabbits' desire.
From rest to http, we hop and leap,
Through tests and mocks, our standards keep.
With every line, we craft with care,
A tale of progress, wrought to 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.
    • 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 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 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.

@dc7290 dc7290 requested a review from himorishige March 14, 2024 08:20
Copy link

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1a19fc2 and b891173.
Files ignored due to path filters (2)
  • package-lock.json is excluded by: !**/*.json
  • package.json is excluded by: !**/*.json
Files selected for processing (6)
  • tests/createClient.test.ts (8 hunks)
  • tests/get.test.ts (2 hunks)
  • tests/getAllContentIds.test.ts (5 hunks)
  • tests/getAllContents.test.ts (3 hunks)
  • tests/mocks/handlers.ts (1 hunks)
  • tests/write.test.ts (7 hunks)
Additional comments: 25
tests/get.test.ts (2)
  • 1-1: The import statement correctly reflects the transition from rest to http and HttpResponse for handling HTTP requests and responses. This aligns with the PR objectives.
  • 61-63: The test for handling server errors has been updated to use http.get and HttpResponse.json for mocking the response. This change correctly implements the new approach for handling HTTP requests and responses. However, ensure that the status code and message are appropriate for the test scenario.
tests/getAllContents.test.ts (3)
  • 1-1: The import statement correctly reflects the transition from rest to http and HttpResponse for handling HTTP requests and responses. This aligns with the PR objectives.
  • 18-29: The test for fetching all contents has been updated to use http.get and HttpResponse.json for mocking responses. This change correctly implements the new approach for handling HTTP requests and responses. Ensure that the response structure matches the expected format for the getAllContents function.
  • 43-68: The test for handling pagination and fetching more than the limit has been correctly updated to use http.get and HttpResponse.json. This demonstrates a good understanding of the new HTTP handling approach. Ensure that the pagination logic in the actual getAllContents function aligns with these test scenarios.
tests/getAllContentIds.test.ts (5)
  • 1-1: The import statement correctly reflects the transition from rest to http and HttpResponse for handling HTTP requests and responses. This aligns with the PR objectives.
  • 18-29: The test for fetching all content IDs has been updated to use http.get and HttpResponse.json for mocking responses. This change correctly implements the new approach for handling HTTP requests and responses. Ensure that the response structure matches the expected format for the getAllContentIds function.
  • 43-68: The test for handling pagination and fetching more than the limit has been correctly updated to use http.get and HttpResponse.json. This demonstrates a good understanding of the new HTTP handling approach. Ensure that the pagination logic in the actual getAllContentIds function aligns with these test scenarios.
  • 82-93: The test for fetching all content IDs with an alternate field has been correctly updated to use http.get and HttpResponse.json. This change is consistent with the new approach for handling HTTP requests and responses. Ensure that the functionality for specifying an alternate field is correctly implemented in the getAllContentIds function.
  • 108-119: The test for throwing an error when the alternateField is not a string has been correctly updated to use http.get and HttpResponse.json. This change aligns with the new approach for handling HTTP requests and responses. Ensure that the error handling logic for the alternateField parameter is correctly implemented in the getAllContentIds function.
tests/mocks/handlers.ts (3)
  • 1-1: The import statement correctly reflects the transition from rest to http and HttpResponse for handling HTTP requests and responses. This aligns with the PR objectives.
  • 7-7: The hasValidApiKey function has been correctly updated to accept a StrictRequest type. This change aligns with the new approach for handling HTTP requests and ensures type safety.
  • 12-97: The mock handlers have been correctly refactored to use http for request handling and HttpResponse for response creation. This change aligns with the PR objectives and correctly implements the new approach for handling HTTP requests and responses. Ensure that the status codes and response bodies are appropriate for each test scenario.
tests/write.test.ts (7)
  • 1-1: The import statement correctly reflects the transition from rest to http and HttpResponse for handling HTTP requests and responses. This aligns with the PR objectives.
  • 24-37: The tests for the create function have been correctly updated to use http.post and http.put for mocking responses. This change correctly implements the new approach for handling HTTP requests and responses. Ensure that the response structure and status codes match the expected behavior for the create function.
  • 122-122: The test for throwing an error if the endpoint is not specified has been correctly updated to use toThrow instead of toThrowError. This change aligns with the updated error handling logic.
  • 133-142: The tests for the update function have been correctly updated to use http.patch for mocking responses. This change correctly implements the new approach for handling HTTP requests and responses. Ensure that the response structure and status codes match the expected behavior for the update function.
  • 186-186: The test for throwing an error if the endpoint is not specified in the update function has been correctly updated. This change aligns with the updated error handling logic.
  • 196-199: The tests for the delete function have been correctly updated to use http.delete for mocking responses. This change correctly implements the new approach for handling HTTP requests and responses. Ensure that the response status code matches the expected behavior for the delete function.
  • 215-222: The tests for throwing errors if the endpoint or contentId is not specified in the delete function have been correctly updated. This change aligns with the updated error handling logic.
tests/createClient.test.ts (5)
  • 1-1: The import statement correctly reflects the transition from rest to http and HttpResponse for handling HTTP requests and responses. This aligns with the PR objectives.
  • 23-34: > 📝 NOTE

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

The tests for throwing errors if serviceDomain or apiKey is missing or not a string have been correctly updated. This change aligns with the updated error handling logic.

  • 60-100: > 📝 NOTE

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

The tests for handling errors when response.ok is false have been correctly updated to use http.get and HttpResponse.json. This change correctly implements the new approach for handling HTTP requests and responses. Ensure that the error messages and status codes are appropriate for the test scenarios.

  • 88-97: The test for handling network errors has been correctly updated to use HttpResponse.error. This change aligns with the new approach for handling HTTP requests and responses. Ensure that the error message is appropriate for a network error scenario.
  • 113-123: The tests for the retry option being true and handling different error scenarios have been correctly updated to use http.get and HttpResponse. This change correctly implements the new approach for handling HTTP requests and responses. Ensure that the retry logic in the actual createClient function aligns with these test scenarios.

Copy link
Contributor

@himorishige himorishige left a comment

Choose a reason for hiding this comment

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

対応ありがとうございます!
LGTM!

@dc7290 dc7290 merged commit c7b4003 into main Mar 14, 2024
2 checks passed
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