fix(test): image ordering test update#1220
Merged
Merged
Conversation
7b719c9 to
50a0f57
Compare
Signed-off-by: Valiantsin Tsimoshyk <v.tsimoshyk@sap.com>
50a0f57 to
4356f75
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the image ordering E2E coverage to better lock in the expected “sort by vulnerability counts, then repository” behavior, and adjusts the GraphQL image resolver so image queries don’t error when no service filter is provided.
Changes:
- Adjusted
seed10Entriesto remap component IDs during seeding so ordering tests fail if severity-based sorting is removed. - Added an E2E test case ensuring the images query succeeds even with an empty filter (no service filter).
- Updated
ImageBaseResolverordering logic to only apply severity-count ordering when a service filter is present (avoids SQL errors due to missing service-scoped count joins).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/e2e/image_query_test.go | Adds an E2E test for “no service filter” and tweaks seeding to strengthen ordering assertions. |
| internal/api/graphql/graph/baseResolver/image.go | Makes default ordering conditional on service being provided to prevent errors in the unscoped case. |
Comments suppressed due to low confidence (1)
internal/api/graphql/graph/baseResolver/image.go:59
- Ordering only by repository name can be non-deterministic when multiple components share the same repository, which can break cursor-based pagination. Other resolvers add a stable ID as a final tie-breaker (e.g., ServiceBaseResolver appends ServiceId; ComponentVersionBaseResolver appends ComponentVersionId). Add ComponentId as a final ordering field to make pagination stable.
opt.Order = append(opt.Order, entity.Order{
By: entity.ComponentRepository,
Direction: entity.OrderDirectionAsc,
})
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
46
to
47
| // Set default ordering by vulnerability counts | ||
| // Secondary ordering by repository name |
Comment on lines
+84
to
+86
| Expect(err).ToNot(HaveOccurred()) | ||
| Expect(respData.Images.TotalCount).To(BeNumerically(">=", 0)) | ||
| }) |
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.
Description
What type of PR is this?
Related Tickets & Documents
Added tests?
Added to documentation?
Checklist