Skip to content

test: fix test failing in windows #1153

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

Merged
merged 1 commit into from
Mar 19, 2024
Merged

test: fix test failing in windows #1153

merged 1 commit into from
Mar 19, 2024

Conversation

jiashengguo
Copy link
Member

@jiashengguo jiashengguo commented Mar 18, 2024

  1. Remove extra quote used in pnpm pack destionation.
  2. Always use normalized path to generate path used in schema file.

Summary by CodeRabbit

  • Tests
    • Enhanced path normalization in test setups for OpenAPI, SWR, TanStack Query, and tRPC plugins using a shared utility.
  • New Features
    • Introduced a normalizePath utility function for consistent path handling across tests and plugins.
  • Refactor
    • Centralized path normalization logic within the testing toolkit to improve maintainability and consistency.

Copy link
Contributor

coderabbitai bot commented Mar 18, 2024

Walkthrough

Walkthrough

The updates involve integrating the normalizePath function from @zenstackhq/testtools across various testing files within the OpenAPI, SWR, Tanstack Query, and tRPC plugins. This function is used to normalize paths in the provider field and elsewhere. Additionally, the testtools package itself sees enhancements with the export of normalizePath, the introduction of normalizedProjectRoot, and an upgrade in the loadSchema function for better path handling.

Changes

Files Change Summary
.../openapi/tests/openapi-restful.test.ts, .../openapi/tests/openapi-rpc.test.ts Added normalizePath import and used it for path normalization in provider fields.
.../swr/tests/swr.test.ts, .../tanstack-query/tests/plugin.test.ts, .../trpc/tests/trpc.test.ts Imported normalizePath and applied it to paths in provider and extraDependencies.
.../testtools/src/schema.ts Exported normalizePath, added normalizedProjectRoot, and updated loadSchema for improved 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:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

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

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d7dbba9 and 1a0b3b9.
Files ignored due to path filters (6)
  • packages/language/package.json is excluded by: !**/*.json
  • packages/misc/redwood/package.json is excluded by: !**/*.json
  • packages/plugins/openapi/package.json is excluded by: !**/*.json
  • packages/plugins/swr/package.json is excluded by: !**/*.json
  • packages/plugins/tanstack-query/package.json is excluded by: !**/*.json
  • packages/plugins/trpc/package.json is excluded by: !**/*.json
Files selected for processing (6)
  • packages/plugins/openapi/tests/openapi-restful.test.ts (8 hunks)
  • packages/plugins/openapi/tests/openapi-rpc.test.ts (12 hunks)
  • packages/plugins/swr/tests/swr.test.ts (3 hunks)
  • packages/plugins/tanstack-query/tests/plugin.test.ts (7 hunks)
  • packages/plugins/trpc/tests/trpc.test.ts (11 hunks)
  • packages/testtools/src/schema.ts (3 hunks)
Additional comments: 37
packages/plugins/swr/tests/swr.test.ts (3)
  • 3-3: The import statement for normalizePath and loadSchema is correctly added.
  • 53-53: Usage of normalizePath for the provider field is correct and ensures consistent path formats across different operating systems.
  • 63-63: Correct application of normalizePath in the extraDependencies field to ensure consistent path handling.
packages/plugins/tanstack-query/tests/plugin.test.ts (5)
  • 3-3: The import statement for normalizePath and loadSchema is correctly added.
  • 53-53: Correct usage of normalizePath for the provider field in the first plugin configuration.
  • 74-74: Correct usage of normalizePath for the provider field in the second plugin configuration.
  • 96-96: Correct usage of normalizePath for the provider field in the third plugin configuration.
  • 117-117: Correct usage of normalizePath for the provider field in the fourth plugin configuration.
packages/plugins/openapi/tests/openapi-restful.test.ts (4)
  • 7-7: The import statement for normalizePath and loadZModelAndDmmf is correctly added.
  • 19-19: Correct usage of normalizePath for the provider field in the first plugin openapi configuration.
  • 117-117: Correct usage of normalizePath for the provider field in the second plugin openapi configuration.
  • 154-154: Correct usage of normalizePath for the provider field in the third plugin openapi configuration.
