Skip to content

test(e2e): add SBOM Groups BDD test coverage#1108

Draft
mrrajan wants to merge 9 commits into
guacsec:mainfrom
mrrajan:TC-3811
Draft

test(e2e): add SBOM Groups BDD test coverage#1108
mrrajan wants to merge 9 commits into
guacsec:mainfrom
mrrajan:TC-3811

Conversation

@mrrajan

@mrrajan mrrajan commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Added 11 new BDD scenarios covering missing SBOM Groups test coverage identified in TC-3811
  • Scenarios cover: product labels, hierarchical tree display, parent group selection, invalid group ID handling, SBOM count, product badge on detail page, edit/remove parent, breadcrumb navigation, and sorting

Scenarios Added

# Scenario Priority
1 Product label badge appears for product groups High
2 Expand and collapse hierarchical tree nodes High
3 Create child group with parent selection High
4 Navigate to invalid group ID shows error Medium
5 SBOM count is displayed for groups with SBOMs Medium
6 Product badge is displayed on group detail page Medium
7 Edit group to assign a parent Medium
8 Edit group to remove parent makes it a root group Medium
9 Breadcrumb navigation on group detail page Low
10 Sort groups by name Low

Not Implemented (features not yet in codebase)

  • Remove SBOM from group — no UI exists for this action
  • "Groups" column on All SBOMs page — column does not exist in SBOM table
  • Loading states — requires component-level test, not E2E
  • React Query caching — requires unit/integration test, not E2E

Test plan

  • Run npm run e2e:test:ui to verify all scenarios pass
  • Verify new scenarios follow BDD standards (.claude/shared/bdd-standards.md)
  • Verify step definitions follow import order convention

Implements TC-3811

Summary by Sourcery

Tests:

  • Add new SBOM Groups BDD scenarios covering product labels, hierarchical tree expand/collapse, parent group selection and editing, invalid group ID error handling, SBOM count display, product badge on detail page, breadcrumb navigation, and name-based sorting.

@sourcery-ai

sourcery-ai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds comprehensive BDD test coverage for SBOM Groups UI, including product labeling, hierarchical tree behavior, parent-child relationships, invalid group navigation, SBOM counts, breadcrumbs, and sorting, plus minor cleanup of existing step definitions.

File-Level Changes

Change Details Files
Extend SBOM Groups step definitions with new actions and assertions to cover product labeling, tree expansion/collapse, parent selection and removal, invalid group IDs, SBOM count display, product badges, breadcrumb navigation, and sorting behavior.
  • Add steps to create/filter product groups and assert presence of product label badges in the treegrid and detail page.
  • Add steps to ensure parent/child groups exist, filter by group name, expand/collapse tree nodes, and assert child visibility and root-level status via aria-level.
  • Add steps for group creation form interactions including name filling, parent group selection, clearing parent selection, and success notification checks.
  • Add steps to directly navigate to an invalid group URL and assert error-state rendering.
  • Add steps to assert SBOM count text in a group row and to sort the groups table by name, verifying aria-sort attributes.
  • Add steps for breadcrumb assertions and navigation back to the Groups list.
e2e/tests/ui/features/@sbom-groups/sbom-groups.step.ts
Define new BDD scenarios to exercise SBOM Groups UI behaviors around product labels, hierarchy management, invalid navigation, SBOM counts, editing parent relationships, breadcrumbs, and name sorting.
  • Add scenario for product label badge visibility after creating and filtering a product group.
  • Add scenario for expanding and collapsing hierarchical tree nodes to show/hide a child group.
  • Add scenario for creating a child group with a selected parent and verifying its placement under the parent in the tree.
  • Add scenario for navigating to an invalid group ID and asserting an error state.
  • Add scenario for displaying SBOM counts for groups with associated SBOMs via bulk-add flow.
  • Add scenario for product badge visibility on the group detail page.
  • Add scenarios for editing a group to assign a parent and to remove a parent, verifying resulting hierarchy.
  • Add scenario for breadcrumb content and navigation from group detail back to the groups list.
  • Add scenario for sorting the groups table by name ascending and descending via column header clicks.
e2e/tests/ui/features/@sbom-groups/sbom-groups.feature
Clean up existing SBOM Groups steps by removing redundant comments around filter clearing and table visibility checks.
  • Remove inline comments that described behavior already enforced by clearAllFilters and visibility expectations for SBOM Groups rows.
  • Remove a redundant comment in the filtered results assertion step to keep the step file concise.
e2e/tests/ui/features/@sbom-groups/sbom-groups.step.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

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.09%. Comparing base (2e45be3) to head (add6f7c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1108      +/-   ##
==========================================
+ Coverage   53.07%   53.09%   +0.02%     
==========================================
  Files         270      270              
  Lines        5879     5937      +58     
  Branches     1842     1870      +28     
==========================================
+ Hits         3120     3152      +32     
- Misses       2455     2482      +27     
+ Partials      304      303       -1     
Flag Coverage Δ
unit 7.01% <ø> (ø)

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.

@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 2 issues, and left some high level feedback:

  • There is repeated setup logic for ensuring groups (and parent/child relationships) exist across multiple steps; consider extracting this into shared helper utilities to reduce duplication and keep test maintenance easier.
  • The invalid group ID error assertion uses a broad heading regex (/error|not found|something went wrong/i); tightening this to a known error message or a more specific selector would make the test less flaky and more resilient to copy changes.
  • Several selectors rely on visible text patterns (e.g., text=/\d+ SBOMs?/ and label text like "Product"); if UI copy changes are expected, you may want to pivot to more stable attributes or test-ids to avoid brittle tests.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There is repeated setup logic for ensuring groups (and parent/child relationships) exist across multiple steps; consider extracting this into shared helper utilities to reduce duplication and keep test maintenance easier.
- The invalid group ID error assertion uses a broad heading regex (`/error|not found|something went wrong/i`); tightening this to a known error message or a more specific selector would make the test less flaky and more resilient to copy changes.
- Several selectors rely on visible text patterns (e.g., `text=/\d+ SBOMs?/` and label text like "Product"); if UI copy changes are expected, you may want to pivot to more stable attributes or test-ids to avoid brittle tests.

## Individual Comments

### Comment 1
<location path="e2e/tests/ui/features/@sbom-groups/sbom-groups.step.ts" line_range="598-602" />
<code_context>
+  await page.goto("/sbom-groups/invalid-group-id-12345");
+});
+
+Then("An error state is displayed for the invalid group", async ({ page }) => {
+  const errorHeading = page.getByRole("heading", {
+    name: /error|not found|something went wrong/i,
+  });
+  await expect(errorHeading).toBeVisible({ timeout: 10000 });
+});
+
</code_context>
<issue_to_address>
**suggestion (testing):** Error state assertion for invalid group ID is quite generic and may produce false positives

This assertion currently matches any heading with `/error|not found|something went wrong/i`, which could pick up unrelated page errors and cause false positives. To make the test reliably about SBOM group errors, assert against a more specific selector or message for the SBOM groups error UI (e.g., a dedicated data-testid or fixed heading text), and optionally check that the URL stays on the invalid group route. That way the test proves the invalid group ID triggers the intended error state, not just any generic error on the page.

Suggested implementation:

```typescript
 // Invalid group ID handling
When("User navigates to group details with invalid ID", async ({ page }) => {
  await page.goto("/sbom-groups/invalid-group-id-12345");
});

Then("An error state is displayed for the invalid group", async ({ page }) => {
  // Assert we stay on the invalid group route
  await expect(page).toHaveURL(/\/sbom-groups\/invalid-group-id-12345$/);

  // Assert the dedicated SBOM group error UI is shown
  const sbomGroupError = page.getByTestId("sbom-group-error");
  await expect(sbomGroupError).toBeVisible();
});

Then("The SBOM Groups table shows all groups", async ({ page }) => {
  const table = page.getByRole("treegrid", { name: "sbom-groups-table" });
  await expect(table).toBeVisible();

  const rows = table.getByRole("row");
  await expect(rows.first()).toBeVisible();
});
Then(

```

1. Ensure the SBOM group error UI in the application uses `data-testid="sbom-group-error"` on the container element (e.g., the alert or error panel). If a different test id or fixed heading text is already used (such as `"sbom-group-not-found-heading"` or a specific error message string), update the selector in this step definition to match the existing UI.
2. If the invalid-group route differs (for example, it includes a workspace/org prefix or uses a different path segment), adjust the regular expression in `toHaveURL` to match the actual route shape.
</issue_to_address>

### Comment 2
<location path="e2e/tests/ui/features/@sbom-groups/sbom-groups.step.ts" line_range="445" />
<code_context>
 Then(
   "The SBOM Groups table shows filtered results containing {string}",
   async ({ page }, searchTerm: string) => {
</code_context>
<issue_to_address>
**suggestion (testing):** SBOM count assertion doesn’t distinguish zero vs non-zero counts or missing content

The `Then "The SBOM count is displayed for group {string}"` step only asserts that text matching `"\d+ SBOMs?"` is visible, which passes for `0 SBOMs` and could miss cases where the count is absent but similar text appears. If the behavior requires at least one SBOM, please assert on the parsed numeric value (e.g., `> 0`). Otherwise, add a dedicated scenario for `0 SBOMs` so both zero and non-zero states are explicitly covered.

Suggested implementation:

```typescript
Then(
  "The SBOM count is displayed for group {string}",
  async ({ page }, groupName: string) => {
    const groupRow = page.getByRole("row", { name: new RegExp(groupName, "i") });
    await expect(groupRow).toBeVisible();

    const sbomCountLocator = groupRow.getByText(/\d+\s+SBOMs?/);
    const sbomCountText = await sbomCountLocator.textContent();

    expect(sbomCountText).not.toBeNull();

    const match = sbomCountText!.match(/(\d+)\s+SBOMs?/);
    expect(match).not.toBeNull();

    const sbomCount = Number.parseInt(match![1], 10);
    expect(sbomCount).toBeGreaterThan(0);
  },
);

```

1. Ensure the DOM structure for the SBOM count matches the locator assumptions (count text within the group row and formatted like `"N SBOMs"`). If the count is in a different element (e.g., a specific column), adjust `sbomCountLocator` accordingly (e.g., `groupRow.getByRole("cell", { name: /\d+\s+SBOMs?/ })`).
2. If the product must support a valid `0 SBOMs` state, add a dedicated scenario to your feature file (e.g., `"The SBOM count shows zero SBOMs for group {string}"`) that asserts `sbomCount === 0` instead of `> 0`, using the same parsing logic.
</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.

Comment on lines +598 to +602
Then("An error state is displayed for the invalid group", async ({ page }) => {
const errorHeading = page.getByRole("heading", {
name: /error|not found|something went wrong/i,
});
await expect(errorHeading).toBeVisible({ timeout: 10000 });

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): Error state assertion for invalid group ID is quite generic and may produce false positives

This assertion currently matches any heading with /error|not found|something went wrong/i, which could pick up unrelated page errors and cause false positives. To make the test reliably about SBOM group errors, assert against a more specific selector or message for the SBOM groups error UI (e.g., a dedicated data-testid or fixed heading text), and optionally check that the URL stays on the invalid group route. That way the test proves the invalid group ID triggers the intended error state, not just any generic error on the page.

Suggested implementation:

 // Invalid group ID handling
When("User navigates to group details with invalid ID", async ({ page }) => {
  await page.goto("/sbom-groups/invalid-group-id-12345");
});

Then("An error state is displayed for the invalid group", async ({ page }) => {
  // Assert we stay on the invalid group route
  await expect(page).toHaveURL(/\/sbom-groups\/invalid-group-id-12345$/);

  // Assert the dedicated SBOM group error UI is shown
  const sbomGroupError = page.getByTestId("sbom-group-error");
  await expect(sbomGroupError).toBeVisible();
});

Then("The SBOM Groups table shows all groups", async ({ page }) => {
  const table = page.getByRole("treegrid", { name: "sbom-groups-table" });
  await expect(table).toBeVisible();

  const rows = table.getByRole("row");
  await expect(rows.first()).toBeVisible();
});
Then(
  1. Ensure the SBOM group error UI in the application uses data-testid="sbom-group-error" on the container element (e.g., the alert or error panel). If a different test id or fixed heading text is already used (such as "sbom-group-not-found-heading" or a specific error message string), update the selector in this step definition to match the existing UI.
  2. If the invalid-group route differs (for example, it includes a workspace/org prefix or uses a different path segment), adjust the regular expression in toHaveURL to match the actual route shape.

@@ -447,7 +445,6 @@ When(
Then(

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): SBOM count assertion doesn’t distinguish zero vs non-zero counts or missing content

The Then "The SBOM count is displayed for group {string}" step only asserts that text matching "\d+ SBOMs?" is visible, which passes for 0 SBOMs and could miss cases where the count is absent but similar text appears. If the behavior requires at least one SBOM, please assert on the parsed numeric value (e.g., > 0). Otherwise, add a dedicated scenario for 0 SBOMs so both zero and non-zero states are explicitly covered.

Suggested implementation:

Then(
  "The SBOM count is displayed for group {string}",
  async ({ page }, groupName: string) => {
    const groupRow = page.getByRole("row", { name: new RegExp(groupName, "i") });
    await expect(groupRow).toBeVisible();

    const sbomCountLocator = groupRow.getByText(/\d+\s+SBOMs?/);
    const sbomCountText = await sbomCountLocator.textContent();

    expect(sbomCountText).not.toBeNull();

    const match = sbomCountText!.match(/(\d+)\s+SBOMs?/);
    expect(match).not.toBeNull();

    const sbomCount = Number.parseInt(match![1], 10);
    expect(sbomCount).toBeGreaterThan(0);
  },
);
  1. Ensure the DOM structure for the SBOM count matches the locator assumptions (count text within the group row and formatted like "N SBOMs"). If the count is in a different element (e.g., a specific column), adjust sbomCountLocator accordingly (e.g., groupRow.getByRole("cell", { name: /\d+\s+SBOMs?/ })).
  2. If the product must support a valid 0 SBOMs state, add a dedicated scenario to your feature file (e.g., "The SBOM count shows zero SBOMs for group {string}") that asserts sbomCount === 0 instead of > 0, using the same parsing logic.

@mrrajan mrrajan marked this pull request as draft June 26, 2026 12:41
@mrrajan mrrajan force-pushed the TC-3811 branch 2 times, most recently from 0cf670a to a8cbc46 Compare July 2, 2026 15:38
mrrajan and others added 8 commits July 3, 2026 17:29
Add missing E2E test coverage for SBOM Groups feature:
- Product label badge visibility in list and detail pages
- Hierarchical tree expand/collapse behavior
- Parent group selection in create and edit flows
- Invalid group ID error handling
- SBOM count display in group list
- Breadcrumb navigation on detail page
- Edit group parent assignment and removal
- Sorting by name column

Implements TC-3811

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-by: Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: mrrajan <86094767+mrrajan@users.noreply.github.com.>
Signed-off-by: mrrajan <86094767+mrrajan@users.noreply.github.com.>
Signed-off-by: mrrajan <86094767+mrrajan@users.noreply.github.com.>
Signed-off-by: mrrajan <86094767+mrrajan@users.noreply.github.com.>
Signed-off-by: mrrajan <86094767+mrrajan@users.noreply.github.com.>
Signed-off-by: mrrajan <86094767+mrrajan@users.noreply.github.com.>
Signed-off-by: mrrajan <86094767+mrrajan@users.noreply.github.com.>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant