You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(frontend): add unit tests for RetentionBanner and SuspendedBanner (#115) - #116
Adds comprehensive unit test suites for the workspace banner components:
RetentionBanner (frontend/src/components/workspace/RetentionBanner.jsx) under frontend/src/components/workspace/__tests__/RetentionBanner.test.jsx.
SuspendedBanner (frontend/src/components/workspace/SuspendedBanner.jsx) under frontend/src/components/workspace/__tests__/SuspendedBanner.test.jsx.
Test Coverage Highlights
RetentionBanner:
Returns null when workspace or notice is null or undefined.
Returns null when isExpiringSoon(notice) is false (forever, not_enforced, or active with empty expiring array).
Renders singular environment heading (1 environment in <name> will be removed soon) and clock icon when exactly one environment is expiring.
Renders plural environment heading (<N> environments in <name> will be removed soon) when multiple environments are expiring.
Tests 5-item boundary condition where count equals display limit without truncation.
Formats retention summary policy and expiration warning days heading.
Formats scheduled date retention summary and scheduled expiration heading for scheduled notices.
Truncates list and appends and <N> more when expiring environments exceed the display threshold of 5.
SuspendedBanner:
Returns null when workspace is null, undefined, or is_active !== false (active workspace or omitted status).
Renders alert icon and <name> is suspended banner header when is_active === false.
Displays descriptive body message explaining that plots and members are intact and advising contacting an administrator.
Motivation and Context
Fixes#115.
Part of the console frontend test coverage initiative (#73).
How Has This Been Tested?
Ran all frontend verification tooling locally:
npx vitest run src/components/workspace/__tests__/RetentionBanner.test.jsx src/components/workspace/__tests__/SuspendedBanner.test.jsx: 14 passed (14)
npm test: All 218 unit tests passed across all 28 test files
npm run lint: ESLint checked all files with 0 errors / 0 warnings
npm run build: Vite production build passed in 537ms
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature / Tests (non-breaking change which adds tests/functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
Documentation update
Checklist:
My code follows the code style of this project.
My change requires a change to the documentation (N/A).
I have updated the documentation accordingly (N/A).
I have read the CONTRIBUTING document.
I have added tests to cover my changes.
All new and existing tests passed.
Summary by Sourcery
Add frontend unit tests covering retention and suspension workspace banners.
Tests:
Add unit test coverage for RetentionBanner visibility, retention messaging, environment list truncation, and scheduled notices.
Add unit test coverage for SuspendedBanner visibility, warning content, and suspended workspace status.
Summary by CodeRabbit
Tests
Expanded coverage for retention and suspension banners across missing, active, and scheduled states.
Added checks for retention summaries, singular and plural headings, environment lists around the display limit, and suspension details such as the workspace name and warning icon.
No actionable comments were generated in the recent review.
Walkthrough
The pull request adds unit tests for RetentionBanner and SuspendedBanner. The tests cover rendering conditions, banner text, warning icons, retention summaries, and environment-list limits.
Changes: Workspace banner tests
Layer / File(s)
Summary
Banner rendering and content frontend/src/components/workspace/__tests__/RetentionBanner.test.jsx, frontend/src/components/workspace/__tests__/SuspendedBanner.test.jsx
Tests check when each banner renders. Retention banner tests also check environment headings, retention summaries, and the five-name display limit. Suspended banner tests check the suspended message and warning icon.
This change adds unit tests for the workspace retention and suspension banners and does not alter product behavior. It has no production impact and is ready to merge.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title follows the conventional commit style and names the main change: adding unit tests for the RetentionBanner and SuspendedBanner components. The changeset contains only test files for those tw…
Linked Issues check
Issue #115 requires unit tests for RetentionBanner and SuspendedBanner. Both test files exist at head: frontend/src/components/workspace/tests/RetentionBanner.test.jsx and SuspendedBanner.test.jsx…
Out of Scope Changes check
The whole-PR diff against the merge base (bec3099) adds only two test files: RetentionBanner.test.jsx (+153) and SuspendedBanner.test.jsx (+61), per the change summary. No component implementation, c…
Full details: Title check
Explanation
The title follows the conventional commit style and names the main change: adding unit tests for the RetentionBanner and SuspendedBanner components. The changeset contains only test files for those two components, and the linked issue #115 requests exactly this coverage. The title does not describe any unrelated change.
Full details: Linked Issues check
Explanation
Issue #115 requires unit tests for RetentionBanner and SuspendedBanner. Both test files exist at head: frontend/src/components/workspace/tests/RetentionBanner.test.jsx and SuspendedBanner.test.jsx. Each requirement maps to a test:
Null rendering for null, undefined, or omitted workspace: RetentionBanner and SuspendedBanner tests cover this. The RetentionBanner component returns null when !workspace, and SuspendedBanner returns null when !workspace.
Null rendering for isExpiringSoon false, including null notice, forever, not_enforced, and empty expiring list: covered. The component guards on !isExpiringSoon(notice).
Singular heading ('1 environment in <name> will be removed soon') with clock icon: covered, including the lucide-clock class check.
Plural heading ('<N> environments in <name> ...'): covered for 2 and 5 environments.
Retention summary and expiring heading based on policy, active and scheduled: covered with exact text for active and scheduled states.
List up to 5 without truncation, and truncation above 5 with 'and N more': covered at the boundary (5) and above (8, showing 'and 3 more').
SuspendedBanner is_active === false: covered for the name header ('<name> is suspended'), the alert icon (lucide-triangle-alert), and the body text about preserved plots and members and contacting an administrator.
No coding requirement is unmet. The test assertions match the component code I read at head. I did not run the test suite. The pass counts in the PR description are author-reported and were not independently verified.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against the merge base (bec3099) adds only two test files: RetentionBanner.test.jsx (+153) and SuspendedBanner.test.jsx (+61), per the change summary. No component implementation, configuration, or unrelated files change. Every added test case targets behavior named in #115 or the current PR description. The scope is within the issue.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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!
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments### Comment 1
<locationpath="frontend/src/components/workspace/__tests__/RetentionBanner.test.jsx"line_range="38-47" />
<code_context>
+ expect(containerUndef.firstChild).toBeNull();+ });
++ it('returns null when notice state is not expiring soon (forever or not_enforced)', () => {
+ const foreverNotice = { state: 'forever', expiring: [] };+ const { container: containerForever } = render(<RetentionBanner workspace={sampleWorkspace} notice={foreverNotice} />);+ expect(containerForever.firstChild).toBeNull();++ const notEnforcedNotice = { state: 'not_enforced', expiring: [] };+ const { container: containerNotEnforced } = render(+ <RetentionBanner workspace={sampleWorkspace} notice={notEnforcedNotice} />+ );+ expect(containerNotEnforced.firstChild).toBeNull();+ });
+
</code_context>
<issue_to_address>
**Non-expiring states escape coverage**
When a `forever` or `not_enforced` notice contains expiring entries, the `returns null when notice state is not expiring soon` test still passes because both fixtures set `expiring: []`; removing the state check from `isExpiringSoon` would go undetected, and notices in those states with entries could render banners.
Give both non-expiring-state fixtures nonempty `expiring` arrays so the assertions exercise the state check.
</issue_to_address>
### Comment 2
<locationpath="frontend/src/components/workspace/__tests__/SuspendedBanner.test.jsx"line_range="47" />
<code_context>
++ render(<SuspendedBanner workspace={suspendedWorkspace} />);++ expect(screen.getByText(/Bioinformatics Lab is suspended/)).toBeInTheDocument();+ expect(+ screen.getByText(
</code_context>
<issue_to_address>
**Suspended workspaces lose warning icon**
When the warning icon is removed from the component, the heading and body-text assertions in `SuspendedBanner.test.jsx` still pass, so the suite misses the lost warning icon.
Add an assertion that the warning icon is present.
</issue_to_address>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Non-expiring states escape coverage
When a forever or not_enforced notice contains expiring entries, the returns null when notice state is not expiring soon test still passes because both fixtures set expiring: []; removing the state check from isExpiringSoon would go undetected, and notices in those states with entries could render banners.
Give both non-expiring-state fixtures nonempty expiring arrays so the assertions exercise the state check.
Prompt for AI agents
In `frontend/src/components/workspace/__tests__/RetentionBanner.test.jsx` at lines 38-47:
**Non-expiring states escape coverage**
When a `forever` or `not_enforced` notice contains expiring entries, the `returns null when notice state is not expiring soon` test still passes because both fixtures set `expiring: []`; removing the state check from `isExpiringSoon` would go undetected, and notices in those states with entries could render banners.
Give both non-expiring-state fixtures nonempty `expiring` arrays so the assertions exercise the state check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds comprehensive unit test suites for the workspace banner components:
RetentionBanner(frontend/src/components/workspace/RetentionBanner.jsx) underfrontend/src/components/workspace/__tests__/RetentionBanner.test.jsx.SuspendedBanner(frontend/src/components/workspace/SuspendedBanner.jsx) underfrontend/src/components/workspace/__tests__/SuspendedBanner.test.jsx.Test Coverage Highlights
nullwhenworkspaceornoticeis null or undefined.nullwhenisExpiringSoon(notice)is false (forever,not_enforced, or active with empty expiring array).1 environment in <name> will be removed soon) and clock icon when exactly one environment is expiring.<N> environments in <name> will be removed soon) when multiple environments are expiring.and <N> morewhen expiring environments exceed the display threshold of 5.nullwhenworkspaceis null, undefined, oris_active !== false(active workspace or omitted status).<name> is suspendedbanner header whenis_active === false.Motivation and Context
Fixes #115.
Part of the console frontend test coverage initiative (#73).
How Has This Been Tested?
Ran all frontend verification tooling locally:
npx vitest run src/components/workspace/__tests__/RetentionBanner.test.jsx src/components/workspace/__tests__/SuspendedBanner.test.jsx: 14 passed (14)npm test: All 218 unit tests passed across all 28 test filesnpm run lint: ESLint checked all files with 0 errors / 0 warningsnpm run build: Vite production build passed in 537msTypes of changes
Checklist:
Summary by Sourcery
Add frontend unit tests covering retention and suspension workspace banners.
Tests:
Summary by CodeRabbit