fix(help-panel): guard rendering with environment feature flag#308
Conversation
Summary by CodeRabbit
WalkthroughThis PR adds feature-flag gating for the Virtual Assistant tab in HelpPanel. A new environment flag ChangesVirtual Assistant Environment Gating
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
| }) => { | ||
| const intl = useIntl(); | ||
| const isEnvironmentEnabled = useFlag( | ||
| 'platform.learning-resources.environment.enabled' |
There was a problem hiding this comment.
You have used the wromg feature flag. VA FF is platform.va.environment.enabled
| </Button> | ||
| ); | ||
|
|
||
| if (!isEnvironmentEnabled) { |
There was a problem hiding this comment.
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.
|
Thanks for the feedback @Hyperkid123! I've updated the implementation:
The VA visibility is now controlled by both Changes:
All 74 tests pass, lint clean. |
|
@platex-rehor-bot seems like your commits are not signed properly. I think there was an issue with infra. Can you fix that? |
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>
49da758 to
3c297dc
Compare
|
Fixed! All three commits have been re-signed and are now showing as verified. Thanks for flagging this. |
There was a problem hiding this comment.
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 winStabilize flag mock lifecycle to avoid cross-test leakage.
These tests mutate
mockUseFlaginline 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
📒 Files selected for processing (4)
cypress/component/HelpPanel.cy.tsxsrc/components/HelpPanel/HelpPanelContent.test.tsxsrc/components/HelpPanel/HelpPanelCustomTabs.test.tsxsrc/components/HelpPanel/HelpPanelCustomTabs.tsx
✅ Files skipped from review due to trivial changes (1)
- cypress/component/HelpPanel.cy.tsx
Summary
platform.learning-resources.environment.enabledUnleash feature flag to prevent errors in FedRAMP environmentsRHCLOUD-47391
Changes
Notes for reviewers
platform.va.environment.enabledfor VA)platform.learning-resources.environment.enabledneeds to be created in Unleash: enabled for prod/stage, disabled for FedRAMPTest plan
🤖 Generated with Claude Code