From 930ebdcde8ffffc9abb92ed647df04fd03aa74fc Mon Sep 17 00:00:00 2001 From: Bob Qiu Date: Tue, 3 Nov 2026 13:57:40 +0800 Subject: [PATCH] refactor(insomnia-test): read MCP row selection from its highlight class Revert the app-side data-active attribute and have the page object detect the selected sidebar row by the bg-(--hl-sm) class the app already applies, so the fix stays inside the test framework. Co-Authored-By: Claude Sonnet 5.5 --- packages/insomnia-test/pages/mcp-client.page.ts | 10 +++++++--- packages/insomnia/src/ui/components/mcp/mcp-pane.tsx | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/insomnia-test/pages/mcp-client.page.ts b/packages/insomnia-test/pages/mcp-client.page.ts index 0110c5818b..4ae84fdae9 100644 --- a/packages/insomnia-test/pages/mcp-client.page.ts +++ b/packages/insomnia-test/pages/mcp-client.page.ts @@ -5,6 +5,10 @@ import { expect, type Locator } from "@playwright/test"; import { RequestPage } from "./request.page"; +/** Class the app adds to the selected sidebar row (the row has no selection attribute of its own). */ +const SELECTED_ROW_CLASS_NAME = 'bg-(--hl-sm)'; +const SELECTED_ROW_CLASS = /(^|\s)bg-\(--hl-sm\)(\s|$)/; + /** The error panel embedded in a capability item's row. */ export interface McpCapabilityError { title: string; @@ -223,7 +227,7 @@ export class McpClientPage extends RequestPage { // The sidebar is virtualized and re-renders while capabilities finish loading, which can swallow a click. await expect(async () => { await rows.nth(index).click(); - await expect(rows.nth(index)).toHaveAttribute('data-active', 'true', { timeout: 2000 }); + await expect(rows.nth(index)).toHaveClass(SELECTED_ROW_CLASS, { timeout: 2000 }); }).toPass({ timeout: DEFAULT_TIMEOUT }); } @@ -232,10 +236,10 @@ export class McpClientPage extends RequestPage { } /** - * Reads, per row of one primitive kind in sidebar order, whether the row is selected, from its data-active attribute. + * Reads, per row of one primitive kind in sidebar order, whether the row is selected, from the highlight class the app adds to the selected row. */ async getPrimitiveSelection(type: McpPrimitiveType): Promise { - return this.primitiveRows(type).evaluateAll(rows => rows.map(row => (row as HTMLElement).dataset.active === 'true')); + return this.primitiveRows(type).evaluateAll((rows, selectedClass) => rows.map(row => row.classList.contains(selectedClass)), SELECTED_ROW_CLASS_NAME); } /** diff --git a/packages/insomnia/src/ui/components/mcp/mcp-pane.tsx b/packages/insomnia/src/ui/components/mcp/mcp-pane.tsx index 0ca8dacd86..be7f0dc162 100644 --- a/packages/insomnia/src/ui/components/mcp/mcp-pane.tsx +++ b/packages/insomnia/src/ui/components/mcp/mcp-pane.tsx @@ -593,7 +593,7 @@ const CollectionGridListItem = (props: { )} textValue={label} data-testid={`test-${uniqueId}`} - data-active={isSelected} + data-selected={isSelected} style={style} >