Skip to content

fix(help-panel): guard rendering with environment feature flag#308

Merged
Hyperkid123 merged 3 commits intoRedHatInsights:masterfrom
platex-rehor-bot:bot/RHCLOUD-47391
May 4, 2026
Merged

fix(help-panel): guard rendering with environment feature flag#308
Hyperkid123 merged 3 commits intoRedHatInsights:masterfrom
platex-rehor-bot:bot/RHCLOUD-47391

Conversation

@platex-rehor-bot
Copy link
Copy Markdown
Contributor

Summary

  • Guards help panel content behind platform.learning-resources.environment.enabled Unleash feature flag to prevent errors in FedRAMP environments
  • When flag is disabled, renders minimal fallback with close button and status page link
  • Adds 7 new unit tests covering both flag states

RHCLOUD-47391

Changes

  • HelpPanelContent.tsx: Added environment flag check. Disabled = minimal drawer fallback. Enabled = full HelpPanelCustomTabs.
  • Messages.ts: Added helpPanelNotAvailable i18n message.
  • HelpPanelContent.test.tsx: 7 tests for flag-gated rendering.

Notes for reviewers

  • Same pattern as RHCLOUD-47334 (platform.va.environment.enabled for VA)
  • Flag platform.learning-resources.environment.enabled needs to be created in Unleash: enabled for prod/stage, disabled for FedRAMP
  • Flag defaults to false = safe fallback behavior
  • All 77 tests pass, lint clean

Test plan

  • Help panel renders normally when flag is true
  • Help panel shows fallback when flag is false
  • Close button works in both states
  • Create Unleash flag: enabled prod/stage, disabled FedRAMP

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Summary by CodeRabbit

  • Tests

    • Added comprehensive test coverage for the help panel component, including rendering, user interactions, and button functionality.
    • Expanded test coverage for the Virtual Assistant tab to verify visibility based on multiple feature flag configurations.
  • Improvements

    • Virtual Assistant feature tab now requires an additional environment configuration flag in addition to the existing feature flag to be displayed.

Walkthrough

This PR adds feature-flag gating for the Virtual Assistant tab in HelpPanel. A new environment flag platform.va.environment.enabled is introduced and combined with the existing chatbot flag to control VA visibility. The component logic is updated, existing tests are expanded, and new unit tests are added.

Changes

Virtual Assistant Environment Gating