packages/testtools/src/schema.ts (4)
  • 57-57: Exporting normalizePath function is correctly implemented.
  • 178-178: Introduction of normalizedProjectRoot variable is correctly implemented for consistent path handling.
  • 196-196: Correct application of normalizedProjectRoot to replace $projectRoot placeholder in the schema file for the multiple files scenario.
  • 201-201: Correct application of normalizedProjectRoot to replace $projectRoot placeholder in the schema file for the single file scenario.
packages/plugins/trpc/tests/trpc.test.ts (9)
  • 3-3: The import statement for normalizePath and loadSchema is correctly added.
  • 22-22: Correct usage of normalizePath for the provider field in the first plugin trpc configuration.
  • 70-70: Correct usage of normalizePath for the provider field in the second plugin trpc configuration.
  • 113-113: Correct usage of normalizePath for the provider field in the third plugin trpc configuration.
  • 144-144: Correct usage of normalizePath for the provider field in the fourth plugin trpc configuration.
  • 174-174: Correct usage of normalizePath for the provider field in the fifth plugin trpc configuration.
  • 223-223: Correct usage of normalizePath for the provider field in the sixth plugin trpc configuration.
  • 248-248: Correct usage of normalizePath for the provider field in the seventh plugin trpc configuration.
  • 268-268: Correct usage of normalizePath for the provider field in the eighth plugin trpc configuration.
packages/plugins/openapi/tests/openapi-rpc.test.ts (12)
  • 7-7: The addition of normalizePath from @zenstackhq/testtools is a good step towards ensuring path consistency across different operating systems. This aligns well with the PR's objectives.
  • 19-19: Using normalizePath for the provider field in the plugin openapi declaration is a correct application of the function to ensure path normalization. This change should help address the issue of test failures on Windows due to path inconsistencies.
  • 130-130: The repeated use of normalizePath for the provider field in different test scenarios demonstrates a consistent approach to handling paths across the test suite. This is crucial for maintaining cross-platform compatibility.
  • 167-167: Again, the application of normalizePath to the provider field in the context of testing security schemes is appropriate. It's good to see this level of attention to detail in ensuring path normalization is applied consistently throughout the test file.
  • 201-201: Consistent with previous instances, the use of normalizePath here is correct. It's important to ensure that even in test scenarios expected to fail or produce errors, paths are handled consistently to avoid conflating path issues with the intended test failures.
  • 222-222: The application of normalizePath in this segment, similar to previous ones, is correctly done. Ensuring that paths are normalized across all test scenarios, including those with security model level overrides, is key to the reliability of these tests on Windows.
  • 250-250: The use of normalizePath for the provider field in the context of security operation level overrides is another correct implementation. This consistency in applying path normalization is commendable and supports the PR's goal of cross-platform test reliability.
  • 283-283: Applying normalizePath in the scenario of inferred security schemes is appropriate. This ensures that the path normalization is uniformly applied across different types of test cases, including those that infer security from other settings.
  • 309-309: The use of normalizePath in this test case, which focuses on specific fields available in OpenAPI 3.1.0, is correctly implemented. It's good to see the normalization applied consistently across various test scenarios, including those testing new or specific features.
  • 333-333: The application of normalizePath in the context of testing ignored models used as relations is appropriate. This ensures that path normalization considerations do not interfere with the specific focus of the test case.
  • 365-365: Using normalizePath for the provider field in the context of testing field type coverage is correctly done. This demonstrates a thorough application of path normalization across a wide range of test scenarios, including those that focus on the coverage of different field types.
  • 411-411: The consistent application of normalizePath in the final test case, which seems to focus on full-text search capabilities, is appropriate. This ensures that path normalization is considered even in specialized test scenarios, supporting the overall goal of cross-platform compatibility.

@ymc9 ymc9 merged commit 24b189e into dev Mar 19, 2024
@ymc9 ymc9 deleted the jiasheng-fixtest branch March 19, 2024 04:27
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