mirror of
https://github.com/Kong/insomnia.git
synced 2026-11-04 20:13:48 -05:00
fix(insomnia-test): expose MCP row selection through a data-active attribute
React Aria overwrites data-selected on GridListItem, so it never reflects the app's own selection. Add data-active next to it, leaving data-selected as is, and read that in the MCP page object. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
930ebdcde8
commit
ffcbffa1e6
2 files changed
+4
-7
No files matched your search
@@ -5,10 +5,6 @@ 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;
|
||||
@@ -227,7 +223,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)).toHaveClass(SELECTED_ROW_CLASS, { timeout: 2000 });
|
||||
await expect(rows.nth(index)).toHaveAttribute('data-active', 'true', { timeout: 2000 });
|
||||
}).toPass({ timeout: DEFAULT_TIMEOUT });
|
||||
}
|
||||
|
||||
@@ -236,10 +232,10 @@ export class McpClientPage extends RequestPage {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Reads, per row of one primitive kind in sidebar order, whether the row is selected, from its data-active attribute (React Aria overwrites data-selected on these rows).
|
||||
*/
|
||||
async getPrimitiveSelection(type: McpPrimitiveType): Promise<boolean[]> {
|
||||
return this.primitiveRows(type).evaluateAll((rows, selectedClass) => rows.map(row => row.classList.contains(selectedClass)), SELECTED_ROW_CLASS_NAME);
|
||||
return this.primitiveRows(type).evaluateAll(rows => rows.map(row => (row as HTMLElement).dataset.active === 'true'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -594,6 +594,7 @@ const CollectionGridListItem = (props: {
|
||||
textValue={label}
|
||||
data-testid={`test-${uniqueId}`}
|
||||
data-selected={isSelected}
|
||||
data-active={isSelected}
|
||||
style={style}
|
||||
>
|
||||
<div className="flex h-full w-full flex-col overflow-hidden">
|
||||
|
||||
Reference in new issue
Block a user