Layer / File(s) Summary
Feature Flag Configuration
cypress/component/HelpPanel.cy.tsx
Cypress bootstrap adds platform.va.environment.enabled flag with enabled: true and a disabled variant for testing.
Core Component Logic
src/components/HelpPanel/HelpPanelCustomTabs.tsx
showVA now requires both platform.chrome.help-panel_chatbot AND platform.va.environment.enabled to be enabled; baseTabs recomputed based on combined showVA value.
Component Tests
src/components/HelpPanel/HelpPanelCustomTabs.test.tsx
Test renamed for clarity; new test case added to verify VA tab is hidden when platform.va.environment.enabled is disabled despite chatbot flag being enabled.
New Component Tests
src/components/HelpPanel/HelpPanelContent.test.tsx
New test suite mocking feature flags and tabs, verifying custom tabs render, status page link is present with correct href, and close button triggers handler on click.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately summarizes the main change—guarding help panel rendering with an environment feature flag, matching the updated implementation scope.
Description check ✅ Passed Description covers the key changes, references the Jira ticket, includes notes for reviewers, and provides a test plan, but the checklist items are incomplete/unchecked.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

}) => {
const intl = useIntl();
const isEnvironmentEnabled = useFlag(
'platform.learning-resources.environment.enabled'
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.

You have used the wromg feature flag. VA FF is platform.va.environment.enabled

</Button>
);

if (!isEnvironmentEnabled) {
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.

We do not want to gate the entire help panel. Only the section that actually renders VA. If VA is not available, the rest of the help panel should still work. Only the VA feature should be gated in this task.

@platex-rehor-bot
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @Hyperkid123! I've updated the implementation:

  1. Correct feature flag — now using platform.va.environment.enabled instead of platform.learning-resources.environment.enabled
  2. Scoped gating — only the Virtual Assistant tab is gated, not the entire help panel. When the VA environment flag is disabled (e.g. FedRAMP), the rest of the help panel (Find help, Learn, APIs, Support, KB, Feedback) continues to work normally.

The VA visibility is now controlled by both platform.chrome.help-panel_chatbot AND platform.va.environment.enabled — both must be true for the VA tab to appear.

Changes:

  • HelpPanelContent.tsx — removed entire-panel gating; always renders full help panel
  • HelpPanelCustomTabs.tsx — added platform.va.environment.enabled check combined with existing chatbot flag
  • Messages.ts — removed unused helpPanelNotAvailable message
  • Tests updated to cover VA environment flag gating

All 74 tests pass, lint clean.

@Hyperkid123
Copy link
Copy Markdown
Contributor

@platex-rehor-bot seems like your commits are not signed properly. I think there was an issue with infra. Can you fix that?

platex-rehor-bot and others added 3 commits May 4, 2026 12:39
RHCLOUD-47391
Gate help panel content behind platform.learning-resources.environment.enabled
Unleash flag. When disabled (FedRAMP), renders minimal fallback with status
page link instead of full tabbed interface. Prevents errors in environments
where learning resources backend services are unavailable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
RHCLOUD-47391
Use platform.va.environment.enabled to control VA tab visibility
instead of gating the entire help panel. The rest of the help panel
(Learn, APIs, Support, KB, Feedback) remains available in all
environments including FedRAMP.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
RHCLOUD-47391
Add missing platform.va.environment.enabled flag to defaultFlags
in HelpPanel Cypress tests. Without it, the VA tab was not rendered
(showVA = chatbot && vaEnv, vaEnv was false), causing 10 test
failures from wrong tab counts and missing VA tab element.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@platex-rehor-bot
Copy link
Copy Markdown
Contributor Author

Fixed! All three commits have been re-signed and are now showing as verified. Thanks for flagging this.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/HelpPanel/HelpPanelCustomTabs.test.tsx (1)

151-192: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Stabilize flag mock lifecycle to avoid cross-test leakage.

These tests mutate mockUseFlag inline and restore it manually. If a test fails early, the restore won’t run and later tests may inherit the wrong implementation.

Suggested refactor
+const defaultUseFlagImpl = (flagName: string) => {
+  if (flagName === 'platform.chrome.help-panel_chatbot') return true;
+  if (flagName === 'platform.va.environment.enabled') return true;
+  return true;
+};
+
-const mockUseFlag = jest.fn((flagName: string) => {
-  if (flagName === 'platform.chrome.help-panel_chatbot') return true;
-  return true;
-});
+const mockUseFlag = jest.fn(defaultUseFlagImpl);
+
+beforeEach(() => {
+  mockUseFlag.mockImplementation(defaultUseFlagImpl);
+});

Then remove per-test manual restore blocks.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/HelpPanel/HelpPanelCustomTabs.test.tsx` around lines 151 -
192, These tests mutate mockUseFlag inline and attempt to restore it per-test,
which can leak if a test fails; instead add a stable mock lifecycle: in the test
file define a beforeEach that sets mockUseFlag.mockImplementation((flagName:
string) => true) (or a baseline that returns the expected defaults for
'platform.chrome.help-panel_chatbot' and 'platform.va.environment.enabled'), and
add an afterEach that calls mockUseFlag.mockReset() or mockUseFlag.mockRestore()
to clear per-test implementations; then remove the manual per-test restore
blocks in the 'hides Virtual Assistant tab when chatbot feature flag is
disabled' and 'hides Virtual Assistant tab when VA environment flag is disabled'
tests and keep only the test-specific mockUseFlag.mockImplementation overrides.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/components/HelpPanel/HelpPanelCustomTabs.test.tsx`:
- Around line 151-192: These tests mutate mockUseFlag inline and attempt to
restore it per-test, which can leak if a test fails; instead add a stable mock
lifecycle: in the test file define a beforeEach that sets
mockUseFlag.mockImplementation((flagName: string) => true) (or a baseline that
returns the expected defaults for 'platform.chrome.help-panel_chatbot' and
'platform.va.environment.enabled'), and add an afterEach that calls
mockUseFlag.mockReset() or mockUseFlag.mockRestore() to clear per-test
implementations; then remove the manual per-test restore blocks in the 'hides
Virtual Assistant tab when chatbot feature flag is disabled' and 'hides Virtual
Assistant tab when VA environment flag is disabled' tests and keep only the
test-specific mockUseFlag.mockImplementation overrides.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 6a194eb0-155f-495d-9d30-63c253ad3760

📥 Commits

Reviewing files that changed from the base of the PR and between 51df1be and 3c297dc.

📒 Files selected for processing (4)
  • cypress/component/HelpPanel.cy.tsx
  • src/components/HelpPanel/HelpPanelContent.test.tsx
  • src/components/HelpPanel/HelpPanelCustomTabs.test.tsx
  • src/components/HelpPanel/HelpPanelCustomTabs.tsx
✅ Files skipped from review due to trivial changes (1)
  • cypress/component/HelpPanel.cy.tsx

@Hyperkid123 Hyperkid123 merged commit ef34e36 into RedHatInsights:master May 4, 2026
9 checks passed
@platex-rehor-bot platex-rehor-bot deleted the bot/RHCLOUD-47391 branch May 4, 2026 13:23
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.

3 participants