mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
Several causes behind servers that ended up absent or stuck: - Fallback servers now take over when the preferred one gives up (missing, not launchable, crashed for good, expired), not only when it is missing, and hand back after a manual restart. - Crash-budget uptime counts from ready, not from launch; the crash message carries why initialize failed (timeout or the server's error). - Restart works while a server is still starting and no longer holds the reconfigure lock while it waits; a server dropped during its crash backoff no longer comes back. - Progress of a still-starting server is watched. - One malformed diagnostic no longer drops the file's other problems; DocumentLink.target URIs are escaped. - Semantic tokens, inlay hints and code lens are asked again on ContentModified (staleRequestSupport). - rustup toolchain lookup uses the platform executable suffix and USERPROFILE, and probes in the project root with a timeout. - Server output lines are capped at 8 KiB. - Go to Declaration from Java to a Kotlin class declared in a differently named file finds the .kt source. - The kotlin-lsp install hint names the Language Servers settings page. Co-authored-by: rohitdanda <10144914+rohitdanda@users.noreply.github.com>
49 lines
2.6 KiB
TypeScript
49 lines
2.6 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
||
import { fireEvent, render, screen } from "@testing-library/react";
|
||
import { registerAction } from "@/platform/actions";
|
||
import { ServerStatus } from "./ServerStatus";
|
||
import { useServers, type ServerEntry } from "./servers";
|
||
|
||
const ISSUE_49 =
|
||
"jdtls needs JDK 25 or newer to run (found JDK 8, 17, 21). Download JDK 25, or pick an installed one in Settings › Languages & Frameworks › Java › Language Server › JDK (it restarts automatically); the project can still target an older Java version.";
|
||
|
||
const server = (status: ServerEntry["status"], message: string | null): ServerEntry =>
|
||
({ id: 1, name: "jdtls", status, message, languages: ["Java"], root: null }) as unknown as ServerEntry;
|
||
|
||
afterEach(() => useServers.setState({ servers: new Map() }));
|
||
|
||
describe("Language server status popup", () => {
|
||
it("offers Download JDK N when jdtls can't start for want of a JDK", () => {
|
||
const run = vi.fn();
|
||
const off = registerAction({ id: "java.downloadJdk", title: "Download JDK…", run: ({ arg }) => run(arg) });
|
||
useServers.setState({ servers: new Map([[1 as never, server("misconfigured", ISSUE_49)]]) });
|
||
render(<ServerStatus />);
|
||
fireEvent.click(screen.getByRole("button", { name: /Language servers/ }));
|
||
fireEvent.click(screen.getByRole("button", { name: "Download JDK 25" }));
|
||
expect(run).toHaveBeenCalledWith({ version: 25, languageServer: true });
|
||
off();
|
||
});
|
||
|
||
it("keeps Restart for other failures", () => {
|
||
useServers.setState({ servers: new Map([[1 as never, server("crashed", "exit code 1")]]) });
|
||
render(<ServerStatus />);
|
||
fireEvent.click(screen.getByRole("button", { name: /Language servers/ }));
|
||
expect(screen.queryByRole("button", { name: /Download JDK/ })).toBeNull();
|
||
expect(screen.getByRole("button", { name: "Restart jdtls" })).toBeInTheDocument();
|
||
});
|
||
|
||
it("checks again for a missing server installed outside the IDE", () => {
|
||
useServers.setState({ servers: new Map([[1 as never, server("missing", "brew install marksman")]]) });
|
||
render(<ServerStatus />);
|
||
fireEvent.click(screen.getByRole("button", { name: /Language servers/ }));
|
||
expect(screen.getByRole("button", { name: "Check for jdtls again" })).toBeEnabled();
|
||
});
|
||
|
||
it("restarts a server that is still starting (an import can take minutes)", () => {
|
||
useServers.setState({ servers: new Map([[1 as never, server("starting", null)]]) });
|
||
render(<ServerStatus />);
|
||
fireEvent.click(screen.getByRole("button", { name: /Language servers/ }));
|
||
expect(screen.getByRole("button", { name: "Restart jdtls" })).toBeEnabled();
|
||
});
|
||
});
|