Skip to content

chore(test): adjust order of vulnerabilities after a backend change - #1205

Merged
mrrajan merged 1 commit into
guacsec:mainfrom
matejnesuta:homepage_test_fix
Aug 13, 2026
Merged

chore(test): adjust order of vulnerabilities after a backend change#1205
mrrajan merged 1 commit into
guacsec:mainfrom
matejnesuta:homepage_test_fix

Conversation

@matejnesuta

@matejnesuta matejnesuta commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Changed the order of vulnerabilities in a test to match to address a backend fix. Hopefully this fixes current issues with the CI.

Related Issues

guacsec/trustify#2569

Summary by Sourcery

Tests:

  • Adjust the expected order of top critical and high vulnerabilities in the home page attention test to match backend behavior.

@sourcery-ai

sourcery-ai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates an end-to-end UI test’s expected vulnerability ordering to match the backend’s new sort order, resolving failing CI assertions.

File-Level Changes

Change Details Files
Adjusted the expected ordering of top vulnerabilities in the home page attention E2E test to align with backend changes.
  • Updated the EXPECTED_TOP_3 array to place CVE-2026-63223 before CVE-2026-18236 while keeping severities and remaining entries unchanged
  • Ensured the test continues to assert identifiers and severities using regex for severity matching
e2e/tests/ui/pages/home/attention.spec.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="e2e/tests/ui/pages/home/attention.spec.ts" line_range="8" />
<code_context>
 import { HomePage } from "./HomePage";

 const EXPECTED_TOP_3 = [
-  { identifier: "CVE-2026-18236", severity: /critical/i },
   { identifier: "CVE-2026-63223", severity: /critical/i },
+  { identifier: "CVE-2026-18236", severity: /critical/i },
   { identifier: "CVE-2026-18358", severity: /high/i },
 ] as const;
</code_context>
<issue_to_address>
**suggestion (testing):** Consider making the test resilient to ordering changes when vulnerabilities share the same severity.

The test currently depends on the exact order of the two critical vulnerabilities. Since the backend has already changed this once, it would be more robust to assert that both critical CVEs appear in the "top" vulnerabilities section (and are marked as critical) without relying on their relative order—unless the product explicitly guarantees a specific sort criterion. If ordering is guaranteed, please add a brief comment in the test documenting the expected sort key so future backend changes don’t unintentionally break CI.

Suggested implementation:

```typescript
import { HomePage } from "./HomePage";

/**
 * Expected vulnerabilities in the "Top vulnerabilities" section.
 *
 * Do not rely on the relative ordering of vulnerabilities that share
 * the same severity (e.g. multiple critical CVEs): backend sorting may
 * change as long as the section still contains the same set of items.
 */
const EXPECTED_TOP_3 = [
  { identifier: "CVE-2026-63223", severity: /critical/i },
  { identifier: "CVE-2026-18236", severity: /critical/i },
  { identifier: "CVE-2026-18358", severity: /high/i },
] as const;

/**
 * Subset of EXPECTED_TOP_3 that should be marked as critical.
 * Tests should use this to assert presence and severity of critical CVEs
 * without depending on their order in the list.
 */
const EXPECTED_CRITICAL_TOP_VULNERABILITIES = EXPECTED_TOP_3.filter(
  ({ severity }) => severity.test("critical"),
);

```

To fully implement the suggestion and make the test resilient to ordering changes:

1. Update the assertion that checks the "Top vulnerabilities" list so that it does **not** assert exact ordering for the critical CVEs.
   - Instead of something like `expect(renderedTopVulns).toEqual(EXPECTED_TOP_3)`, use a combination of:
     - `expect(renderedTopVulns).toEqual(expect.arrayContaining(EXPECTED_TOP_3));` if you only care about membership, or
     - `expect(renderedTopVulns.map(v => v.identifier)).toEqual(expect.arrayContaining(EXPECTED_CRITICAL_TOP_VULNERABILITIES.map(v => v.identifier)));`
       plus explicit severity checks per item.
