mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 14:15:24 +00:00
fix: unify connection failure screens and rebuild stale local plugins
This commit is contained in:
1 parent
a72aa5b57b
commit
49fc241e06
9 files changed
+262
-29
No files matched your search
@@ -6,7 +6,12 @@ vi.mock("react-i18next", () => ({
|
||||
}));
|
||||
|
||||
import { ConnectionScreen } from "../../../components/connection/ConnectionScreen";
|
||||
import { ConnectionLogProvider } from "../../../ssh/connection-log/ConnectionLogContext";
|
||||
import {
|
||||
ConnectionLogProvider,
|
||||
useConnectionLog,
|
||||
} from "../../../ssh/connection-log/ConnectionLogContext";
|
||||
import { SurfaceScope } from "../../../components/surface/surface-scope";
|
||||
import { useEffect } from "react";
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
@@ -107,6 +112,75 @@ describe("ConnectionScreen", () => {
|
||||
expect(screen.getByText("connection.reconnect")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("uses the same headline when retries run out", () => {
|
||||
render(<ConnectionScreen status="disconnected" message="common.loading" />);
|
||||
expect(screen.getByText("connection.failed")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("closes the tab it sits in once it stops", () => {
|
||||
const close = vi.fn();
|
||||
render(
|
||||
<SurfaceScope kind="tab" onClose={close}>
|
||||
<ConnectionScreen status="error" onManualRetry={() => {}} />
|
||||
</SurfaceScope>,
|
||||
);
|
||||
fireEvent.click(screen.getByText("connection.close"));
|
||||
expect(close).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("prefers its own close and can hide it", () => {
|
||||
const own = vi.fn();
|
||||
const { rerender } = render(
|
||||
<SurfaceScope kind="tab" onClose={() => {}}>
|
||||
<ConnectionScreen status="error" onClose={own} />
|
||||
</SurfaceScope>,
|
||||
);
|
||||
fireEvent.click(screen.getByText("connection.close"));
|
||||
expect(own).toHaveBeenCalledTimes(1);
|
||||
|
||||
rerender(
|
||||
<SurfaceScope kind="tab" onClose={() => {}}>
|
||||
<ConnectionScreen status="error" onClose={false} />
|
||||
</SurfaceScope>,
|
||||
);
|
||||
expect(screen.queryByText("connection.close")).toBeNull();
|
||||
});
|
||||
|
||||
it("shows no close while connecting or outside a tab", () => {
|
||||
render(
|
||||
<SurfaceScope kind="tab" onClose={() => {}}>
|
||||
<ConnectionScreen status="connecting" />
|
||||
</SurfaceScope>,
|
||||
);
|
||||
expect(screen.queryByText("connection.close")).toBeNull();
|
||||
cleanup();
|
||||
render(<ConnectionScreen status="error" />);
|
||||
expect(screen.queryByText("connection.close")).toBeNull();
|
||||
});
|
||||
|
||||
it("falls back to the last logged error for the reason", () => {
|
||||
function Seed() {
|
||||
const { addLog } = useConnectionLog();
|
||||
useEffect(() => {
|
||||
addLog({ type: "error", stage: "connection", message: "old" });
|
||||
addLog({ type: "info", stage: "connection", message: "trying" });
|
||||
addLog({
|
||||
type: "error",
|
||||
stage: "connection",
|
||||
message: "Docker not found",
|
||||
});
|
||||
}, [addLog]);
|
||||
return null;
|
||||
}
|
||||
render(
|
||||
<ConnectionLogProvider>
|
||||
<Seed />
|
||||
<ConnectionScreen status="error" />
|
||||
</ConnectionLogProvider>,
|
||||
);
|
||||
expect(screen.getAllByText("Docker not found").length).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
it("renders nothing once connected", () => {
|
||||
const { container } = render(<ConnectionScreen status="connected" />);
|
||||
expect(container.innerHTML).toBe("");
|
||||
|
||||
Reference in new issue
Block a user