дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
VM options and the other multi-line run configuration fields get an Expand button (Shift+Enter) opening a resizable editor where each line stays on one visual line and scrolls sideways, so a long JVM argument isn't wrapped into what looks like several. OK applies; Cancel or OK without edits leaves the field unchanged.
38 рядки
1.7 KiB
TypeScript
38 рядки
1.7 KiB
TypeScript
import { afterEach, expect, it, vi } from "vitest";
|
|
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
import { ExpandableTextarea } from "./ExpandableTextarea";
|
|
|
|
afterEach(cleanup);
|
|
|
|
const LONG = "-Ddemo.endpoint=https://example.com/demo/environments/local/feature-flags/configuration/versions/current";
|
|
const VALUE = `-Xmx512m\n${LONG}\n-Ddemo.mode=local`;
|
|
|
|
function editors() {
|
|
return screen.getAllByRole("textbox", { name: "VM options" }) as HTMLTextAreaElement[];
|
|
}
|
|
|
|
it("edits in an expanded editor that keeps each line on one visual line", () => {
|
|
const onChange = vi.fn();
|
|
render(<ExpandableTextarea label="VM options" value={VALUE} onChange={onChange} />);
|
|
fireEvent.click(screen.getByRole("button", { name: "Expand (⇧⏎)" }));
|
|
const expanded = editors()[1]!;
|
|
expect(expanded.value).toBe(VALUE);
|
|
expect(expanded.getAttribute("wrap")).toBe("off");
|
|
fireEvent.change(expanded, { target: { value: `${VALUE}\n-Dextra=1` } });
|
|
fireEvent.click(screen.getByRole("button", { name: "OK" }));
|
|
expect(onChange).toHaveBeenCalledWith(`${VALUE}\n-Dextra=1`);
|
|
expect(editors()).toHaveLength(1);
|
|
});
|
|
|
|
it("leaves the value alone on Cancel or OK without edits, and opens with Shift+Enter", () => {
|
|
const onChange = vi.fn();
|
|
render(<ExpandableTextarea label="VM options" value={VALUE} onChange={onChange} />);
|
|
fireEvent.keyDown(editors()[0]!, { key: "Enter", shiftKey: true });
|
|
fireEvent.change(editors()[1]!, { target: { value: "-Xmx1g" } });
|
|
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
|
|
expect(editors()).toHaveLength(1);
|
|
fireEvent.click(screen.getByRole("button", { name: "Expand (⇧⏎)" }));
|
|
fireEvent.click(screen.getByRole("button", { name: "OK" }));
|
|
expect(onChange).not.toHaveBeenCalled();
|
|
});
|