2. Ensure the test verifies that:
   - All identifiers from `EXPECTED_CRITICAL_TOP_VULNERABILITIES` appear in the "top vulnerabilities" section.
   - Each of those entries is marked as critical (matching the `/critical/i` severity).
   - The test does not assume any specific relative order between the critical CVEs.
3. If the product *does* guarantee a specific sort key (e.g. `severity desc, exploitability desc, identifier asc`), add a short inline comment near the assertion documenting that sort criterion so backend changes do not unintentionally break CI.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

import { HomePage } from "./HomePage";

const EXPECTED_TOP_3 = [
{ identifier: "CVE-2026-18236", severity: /critical/i },

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.

suggestion (testing): Consider making the test resilient to ordering changes when vulnerabilities share the same severity.

The test currently depends on the exact order of the two critical vulnerabilities. Since the backend has already changed this once, it would be more robust to assert that both critical CVEs appear in the "top" vulnerabilities section (and are marked as critical) without relying on their relative order—unless the product explicitly guarantees a specific sort criterion. If ordering is guaranteed, please add a brief comment in the test documenting the expected sort key so future backend changes don’t unintentionally break CI.

Suggested implementation:

import { HomePage } from "./HomePage";

/**
 * Expected vulnerabilities in the "Top vulnerabilities" section.
 *
 * Do not rely on the relative ordering of vulnerabilities that share
 * the same severity (e.g. multiple critical CVEs): backend sorting may
 * change as long as the section still contains the same set of items.
 */
const EXPECTED_TOP_3 = [
  { identifier: "CVE-2026-63223", severity: /critical/i },
  { identifier: "CVE-2026-18236", severity: /critical/i },
  { identifier: "CVE-2026-18358", severity: /high/i },
] as const;

/**
 * Subset of EXPECTED_TOP_3 that should be marked as critical.
 * Tests should use this to assert presence and severity of critical CVEs
 * without depending on their order in the list.
 */
const EXPECTED_CRITICAL_TOP_VULNERABILITIES = EXPECTED_TOP_3.filter(
  ({ severity }) => severity.test("critical"),
);

To fully implement the suggestion and make the test resilient to ordering changes:

  1. Update the assertion that checks the "Top vulnerabilities" list so that it does not assert exact ordering for the critical CVEs.
    • Instead of something like expect(renderedTopVulns).toEqual(EXPECTED_TOP_3), use a combination of:
      • expect(renderedTopVulns).toEqual(expect.arrayContaining(EXPECTED_TOP_3)); if you only care about membership, or
      • expect(renderedTopVulns.map(v => v.identifier)).toEqual(expect.arrayContaining(EXPECTED_CRITICAL_TOP_VULNERABILITIES.map(v => v.identifier)));
        plus explicit severity checks per item.
  2. Ensure the test verifies that:
    • All identifiers from EXPECTED_CRITICAL_TOP_VULNERABILITIES appear in the "top vulnerabilities" section.
    • Each of those entries is marked as critical (matching the /critical/i severity).
    • The test does not assume any specific relative order between the critical CVEs.
  3. If the product does guarantee a specific sort key (e.g. severity desc, exploitability desc, identifier asc), add a short inline comment near the assertion documenting that sort criterion so backend changes do not unintentionally break CI.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.19%. Comparing base (c2a97ed) to head (15b1d42).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1205      +/-   ##
==========================================
- Coverage   54.20%   54.19%   -0.02%     
==========================================
  Files         255      255              
  Lines        5715     5715              
  Branches     1774     1774              
==========================================
- Hits         3098     3097       -1     
  Misses       2355     2355              
- Partials      262      263       +1     
Flag Coverage Δ
e2e 70.36% <ø> (-0.03%) ⬇️
unit 8.65% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mrrajan mrrajan 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.

@matejnesuta Thanks for raising this PR, But this issue will be resolved with backend fix guacsec/trustify#2569

@mrrajan mrrajan 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.

LGTM, Even though the backend fix required for CVSS scoring - this fix also essential for correct ordering.

@mrrajan
mrrajan added this pull request to the merge queue Aug 13, 2026
Merged via the queue into guacsec:main with commit 1d0914c Aug 13, 2026
13 of 14 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Trustify Aug 13, 2026
@trustify-ci-bot

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release/0.6.z:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants