-
Notifications
You must be signed in to change notification settings - Fork 297
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
Development
: Fix load rating api spam and fix flaky e2e tests
#9665
Conversation
Development
Fix load rating api spam and fix flaky tests
Development
Fix load rating api spam and fix flaky testsDevelopment
Fix load rating api spam and fix flaky tests
Development
Fix load rating api spam and fix flaky testsDevelopment
: Fix load rating api spam and fix flaky tests
WalkthroughThe changes in the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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
Documentation and Community
|
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.
While the fix looks good, would it be possible to add a small client test that ensures (and documents) that this issue does not occur again?
Not that somebody tries to simplify the condition and the test turns flaky again 😅
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
🧹 Outside diff range and nitpick comments (2)
src/test/javascript/spec/component/rating/rating.component.spec.ts (2)
97-101
: Enhance test specificity for result changes.The test correctly verifies the number of loadRating calls and final rating value. However, we could make it more explicit and robust.
Consider enhancing the test:
ratingComponent.result = { id: 91 } as Result; +ratingComponent.result.submission = { id: 1 } as Submission; +ratingComponent.result.participation = { id: 1 } as Participation; ratingComponentFixture.detectChanges(); -expect(loadRatingSpy).toHaveBeenCalledTimes(2); +expect(loadRatingSpy).toHaveBeenCalledExactlyOnceWith(90); +expect(loadRatingSpy).toHaveBeenCalledExactlyOnceWith(91); expect(ratingComponent.rating).toBe(2);
103-112
: LGTM! Consider additional edge cases.The test effectively verifies the optimization to prevent unnecessary API calls. Good job documenting the purpose with the comment.
Consider adding these edge cases:
it('should not call loadRating when only result object reference changes', () => { const loadRatingSpy = jest.spyOn(ratingComponent, 'loadRating'); ratingComponent.result = { id: 90, submission: { id: 1 }, participation: { id: 1 } } as Result; ratingComponentFixture.detectChanges(); // Create new object with same ID but different reference ratingComponent.result = { id: 90, submission: { id: 2 }, // different submission participation: { id: 1 } } as Result; ratingComponentFixture.detectChanges(); expect(loadRatingSpy).toHaveBeenCalledOnce(); expect(loadRatingSpy).toHaveBeenCalledExactlyOnceWith(90); });
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
src/test/javascript/spec/component/rating/rating.component.spec.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/test/javascript/spec/component/rating/rating.component.spec.ts (1)
Pattern src/test/javascript/spec/**/*.ts
: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}
Development
: Fix load rating api spam and fix flaky testsDevelopment
: Fix load rating api spam and fix flaky e2e 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.
Code lgtm, e2e tests pass
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.
Thanks for the fix. LGTM
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.
Code looks good to me 👍
Checklist
General
Client
Motivation and Context
There were some flaky tests. It was because the rating api was being spam called in the on changed hook .
Description
Steps for Testing
Prerequisites:
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Code Review
Manual Tests
Summary by CodeRabbit
Bug Fixes
Refactor
Tests
RatingComponent
, ensuring correct behavior when the result changes and preventing unnecessary API calls. Adjusted tests to handle scenarios with missing data.