Skip to content

test: Add unit tests for StatusBadgeV2 component#5555

Open
Shahazadi-Shaguftha-Syed wants to merge 5 commits into
litmuschaos:masterfrom
Shahazadi-Shaguftha-Syed:test/statusbadgev2-unit-tests
Open

test: Add unit tests for StatusBadgeV2 component#5555
Shahazadi-Shaguftha-Syed wants to merge 5 commits into
litmuschaos:masterfrom
Shahazadi-Shaguftha-Syed:test/statusbadgev2-unit-tests

Conversation

@Shahazadi-Shaguftha-Syed

Copy link
Copy Markdown

Proposed changes

Adds unit test coverage for the StatusBadgeV2 component which had no tests.
Closes #5554

Types of changes

What types of changes does your code introduce to Litmus? Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Special notes for your reviewer:

The StatusBadgeV2 component had no test coverage before this PR. Tests cover the main entity type (ExperimentRun) with different status values (COMPLETED, RUNNING, ERROR) and tooltip rendering. All 4 tests pass locally.

@kunalworldwide kunalworldwide left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tests cover the basic rendering cases (completed, running, error, with tooltip), which is a good start.

A few suggestions to make the tests more meaningful:

  1. Assertions are identical across all tests — every test just checks toBeInTheDocument() on the same data-testid. This confirms the component renders without crashing but doesn't verify the output differs. Consider asserting on the actual status text or CSS class to confirm each status produces the right visual indicator. For example:

    expect(screen.getByText('Completed')).toBeInTheDocument();
  2. Missing statusesExperimentRunStatus likely has more values (STOPPED, QUEUED, TIMEOUT, NA, etc.). Adding at least one more status would improve coverage.

  3. The tooltip test doesn't verify the tooltip content is rendered. You could hover or check for an aria-label or title attribute to confirm the tooltip text actually appears.

  4. No test for the other entity typesStatusBadgeEntity might have values beyond ExperimentRun. Testing with a different entity would confirm the component handles them.

Overall the structure is right — just needs slightly stronger assertions to catch regressions beyond "it doesn't crash."

@Shahazadi-Shaguftha-Syed Shahazadi-Shaguftha-Syed force-pushed the test/statusbadgev2-unit-tests branch 2 times, most recently from 1ca953d to 54f0f7b Compare June 12, 2026 17:00
@Shahazadi-Shaguftha-Syed

Copy link
Copy Markdown
Author

@kunalworldwide Thanks for the feedback! Updated the tests with stronger assertions checking actual rendered text (COMPLETED, RUNNING, ERROR, STOPPED, QUEUED), added Infrastructure entity tests covering ACTIVE and INACTIVE statuses, and the tooltip test now verifies the badge renders correctly. All 8 tests passing locally.

nXtCyberNet and others added 3 commits June 12, 2026 22:41
Signed-off-by: nXtCyberNet <rohantech2005@gmail.com>
Co-authored-by: Pritesh Kiri <77957844+PriteshKiri@users.noreply.github.com>
Signed-off-by: Shahazadi-Shaguftha-Syed <shahazadishagufthasyed3@gmail.com>
Signed-off-by: Shahazadi-Shaguftha-Syed <shahazadishagufthasyed3@gmail.com>
Signed-off-by: Shahazadi-Shaguftha-Syed <shahazadishagufthasyed3@gmail.com>

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

Adds a new unit test suite for the StatusBadgeV2 React component in ChaosCenter Web to improve coverage around status rendering (and intended tooltip behavior).

Changes:

  • Added StatusBadgeV2.test.tsx covering multiple ExperimentRunStatus render paths.
  • Added basic render tests for ChaosInfrastructureStatus entity usage.
  • Included a test intended to cover tooltip rendering via the tooltip prop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chaoscenter/web/src/components/StatusBadgeV2/__tests__/StatusBadgeV2.test.tsx Outdated
Comment thread chaoscenter/web/src/components/StatusBadgeV2/__tests__/StatusBadgeV2.test.tsx Outdated
…frastructure statuses

Signed-off-by: Shahazadi-Shaguftha-Syed <shahazadishagufthasyed3@gmail.com>
@Shahazadi-Shaguftha-Syed Shahazadi-Shaguftha-Syed force-pushed the test/statusbadgev2-unit-tests branch from 67601be to 7e44996 Compare June 14, 2026 13:51
@Shahazadi-Shaguftha-Syed

Copy link
Copy Markdown
Author

@PriteshKiri addressed all Copilot comments & added text assertion for CONNECTED status, added INACTIVE text assertion, and improved tooltip test. All 8 tests passing locally. Would love a re-review when you get a chance!

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines +40 to +51
test('renders with tooltip prop and shows status text', () => {
render(
<StatusBadgeV2
status={ExperimentRunStatus.COMPLETED}
entity={StatusBadgeEntity.ExperimentRun}
tooltip="Test tooltip"
/>
);
expect(screen.getByTestId('status-badge-v2')).toBeInTheDocument();
expect(screen.getByText('COMPLETED')).toBeInTheDocument();
expect(screen.getByText('COMPLETED').closest('[data-testid="status-badge-v2"]')).toBeInTheDocument();
});
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: Add unit tests for StatusBadgeV2 component

4 participants