-
Notifications
You must be signed in to change notification settings - Fork 7
Add tests for dotrain add order lsp file #1719
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
Conversation
""" WalkthroughA new test module was introduced to the Changes
Sequence Diagram(s)sequenceDiagram
participant Test as test_problems()
participant Doc as TextDocumentItem
participant LSP as DotrainAddOrderLsp
Test->>Doc: Create TextDocumentItem with test Rainlang text
Test->>LSP: Instantiate DotrainAddOrderLsp with Doc
Test->>LSP: Call problems()
LSP-->>Test: Return list of problems (diagnostics)
Test->>Test: Assert problems match expected diagnostics
Assessment against linked issues
Suggested reviewers
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
@hardyjosh I didn't add any tests for hover and completion functions because they aren't used anywhere in both webapp and tauri app. I could not figure out how they are used so if you have any input on this, that would be awesome. |
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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
crates/common/src/dotrain_add_order_lsp.rs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (16)
- GitHub Check: git-clean
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
- GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
- GitHub Check: build-tauri (ubuntu-22.04, true)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
- GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
- GitHub Check: test
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
- GitHub Check: test
- GitHub Check: test
- GitHub Check: Deploy-Preview
- GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
- GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
🔇 Additional comments (3)
crates/common/src/dotrain_add_order_lsp.rs (3)
123-126
: Appropriate test module setup and imports.The test module is correctly set up with the
#[cfg(test)]
attribute and imports the necessary components. This is a good practice for isolating test code.
128-206
: Well-structured test data with appropriate test cases.The
TEXT
constant provides comprehensive test coverage with various sections (tokens, orders, scenarios, deployments) and intentionally includes different kinds of errors to test problem detection. This approach ensures thorough testing of the LSP functionality.
208-215
: Clean helper function implementation.The
get_text_document
helper function is well-implemented, making the test more readable by encapsulating the creation of the test document.
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.
Should we have a test case with no problems?
right, the front end work was something we decided to deprioritise. for the same reason i agree it wouldn't be a good use of time to write tests for it right now. |
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
♻️ Duplicate comments (1)
crates/common/src/dotrain_add_order_lsp.rs (1)
241-241
: 🧹 Nitpick (assertive)Consider using a mock or configurable RPC URL.
While the test is using a different URL from a previous review comment, it's still using a hardcoded URL which could be problematic if tests run in environments with different configurations. Consider using a clearly fake URL pattern or an environment variable.
- let problems = lsp.problems("https://some-rpc-url.com", None, None).await; + // Use a clearly fake URL or environment variable for testing + let problems = lsp.problems("http://invalid-test-url", None, None).await;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
crates/common/src/dotrain_add_order_lsp.rs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
- GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
- GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
- GitHub Check: test
- GitHub Check: test
- GitHub Check: test
- GitHub Check: Deploy-Preview
- GitHub Check: git-clean
- GitHub Check: build-tauri (ubuntu-22.04, true)
🔇 Additional comments (3)
crates/common/src/dotrain_add_order_lsp.rs (3)
218-236
: Good job on the test_no_problems implementation.The test correctly sets up a LocalEvm instance and tests the "happy path" by verifying that a valid document produces no problems. Using a real deployer address from the local EVM provides better test coverage than a dummy value.
257-259
: Effective implementation of message comparison.This implementation addresses the nitpick from a previous reviewer about displaying mismatches more clearly by comparing messages pairwise rather than comparing entire vectors.
238-256
: Comprehensive problem detection test.The test effectively validates that the
problems
method correctly identifies all expected issues in an invalid document. The assertions check both the number of problems and their specific messages, which provides good coverage of the error detection logic.
Motivation
See issue: #1625
Solution
Checks
By submitting this for review, I'm confirming I've done the following:
[ ] included screenshots (if this involves a front-end change)fix #1625
Summary by CodeRabbit