fix(coding-agent): make tests keybinding-agnostic
Reset global editor keybindings to defaults in beforeEach for session-selector-rename and tree-selector tests. Pass KeybindingsManager.inMemory() to SessionSelectorComponent in tests to avoid reading user keybindings.json. Closes #2360
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Tests for session-selector-rename and tree-selector are now keybinding-agnostic, resetting editor keybindings to defaults before each test so user `keybindings.json` cannot cause failures ([#2360](https://github.com/badlogic/pi-mono/issues/2360))
|
||||
|
||||
## [0.60.0] - 2026-03-18
|
||||
|
||||
### New Features
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { DEFAULT_EDITOR_KEYBINDINGS, EditorKeybindingsManager, setEditorKeybindings } from "@mariozechner/pi-tui";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { KeybindingsManager } from "../src/core/keybindings.js";
|
||||
import type { SessionInfo } from "../src/core/session-manager.js";
|
||||
import { SessionSelectorComponent } from "../src/modes/interactive/components/session-selector.js";
|
||||
import { initTheme } from "../src/modes/interactive/theme/theme.js";
|
||||
@@ -31,8 +33,14 @@ describe("session selector rename", () => {
|
||||
initTheme("dark");
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// Ensure test isolation: editor keybindings are a global singleton
|
||||
setEditorKeybindings(new EditorKeybindingsManager(DEFAULT_EDITOR_KEYBINDINGS));
|
||||
});
|
||||
|
||||
it("shows rename hint in interactive /resume picker configuration", async () => {
|
||||
const sessions = [makeSession({ id: "a" })];
|
||||
const keybindings = KeybindingsManager.inMemory();
|
||||
const selector = new SessionSelectorComponent(
|
||||
async () => sessions,
|
||||
async () => [],
|
||||
@@ -40,7 +48,7 @@ describe("session selector rename", () => {
|
||||
() => {},
|
||||
() => {},
|
||||
() => {},
|
||||
{ showRenameHint: true },
|
||||
{ showRenameHint: true, keybindings },
|
||||
);
|
||||
await flushPromises();
|
||||
|
||||
@@ -51,6 +59,7 @@ describe("session selector rename", () => {
|
||||
|
||||
it("does not show rename hint in --resume picker configuration", async () => {
|
||||
const sessions = [makeSession({ id: "a" })];
|
||||
const keybindings = KeybindingsManager.inMemory();
|
||||
const selector = new SessionSelectorComponent(
|
||||
async () => sessions,
|
||||
async () => [],
|
||||
@@ -58,7 +67,7 @@ describe("session selector rename", () => {
|
||||
() => {},
|
||||
() => {},
|
||||
() => {},
|
||||
{ showRenameHint: false },
|
||||
{ showRenameHint: false, keybindings },
|
||||
);
|
||||
await flushPromises();
|
||||
|
||||
@@ -71,6 +80,7 @@ describe("session selector rename", () => {
|
||||
const sessions = [makeSession({ id: "a", name: "Old" })];
|
||||
const renameSession = vi.fn(async () => {});
|
||||
|
||||
const keybindings = KeybindingsManager.inMemory();
|
||||
const selector = new SessionSelectorComponent(
|
||||
async () => sessions,
|
||||
async () => [],
|
||||
@@ -78,7 +88,7 @@ describe("session selector rename", () => {
|
||||
() => {},
|
||||
() => {},
|
||||
() => {},
|
||||
{ renameSession, showRenameHint: true },
|
||||
{ renameSession, showRenameHint: true, keybindings },
|
||||
);
|
||||
await flushPromises();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { beforeAll, describe, expect, test } from "vitest";
|
||||
import { DEFAULT_EDITOR_KEYBINDINGS, EditorKeybindingsManager, setEditorKeybindings } from "@mariozechner/pi-tui";
|
||||
import { beforeAll, beforeEach, describe, expect, test } from "vitest";
|
||||
import type {
|
||||
ModelChangeEntry,
|
||||
SessionEntry,
|
||||
@@ -12,6 +13,11 @@ beforeAll(() => {
|
||||
initTheme("dark");
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// Ensure test isolation: editor keybindings are a global singleton
|
||||
setEditorKeybindings(new EditorKeybindingsManager(DEFAULT_EDITOR_KEYBINDINGS));
|
||||
});
|
||||
|
||||
// Helper to create a user message entry
|
||||
function userMessage(id: string, parentId: string | null, content: string): SessionMessageEntry {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user