mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-08-30 02:41:34 +00:00
feat: add host context menu actions (#1315)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
||||
import { useState } from "react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { Host } from "@/types/ui-types";
|
||||
import { LOCAL_ADAPTIVE_PREFERENCES_KEY } from "@/lib/local-adaptive-preferences";
|
||||
@@ -106,10 +107,41 @@ describe("HostItem density parity", () => {
|
||||
"exposes the Copy Link submenu trigger in %s density",
|
||||
(density) => {
|
||||
renderHostItem(density, { menuOpen: true });
|
||||
expect(screen.getByText("common.connect")).toBeTruthy();
|
||||
expect(screen.getByText("hosts.copyLink")).toBeTruthy();
|
||||
},
|
||||
);
|
||||
|
||||
it("opens the complete host menu on right click", () => {
|
||||
function Harness() {
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
return (
|
||||
<HostItem
|
||||
host={baseHost}
|
||||
onOpenTab={noop}
|
||||
onEditHost={noop}
|
||||
onShareHost={noop}
|
||||
onDelete={noop}
|
||||
onDuplicate={noop}
|
||||
isMenuOpen={menuOpen}
|
||||
onMenuOpenChange={setMenuOpen}
|
||||
/>
|
||||
);
|
||||
}
|
||||
render(<Harness />);
|
||||
|
||||
const hostRow = screen.getByText("web-01").closest(".cursor-pointer");
|
||||
expect(hostRow).toBeTruthy();
|
||||
fireEvent.contextMenu(hostRow!, { clientX: 120, clientY: 80 });
|
||||
|
||||
expect(screen.getByText("common.connect")).toBeTruthy();
|
||||
expect(screen.getAllByText("hosts.editHostAction").length).toBeGreaterThan(
|
||||
0,
|
||||
);
|
||||
expect(screen.getAllByText("hosts.shareHost").length).toBeGreaterThan(0);
|
||||
expect(screen.getByText("hosts.wakeOnLanAction")).toBeTruthy();
|
||||
});
|
||||
|
||||
it.each(["comfortable", "compact"] as const)(
|
||||
"exposes edit, share, and more-options actions in %s density",
|
||||
(density) => {
|
||||
|
||||
Reference in New Issue
Block a user