Skip to content

test(intelligent-assistant): add saved prompts coverage for PR #4600 - #4822

Open
HusneShabbir wants to merge 5 commits into
redhat-developer:mainfrom
HusneShabbir:test/intelligent-assistant-saved-prompts-4600
Open

HusneShabbir wants to merge 5 commits into
redhat-developer:mainfrom
HusneShabbir:test/intelligent-assistant-saved-prompts-4600

Conversation

@HusneShabbir

@HusneShabbir HusneShabbir commented Sep 16, 2026

Copy link
Copy Markdown
Member

Description

Follow-up test coverage for the Saved Prompts feature merged in #4600.

Resolves:
https://redhat.atlassian.net/browse/RHIDP-15753
https://redhat.atlassian.net/browse/RHIDP-15754
https://redhat.atlassian.net/browse/RHIDP-15755

No product code changes — tests and e2e infrastructure only.

L3 component — SavedPromptCard.test.tsx

  • Card rendering (name, content preview, timestamp)
  • Optional divider between cards
  • Invalid-date fallback
  • Settings kebab menu actions wired to handlers:
    • Apply in input boxonApplyToInput(content)
    • Send directlyonSendDirectly(content)
    • DeleteonDelete(prompt)
  • Assertions use translation keys from intelligentAssistantMessages

L1 unit — useLightspeedProviderState.test.tsx

  • settingsTab / setSettingsTab exposed through provider context
  • Deep-link query param ?settingsTab=saved-prompts handling

L4a Playwright — lightspeed.saved-prompts.test.ts

Uses a dedicated page object (SavedPromptsPage) with translation-backed locators, matching other intelligent-assistant e2e specs.

Scenario What it verifies
Sidebar display Seeded prompt appears in chat history drawer (not empty placeholder)
Sidebar apply Click prompt → content in message input; drawer closes so chat is visible
Sidebar gear Hover Saved prompts section → open settings panel
Settings kebab — Apply Prompt content lands in message input
Settings kebab — Send directly Prompt sent as user message
Settings kebab — Delete Prompt removed; empty settings state shown
Settings create New prompt saved and listed

E2e mock/setup notes

  • mockSavedPrompts() route handler + in-memory seed (devMode.ts, fixtures/responses.ts)
  • page.reload() after seeding to clear React Query’s 5-minute saved-prompts cache (fixes stale “No saved prompts yet” in the sidebar)
  • History drawer scoped to nested chatbot dialog (not generic drawer panel)
  • Bootstrap uses openFullscreenChat: false for overlay mode

Test plan

  • yarn test SavedPromptCard useLightspeedProviderState --watchAll=false in workspaces/intelligent-assistant/plugins/intelligent-assistant
  • APP_MODE=legacy npx playwright test e2e-tests/lightspeed.saved-prompts.test.ts --project=en in workspaces/intelligent-assistant (7 tests, ~45s locally)

Checklist

  • A changeset describing the change and affected packages. (N/A — test-only PR)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

…-developer#4600

Add SavedPromptCard component tests, settingsTab provider state coverage,
and Playwright e2e for sidebar apply and settings create flows.

Signed-off-by: HusneShabbir <[email protected]>
Co-authored-by: Cursor <[email protected]>
@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.01%. Comparing base (7d3c5ec) to head (df2fd34).
⚠️ Report is 17 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4822   +/-   ##
=======================================
  Coverage   62.01%   62.01%           
=======================================
  Files        2680     2680           
  Lines      106534   106534           
  Branches    29834    29819   -15     
=======================================
+ Hits        66064    66068    +4     
+ Misses      39910    39906    -4     
  Partials      560      560           
Flag Coverage Δ *Carryforward flag
adoption-insights 84.77% <ø> (ø) Carriedforward from 65f1cb2
ai-integrations 79.50% <ø> (ø) Carriedforward from 65f1cb2
app-defaults 54.82% <ø> (ø) Carriedforward from 65f1cb2
augment 46.67% <ø> (ø) Carriedforward from 65f1cb2
boost 84.97% <ø> (ø) Carriedforward from 65f1cb2
bulk-import 73.12% <ø> (ø) Carriedforward from 65f1cb2
cost-management 13.53% <ø> (ø) Carriedforward from 65f1cb2
dcm 73.47% <ø> (ø) Carriedforward from 65f1cb2
e2e-adoption-insights 60.00% <ø> (ø) Carriedforward from 65f1cb2
e2e-extensions 62.31% <ø> (ø) Carriedforward from 65f1cb2
e2e-global-header 51.82% <ø> (ø) Carriedforward from 65f1cb2
e2e-homepage 61.11% <ø> (ø) Carriedforward from 65f1cb2
e2e-intelligent-assistant 46.01% <ø> (ø) Carriedforward from 65f1cb2
e2e-orchestrator 49.49% <ø> (ø) Carriedforward from 65f1cb2
e2e-orchestrator-plugin 49.48% <ø> (ø) Carriedforward from 65f1cb2
e2e-quickstart 55.21% <ø> (ø) Carriedforward from 65f1cb2
e2e-scorecard 50.05% <ø> (ø) Carriedforward from 65f1cb2
e2e-theme 16.36% <ø> (ø) Carriedforward from 65f1cb2
extensions 58.30% <ø> (ø) Carriedforward from 65f1cb2
global-floating-action-button 71.18% <ø> (ø) Carriedforward from 65f1cb2
global-header 67.76% <ø> (ø) Carriedforward from 65f1cb2
homepage 48.39% <ø> (ø) Carriedforward from 65f1cb2
install-dynamic-plugins 71.77% <ø> (ø) Carriedforward from 65f1cb2
intelligent-assistant 78.04% <ø> (+0.04%) ⬆️
konflux 91.98% <ø> (ø) Carriedforward from 65f1cb2
lightspeed 69.02% <ø> (ø) Carriedforward from 65f1cb2
mcp-integrations 84.46% <ø> (ø) Carriedforward from 65f1cb2
orchestrator 77.32% <ø> (ø) Carriedforward from 65f1cb2
quickstart 63.74% <ø> (ø) Carriedforward from 65f1cb2
sandbox 79.56% <ø> (ø) Carriedforward from 65f1cb2
scorecard 88.44% <ø> (ø) Carriedforward from 65f1cb2
theme 87.91% <ø> (ø) Carriedforward from 65f1cb2
translations 5.12% <ø> (ø) Carriedforward from 65f1cb2
x2a 53.78% <ø> (ø) Carriedforward from 65f1cb2

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d3c5ec...df2fd34. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

