Skip to content

🐛 fix(tests): tighten ComplianceScoreBreakdownModal test scoping (#7908)#7909

Merged
clubanderson merged 1 commit intomainfrom
fix/compliance-test-7908
Apr 14, 2026
Merged

🐛 fix(tests): tighten ComplianceScoreBreakdownModal test scoping (#7908)#7909
clubanderson merged 1 commit intomainfrom
fix/compliance-test-7908

Conversation

@clubanderson
Copy link
Copy Markdown
Collaborator

Summary

Addresses the two Copilot review comments left on merged PR #7905 for web/src/components/cards/ComplianceCards.test.tsx. Both comments flagged assertions as too loose and prone to false positives as the UI evolves.

1. Scope "By tool" assertions to the per-tool section

Before:

```ts
expect(screen.getAllByText('Kubescape').length).toBeGreaterThanOrEqual(2)
expect(screen.getAllByText('Kyverno').length).toBeGreaterThanOrEqual(2)
```

After:

```ts
const byToolHeading = screen.getByText('By tool')
const byToolSection = byToolHeading.parentElement!
expect(within(byToolSection).getByText('Kubescape')).toBeInTheDocument()
expect(within(byToolSection).getByText('Kyverno')).toBeInTheDocument()
```

2. Assert Total Checks value-label pairing

Before:

```ts
expect(screen.getByText('Total Checks')).toBeInTheDocument()
expect(screen.getByText('100')).toBeInTheDocument()
```

After:

```ts
const totalChecksLabel = screen.getByText('Total Checks')
const totalChecksStatBox = totalChecksLabel.parentElement!
expect(within(totalChecksStatBox).getByText('100')).toBeInTheDocument()
```

Added within to the @testing-library/react import.

Fixes #7908

Test plan

  • npx vitest run src/components/cards/ComplianceCards.test.tsx — 12/12 pass
  • npm run build passes
  • CI green

Two Copilot review comments on merged PR #7905:

1. **Line 400** — `getAllByText('Kubescape').length >= 2` / `getAllByText('Kyverno').length >= 2`
   are too loose. Any extra rendering of those names anywhere in the modal
   would satisfy the assertion, and the check doesn't actually verify the
   per-tool bars exist. Replaced with a scoped lookup via the "By tool"
   heading: grab the section container and use `within(section).getByText(...)`
   so the assertion only accepts matches inside the per-tool list.

2. **Line 512** — `getByText('100')` is a broad assertion; any element rendering
   "100" anywhere (score %, count, label) would pass. Replaced with a
   value-label pairing check: locate the "Total Checks" label, walk up to
   its StatBox parent, and assert "100" appears inside that StatBox.

Added `within` to the @testing-library/react import.

All 12 tests in the file continue to pass locally; `npm run build` green.

Fixes #7908

Signed-off-by: Andy Anderson <andy@clubanderson.com>
Copilot AI review requested due to automatic review settings April 14, 2026 06:47
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Apr 14, 2026
@kubestellar-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 14, 2026

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit e3d96a2
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/69dde2f3b1fa48000859a640
😎 Deploy Preview https://deploy-preview-7909.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@clubanderson clubanderson added the ai-generated Pull request generated by AI label Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Tightens ComplianceScoreBreakdownModal unit test assertions in the web frontend to avoid false positives as the modal UI evolves, addressing follow-up review feedback from the previously merged test fix.

Changes:

  • Scope “Kubescape/Kyverno” assertions to the “By tool” section using within(...) instead of global getAllByText(...) length checks.
  • Assert the “Total Checks” value (“100”) within the corresponding StatBox container to ensure correct label/value pairing.
  • Add within to the @testing-library/react import to support the narrowed assertions.

@clubanderson clubanderson merged commit af9e9b5 into main Apr 14, 2026
31 of 32 checks passed
@clubanderson clubanderson deleted the fix/compliance-test-7908 branch April 14, 2026 06:52
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions
Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit af9e9b5132698720ecc0b5a6d52e81228fb2e192.

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

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Copilot Review] 2 comment(s) on merged PR #7905

2 participants