-
Notifications
You must be signed in to change notification settings - Fork 47
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: Ensure that SDK getDispute() returns the RTA/Invalid answer #1831
Conversation
WalkthroughThis pull request updates the version of the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🪧 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 (
|
✅ Deploy Preview for kleros-v2-testnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for kleros-v2-university ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for kleros-v2-neo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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
🧹 Nitpick comments (3)
kleros-sdk/test/getDispute.test.ts (3)
28-61
: Add test cases for edge cases and malformed dataWhile the test coverage is good, consider adding these test cases:
- Malformed answer structure (missing required fields)
- Non-hex IDs in answers array
- Snapshot test for the entire dispute object
Example test case for malformed data:
it("should handle malformed answer structure gracefully", async () => { const mockTemplate = { disputeTemplate: { templateData: JSON.stringify({ answers: [ { /* missing id */ }, { id: null }, { id: undefined }, ], }), templateDataMappings: "", }, }; // ... setup mocks ... const result = await getDispute({ disputeId: mockDisputeId, coreSubgraph: mockCoreSubgraph, dtrSubgraph: mockDtrSubgraph, }); expect(result?.answers[0].id).toBe("0x0"); });
198-208
: Enhance error test with specific error typeThe error test could be more specific by checking the exact error type.
await expect( getDispute({ disputeId: mockDisputeId, coreSubgraph: mockCoreSubgraph, dtrSubgraph: mockDtrSubgraph, }) - ).rejects.toThrow("Dispute details not found"); + ).rejects.toThrow(NotFoundError); + ).rejects.toThrowError("Dispute details not found for disputeId: 123");
6-8
: Consider using more specific mock importsInstead of mocking the entire module, consider mocking specific functions for better test isolation.
-vi.mock("../src/requests/fetchDisputeDetails"); -vi.mock("../src/requests/fetchDisputeTemplateFromId"); +vi.mock("../src/requests/fetchDisputeDetails", () => ({ + default: vi.fn() +})); +vi.mock("../src/requests/fetchDisputeTemplateFromId", () => ({ + default: vi.fn() +}));
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
kleros-sdk/package.json
(1 hunks)kleros-sdk/src/utils/getDispute.ts
(1 hunks)kleros-sdk/test/getDispute.test.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- kleros-sdk/package.json
⏰ Context from checks skipped due to timeout of 90000ms (18)
- GitHub Check: Redirect rules - kleros-v2-neo
- GitHub Check: Header rules - kleros-v2-neo
- GitHub Check: Pages changed - kleros-v2-neo
- GitHub Check: Redirect rules - kleros-v2-university
- GitHub Check: Redirect rules - kleros-v2-testnet
- GitHub Check: Redirect rules - kleros-v2-testnet
- GitHub Check: Header rules - kleros-v2-university
- GitHub Check: Header rules - kleros-v2-testnet
- GitHub Check: Header rules - kleros-v2-testnet
- GitHub Check: Pages changed - kleros-v2-university
- GitHub Check: Pages changed - kleros-v2-testnet
- GitHub Check: Pages changed - kleros-v2-testnet
- GitHub Check: Copy labels from linked issues
- GitHub Check: SonarCloud
- GitHub Check: contracts-testing
- GitHub Check: Copy labels from linked issues
- GitHub Check: dependency-review
- GitHub Check: Analyze (javascript)
❌ Deploy Preview for kleros-v2-testnet-devtools failed. Why did it fail? →
|
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.
LGTM!
Thanks for the quick change
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.
lgtm
6411a42
to
6d0cbeb
Compare
2c9ea33
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.
lgtm
Code Climate has analyzed commit 364cb02 and detected 2 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
|
Resolves https://github.com/kleros/atlas/issues/369
PR-Codex overview
This PR updates the
@kleros/kleros-sdk
package version and enhances thegetDispute
functionality to include a standard "Refuse to Arbitrate" answer in various scenarios. It also adds tests to ensure this behavior works correctly.Detailed summary
version
inpackage.json
from2.1.10
to2.1.12
.populatedTemplate.answers
ingetDispute
.getDispute
ingetDispute.test.ts
:0x0
or0x00
.Summary by CodeRabbit
New Features
Tests
getDispute
function.Version Update