-
Notifications
You must be signed in to change notification settings - Fork 32
Make index swap test more permissive #442
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
WalkthroughReworked a test in swaps_test.dart to validate the swaps response by casting to a List, asserting length, and checking specific inner map values via indexed access instead of a single deep-structure equality assertion. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
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. CodeRabbit Commands (Invoked using PR/Issue comments)Type 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: 0
🧹 Nitpick comments (1)
test/swaps_test.dart (1)
34-37: Assertions still rely on list order; make them order-agnostic (and robust to pair order).Good move away from deep structural equality. However, indexing into responseSwaps assumes the backend preserves the order of swaps, which may change across versions or implementations. Also, some backends may reorder the two indexes within each pair. Prefer presence-based, order-agnostic assertions.
Apply this diff to avoid order assumptions and slightly strengthen typing:
- var responseSwaps = response.details!['swaps'] as List; - expect(responseSwaps, hasLength(2)); - expect(responseSwaps[0]['indexes'], books); - expect(responseSwaps[1]['indexes'], movies); + final responseSwaps = + (response.details!['swaps'] as List).cast<Map<String, dynamic>>(); + expect(responseSwaps, hasLength(2)); + expect( + responseSwaps, + anyElement(containsPair('indexes', unorderedEquals(books))), + ); + expect( + responseSwaps, + anyElement(containsPair('indexes', unorderedEquals(movies))), + );This:
- Doesn’t depend on the order of swaps returned by the server.
- Doesn’t depend on the order of the two indexes within each swap.
- Gives better IDE/type help on responseSwaps.
If the API guarantees both orders are stable, feel free to keep the simpler assertions—but given the PR objective to make the test more permissive, this version is safer.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
test/swaps_test.dart(1 hunks)
curquiza
left a comment
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.
bors merge
|
Build succeeded: |
Fix Meilisearch 1.18 tests run
Summary by CodeRabbit