Skip to content

fix(test): image ordering test update#1220

Merged
MR2011 merged 1 commit into
mainfrom
tsim-sap/issue-1207/update-image-test
Jun 17, 2026
Merged

fix(test): image ordering test update#1220
MR2011 merged 1 commit into
mainfrom
tsim-sap/issue-1207/update-image-test

Conversation

@tsim-sap

Copy link
Copy Markdown
Collaborator

Description

   - Updated seed10Entries to swap component IDs during seeding, ensuring that ID order is different from vulnerability severity order.
   - Added a new test case to verify that querying images without a service filter does not result in an error.
   - Verified that existing tests now correctly fail if the sorting logic is removed.

What type of PR is this?

  • ✅ Test

Related Tickets & Documents

Remove if not applicable

Added tests?

  • 👍 yes

Added to documentation?

  • 🙅 no documentation needed

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@tsim-sap tsim-sap force-pushed the tsim-sap/issue-1207/update-image-test branch from 7b719c9 to 50a0f57 Compare June 12, 2026 09:33
Signed-off-by: Valiantsin Tsimoshyk <v.tsimoshyk@sap.com>
@tsim-sap tsim-sap force-pushed the tsim-sap/issue-1207/update-image-test branch from 50a0f57 to 4356f75 Compare June 16, 2026 12:24
@tsim-sap tsim-sap marked this pull request as ready for review June 17, 2026 07:50
Copilot AI review requested due to automatic review settings June 17, 2026 07:50

@michalkrzyz michalkrzyz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 seed10Entries to 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 ImageBaseResolver ordering 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))
})
@MR2011 MR2011 merged commit 0dcf6a1 into main Jun 17, 2026
12 checks passed
@MR2011 MR2011 deleted the tsim-sap/issue-1207/update-image-test branch June 17, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(image): update image ordering test

4 participants