-
Notifications
You must be signed in to change notification settings - Fork 53
fix: recs tests #301
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
fix: recs tests #301
Conversation
WalkthroughThe changes involve modifications to the test suite for the Changes
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (1)
packages/state/src/__tests__/utils.test.ts (1)
Line range hint
95-108
: Verify the expected behavior for nested schema conversions.The test case for nested schema values is a good addition to improve coverage. However, the expected result structure seems unusual:
expect(result.nested).toEqual({ innerField: { value: "42" } });This structure suggests that the inner value is not being converted to a number, which might not be the intended behavior of
convertValues
. Typically, we would expect the result to be:expect(result.nested).toEqual({ innerField: 42 });Please verify if this is the intended behavior of
convertValues
for nested schemas. If not, consider updating the test case or theconvertValues
function to ensure proper conversion of nested values.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- packages/state/src/tests/utils.test.ts (3 hunks)
🧰 Additional context used
🔇 Additional comments (3)
packages/state/src/__tests__/utils.test.ts (3)
Line range hint
25-58
: New test case for hexadecimal BigInt conversion looks good.The addition of a test case for converting huge hexadecimal BigInt values improves the test coverage. This is a good practice to ensure the
convertValues
function handles various input formats correctly.However, please note that the test for converting huge numbers in StringArray has been modified to remove the
type: "array"
property from thevalues
object.Could you verify if this change is intentional and doesn't affect the type checking or functionality of the
convertValues
function? You may want to check the implementation ofconvertValues
to ensure it still handles StringArray correctly without the explicit type.
Line range hint
60-93
: New test cases for basic data types are a good addition.The new test cases for boolean, string, null, and undefined values improve the coverage of the
convertValues
function for basic data types. This is a positive change that helps ensure the function handles various input types correctly.Consider adding the following test cases to further improve coverage:
- Test with an empty string input.
- Test with a floating-point number input.
- Test with a negative number input.
- Test with an array of mixed data types.
Would you like me to provide example implementations for these additional test cases?
Line range hint
1-111
: Verify test coverage after removing several test cases.Several test cases have been removed from the test suite, including:
- Handling empty StringArray
- Converting StringArray with enum types
- Handling invalid BigInt strings
- Converting arrays of structs
- Handling default cases for unhandled schema types
While simplifying the test suite can improve maintainability, it's important to ensure that these removals don't negatively impact the overall test coverage.
Please run a test coverage analysis to ensure that the
convertValues
function is still adequately tested after these removals. Consider the following actions:
- Run a coverage report for the
convertValues
function.- Review the function's implementation to identify any edge cases that might no longer be covered.
- If necessary, add new test cases to maintain comprehensive coverage.
Would you like assistance in generating a script to run the coverage analysis or in creating new test cases to address any coverage gaps?
import { Type as RecsType } from "@dojoengine/recs"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import { convertValues } from "../utils"; | ||
|
||
describe("convertValues", () => { | ||
// Mock console.warn to suppress warnings during tests | ||
beforeEach(() => { | ||
vi.spyOn(console, "warn").mockImplementation(() => {}); | ||
}); | ||
// ... existing tests ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Removed console.warn
mock may affect other tests.
Multiple console.warn
calls were found across the codebase. Without mocking console.warn
, tests that rely on these warnings might produce unexpected outputs or fail.
packages/react/src/utils/useMountedState.ts: console.warn(
packages/state/src/recs/index.ts: console.warn(
packages/state/src/utils/index.ts: console.warn(
packages/state/src/utils/index.ts: console.warn(
packages/sdk/src/parseEntities.ts: console.warn(\
Invalid modelName format: ${modelName}`);`packages/core/src/logger/logger.ts: this.warn = console.warn.bind(console);
packages/create-burner/src/manager/burnerManager.ts: // console.warn(error);
🔗 Analysis chain
Verify the impact of removing the console.warn
mock.
The beforeEach
setup for mocking console.warn
has been removed. This change might affect test output if warnings were expected in certain scenarios.
Please run the following script to check for any console.warn
calls in the codebase:
If there are any console.warn
calls, consider whether they need to be mocked or if the tests should be updated to handle potential warnings.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for console.warn calls in the codebase
# Test: Look for console.warn calls
rg --type typescript 'console\.warn'
Length of output: 73
Script:
#!/bin/bash
# Description: Search for console.warn calls in .ts and .tsx files
rg 'console\.warn' -g '*.ts' -g '*.tsx'
Length of output: 607
Summary by CodeRabbit
convertValues
function by removing several test cases and adjusting existing ones.