Skip to content

Add search tab stories#271

Open
CodyWMitchell wants to merge 2 commits intoRedHatInsights:masterfrom
CodyWMitchell:search-tab-stories
Open

Add search tab stories#271
CodyWMitchell wants to merge 2 commits intoRedHatInsights:masterfrom
CodyWMitchell:search-tab-stories

Conversation

@CodyWMitchell
Copy link
Contributor

@CodyWMitchell CodyWMitchell commented Mar 20, 2026

Add Search Tab stories

Added the following User Journeys (RHCLOUD-45245):

  • Manual testing entry point
  • Page loads successfully
  • Open the help panel
  • Navigate to the Search tab
  • Search for a term and view results
  • Search, then filter results by content type
  • Clear all applied filters
  • Clear the search input and return to the default view
  • Click a recent query to re-run a previous search
  • Clear search history (recent queries)
  • Toggle recommended content scope (All vs current bundle)
  • Toggle favoriting a service result (star / favorite-pages)
  • Toggle bookmarking a learning resource (quickstarts favorites)
  • Toggle search scope (All vs current bundle) in the results view

Added the following Component Tests (RHCLOUD-45250):

  • Default view (input + recommended content + “no recent searches” state)
  • Searching and seeing results
  • Searching with no results
  • Filtering results by content type (Documentation)
  • Clearing all filters after applying one
  • Clearing the search input to return to default view
  • Displaying recent queries and clicking one to re-run it
  • Clearing search history and showing the empty state
  • Toggling recommended content scope (All vs bundle)
  • Toggling search scope in results (All vs current bundle)

@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eaf79ca0-5a67-45aa-8863-7a2486d951e1

📥 Commits

Reviewing files that changed from the base of the PR and between ef11dcc and 261206a.

📒 Files selected for processing (2)
  • .storybook/hooks/unleash.js
  • src/user-journeys/_shared/helpPanelJourneyHelpers.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .storybook/hooks/unleash.js
  • src/user-journeys/_shared/helpPanelJourneyHelpers.ts

Summary by CodeRabbit

  • New Features

    • Help Panel now supports searching with filtering by content type, favorites management, and recent query history
  • Tests

    • Added extensive Storybook stories and end-to-end user journey tests covering search workflows, filters, and result interactions

Walkthrough

Enabled an additional Storybook feature flag and added extensive Help Panel search support: new SearchPanel stories, user-journey stories, OUIA attributes, and expanded MSW handlers to mock chrome service, quickstarts, favorites and bookmark endpoints.

Changes

Cohort / File(s) Summary
Storybook Unleash mock
​.storybook/hooks/unleash.js
Added 'platform.chrome.help-panel_search' to the Storybook enabled-flag allowlist so useFlag/useFlags report it as enabled.
Help Panel story adjustments & MSW
src/components/HelpPanel/HelpPanelContent.stories.tsx
Added MSW handlers for chrome service user/favorites, static specs/bundles, favorite-pages POST, and quickstarts favorites POST to support Search-related story scenarios.
SearchForm minor UI attribute
src/components/HelpPanel/HelpPanelTabs/SearchPanel/SearchForm.tsx
Added data-ouia-component-id="help-panel-search-filter-option-${option.value}" to each SelectOption for per-option OUIA identification.
SearchPanel Storybook stories
src/components/HelpPanel/HelpPanelTabs/SearchPanel/SearchPanel.stories.tsx
New Storybook file exporting SearchPanelWrapper and multiple interactive stories; configures MSW handlers, sets up providers, manipulates bundle data, clears help-panel-recent-queries, and includes play functions covering search, filters, recent queries, clearing history, scope toggles, and recommended-content interactions.
User-journeys for Search Panel
src/user-journeys/HelpPanelSearchPanel.stories.tsx
Added comprehensive user-journey story file with 13 step stories exercising search flow end-to-end, filter interactions (using OUIA), favorites/bookmarks toggles, and scope toggles; wires MSW handlers and manages localStorage seeding/cleanup.
Shared MSW helpers
src/user-journeys/_shared/helpPanelJourneyHelpers.ts
Appended search-related MSW handlers to helpPanelMswHandlers and added exported searchPanelJourneyMswHandlers (includes quickstarts GET with query filtering, chrome service static endpoints, user favorites, and POST toggles).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add search tab stories' directly and clearly summarizes the main change: adding Storybook stories for the search tab component.
Description check ✅ Passed The description is directly related to the changeset, providing detailed lists of User Journey and Component tests added for the Search Tab, with linked Jira tickets.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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

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

@CodyWMitchell
Copy link
Contributor Author

/retest

@CodyWMitchell CodyWMitchell marked this pull request as ready for review March 20, 2026 17:30
@CodyWMitchell
Copy link
Contributor Author

CodyWMitchell commented Mar 20, 2026

The failing e2e tests appear unrelated to these changes and also appear in an empty PR.

Copy link

@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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/components/HelpPanel/HelpPanelTabs/SearchPanel/SearchPanel.stories.tsx (1)

15-16: Consider reusing delay from testConstants.ts.

The testDelay helper duplicates the delay function already exported from src/user-journeys/_shared/testConstants.ts. Reusing the existing utility would reduce duplication.

♻️ Proposed refactor
+import { delay } from '../../user-journeys/_shared/testConstants';

-const testDelay = (ms: number): Promise<void> =>
-  new Promise((resolve) => setTimeout(resolve, ms));

Then replace testDelay calls with delay.

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