HusneShabbir and others added 2 commits September 16, 2026 21:10
Remove the Playwright spec that failed bootstrap locally and in CI;
keep L1/L3 unit coverage for SavedPromptCard and settingsTab state.

Signed-off-by: HusneShabbir <[email protected]>
Co-authored-by: Cursor <[email protected]>
Fix overlay bootstrap, Chatbot-scoped locators, mock seeding, and settings
Save button targeting so saved-prompt sidebar and settings flows pass locally.

Co-authored-by: Cursor <[email protected]>
@Jdubrick

Copy link
Copy Markdown
Contributor

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 16, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 5:24 PM UTC · Completed 5:46 PM UTC

Commit: d643fc1 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Low

  • [test-adequacy] workspaces/intelligent-assistant/plugins/intelligent-assistant/src/components/__tests__/SavedPromptCard.test.tsx:108 — The kebab menu test only verifies the 'Apply in input box' action. The 'Send directly' and 'Delete' actions are not exercised, leaving two of the three SavedPromptMenuItems action paths untested. Notably, onDelete receives the full SavedPrompt object while onSendDirectly receives prompt.content — this asymmetry means a refactoring error in either path would go undetected.

  • [variable-declaration-order] workspaces/intelligent-assistant/e2e-tests/lightspeed.saved-prompts.test.ts:72 — The test.beforeAll block explicitly types the boot variable (const boot: LightspeedE2eBootstrap = ...), whereas all seven existing e2e test files omit the type annotation, relying on inference.

  • [locator-function-scope] workspaces/intelligent-assistant/e2e-tests/utils/chatManagement.ts:526 — The new savedPromptSidebarItem locator scopes to page.getByLabel('Chatbot', { exact: true }) instead of sidePanelLocator(page), which is the established base container for sidebar locators in this file. This may be intentional for overlay mode compatibility — verify before changing.

);
sharedPage = boot.page;
translations = boot.translations;
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] variable-declaration-order

The test.beforeAll block explicitly types the boot variable (const boot: LightspeedE2eBootstrap), whereas all seven existing e2e test files omit the type annotation, relying on inference.

Suggested fix: Remove the explicit type annotation: const boot = await bootstrapLightspeedE2ePage(browser, { openFullscreenChat: false });


export const closeSortDropdown = async (page: Page) => {
await page.keyboard.press('Escape');
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] locator-function-scope

The new savedPromptSidebarItem locator scopes to page.getByLabel(Chatbot, { exact: true }) instead of sidePanelLocator(page), which is the established base container for sidebar locators in this file. This may be intentional for overlay mode compatibility.

Suggested fix: Verify whether sidePanelLocator works in overlay mode before switching. If it does, use it for consistency.

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Sep 16, 2026
HusneShabbir and others added 2 commits September 16, 2026 23:22
Introduce SavedPromptsPage with translation-driven locators, move fixture
data to responses.ts, and reuse loginAsGuest in overlay setup like other specs.

Co-authored-by: Cursor <[email protected]>
…coverage

Fix sidebar seeding via mock reload to bust React Query cache, add settings
kebab/gear/empty-state e2e flows, and cover Apply/Send/Delete kebab actions in unit tests.

Co-authored-by: Cursor <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

const closeSettings = this.page.getByRole('button', {
name: this.t['mcp.settings.closeAriaLabel'],
});
if (await closeSettings.isVisible().catch(() => false)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think you need the catch construct here, isVisible should just return false if the element isn't on screen

also applies to all the other occurrences of this :)

Comment on lines +199 to +215
await expect
.poll(
async () => {
const emptyVisible = await this.savedPromptsMenu()
.getByRole('menuitem', {
name: this.t['savedPrompts.sidebar.empty'],
})
.isVisible()
.catch(() => false);
const promptVisible = await this.savedPromptSidebarItem(promptName)
.isVisible()
.catch(() => false);
return !emptyVisible && promptVisible;
},
{ timeout: 15_000 },
)
.toBe(true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't it be a lot simpler to check if savedPromptSidebarItem is visible using an assertion that auto retries?
and for completeness, you can then check if the empty state is not visible the same way

created_at: string;
updated_at: string;
};
import type { SavedPromptMock } from '../fixtures/responses';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks like an import from '../fixtures/responses' already exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge All reviewers approved — ready to merge workspace/intelligent-assistant

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants