bug: add assertions to service spec tests (SonarQube S2699)#34
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
bug: add assertions to service spec tests (SonarQube S2699)#34devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the 9 open SonarQube
S2699blockers ("Add at least one assertion to this test case") in the Angular service specs. These tests subscribed to a service call and usedhttpMock.expectOne(...)to drive the request, but had noexpect(...)call —expectOneis not recognized by SonarQube as an assertion, so the tests were flagged as assertion-less.Each flagged test now asserts the captured request's HTTP method, matching the existing convention used in the surrounding tests (e.g.
articles.service.spec.ts:114,comments.service.spec.ts:173).const req = httpMock.expectOne(`/profiles/${username}`); + expect(req.request.method).toBe('GET'); req.flush({ profile: { ...mockProfile, username } });Files / tests touched:
articles.service.spec.ts— "should handle pagination parameters" (GET)comments.service.spec.ts— "slug with special characters" (GET), "numeric comment ID" / "UUID comment ID" (DELETE)profile.service.spec.ts— "username with special characters", "with numbers", "with hyphens", "with underscores", "very long username" (GET)Notes
java:S2699, but there are nojava:S2699issues in this org's SonarQube — the matching blockers aretypescript:S2699in this repo. Same rule (S2699), TypeScript analyzer.mainindependently of this change — every spec importszone.jswhich is not a declared dependency, so all spec files fail to load on a clean checkout. Tests here were validated by temporarily installingzone.jslocally (not part of this PR). This pre-existing test-setup gap may want a separate fix.Link to Devin session: https://app.devin.ai/sessions/8bf682121cf4422e9d34860899031849
Requested by: @Colhodm
Devin Review
eda2fcf