In `@src/components/HelpPanel/HelpPanelTabs/SearchPanel/SearchPanel.stories.tsx`
around lines 15 - 16, The file defines a duplicate helper testDelay; remove
testDelay and import the existing delay exported from testConstants (the symbol
name is delay) instead, then replace all testDelay(...) calls with delay(...).
Ensure you add the import for delay from
src/user-journeys/_shared/testConstants.ts at the top of the module and remove
the local testDelay declaration to avoid duplication.
src/user-journeys/_shared/helpPanelJourneyHelpers.ts (1)

324-508: Consider extracting shared mock data to reduce duplication.

The searchPanelJourneyMswHandlers duplicates mock resource data that also exists in helpPanelMswHandlers. While the MSW first-match ordering is correctly implemented, extracting common mock data into shared constants would reduce maintenance burden and ensure consistency.

💡 Suggested approach
// Extract shared mock resources
const baseLearningResources = [
  {
    content: {
      metadata: { name: 'getting-started-insights', /* ... */ },
      spec: { displayName: 'Getting started with Red Hat Insights', /* ... */ },
    },
  },
  // ... other resources
];

// Then use in handlers:
http.get('/api/quickstarts/v1/quickstarts', ({ request }) => {
  const url = new URL(request.url);
  const displayName = url.searchParams.get('display-name') || '';
  if (displayName) {
    const query = displayName.toLowerCase();
    const filtered = baseLearningResources.filter((r) =>
      r.content.spec.displayName.toLowerCase().includes(query)
    );
    return HttpResponse.json({ data: filtered });
  }
  return HttpResponse.json({ data: baseLearningResources });
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/user-journeys/_shared/helpPanelJourneyHelpers.ts` around lines 324 - 508,
The handlers in searchPanelJourneyMswHandlers duplicate the mock resource
objects already present in helpPanelMswHandlers; extract the shared mock array
into a single constant (e.g., baseLearningResources) and replace the inline
arrays in searchPanelJourneyMswHandlers and helpPanelMswHandlers with references
to that constant so both the quickstarts GET handler (inside
searchPanelJourneyMswHandlers) and the handlers in helpPanelMswHandlers reuse
the same data; ensure the filtering logic in the GET
'/api/quickstarts/v1/quickstarts' handler continues to operate on
baseLearningResources and return HttpResponse.json({ data: ... }) as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/HelpPanel/HelpPanelTabs/SearchPanel/SearchPanel.stories.tsx`:
- Around line 379-390: The ClearAllFilters story is querying for the services
filter option but the mockSearchPanelHandlers used in the story only provides
the product-families category; update the mockSearchPanelHandlers to include a
`services` filter category that matches the DOM attribute used in the test
(`data-ouia-component-id="help-panel-search-filter-option-services"`) so the
element rendered by SearchPanel.tsx appears; ensure the mock entry uses the same
id/label/checkbox structure as other categories so the waitFor and subsequent
click on the services checkbox succeed.

In `@src/user-journeys/HelpPanelSearchPanel.stories.tsx`:
- Around line 219-229: The test Step06_ClearAllFilters in
HelpPanelSearchPanel.stories.tsx fails because it queries a non-existent filter
option with data-ouia-component-id "help-panel-search-filter-option-services";
update the mock handlers in searchPanelJourneyMswHandlers (defined in
helpPanelJourneyHelpers.ts) to include a "services" filter option in the filter
endpoint response, or change the test to target an existing filter (e.g.,
"help-panel-search-filter-option-documentation") by replacing the selector and
checkbox click to that existing filter so the waitFor/query and userEvent.click
use a filter that exists in the MSW mock data.

---

Nitpick comments:
In `@src/components/HelpPanel/HelpPanelTabs/SearchPanel/SearchPanel.stories.tsx`:
- Around line 15-16: The file defines a duplicate helper testDelay; remove
testDelay and import the existing delay exported from testConstants (the symbol
name is delay) instead, then replace all testDelay(...) calls with delay(...).
Ensure you add the import for delay from
src/user-journeys/_shared/testConstants.ts at the top of the module and remove
the local testDelay declaration to avoid duplication.

In `@src/user-journeys/_shared/helpPanelJourneyHelpers.ts`:
- Around line 324-508: The handlers in searchPanelJourneyMswHandlers duplicate
the mock resource objects already present in helpPanelMswHandlers; extract the
shared mock array into a single constant (e.g., baseLearningResources) and
replace the inline arrays in searchPanelJourneyMswHandlers and
helpPanelMswHandlers with references to that constant so both the quickstarts
GET handler (inside searchPanelJourneyMswHandlers) and the handlers in
helpPanelMswHandlers reuse the same data; ensure the filtering logic in the GET
'/api/quickstarts/v1/quickstarts' handler continues to operate on
baseLearningResources and return HttpResponse.json({ data: ... }) as before.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 52302ccc-ea41-4426-949e-7d89ac236ffa

📥 Commits

Reviewing files that changed from the base of the PR and between 10e41c2 and ef11dcc.

📒 Files selected for processing (6)
  • .storybook/hooks/unleash.js
  • src/components/HelpPanel/HelpPanelContent.stories.tsx
  • src/components/HelpPanel/HelpPanelTabs/SearchPanel/SearchForm.tsx
  • src/components/HelpPanel/HelpPanelTabs/SearchPanel/SearchPanel.stories.tsx
  • src/user-journeys/HelpPanelSearchPanel.stories.tsx
  • src/user-journeys/_shared/helpPanelJourneyHelpers.ts

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.

1 participant