mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 07:05:24 +00:00
feat: shared list kit, settings search, rail order and ui consistency fixes
This commit is contained in:
1 parent
3ed5775ed5
commit
58c3434e58
68 files changed
+2078
-512
No files matched your search
@@ -0,0 +1,86 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
cleanup,
|
||||
fireEvent,
|
||||
render,
|
||||
screen,
|
||||
waitFor,
|
||||
} from "@testing-library/react";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
|
||||
import { EditorPane, EditorSection, LazySection } from "@/manage/EditorPane";
|
||||
import { Field } from "@/components/form-fields";
|
||||
import { HIDDEN_ATTR } from "@/settings/page-filter";
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
function renderEditor() {
|
||||
return render(
|
||||
<EditorPane
|
||||
bands={[
|
||||
{
|
||||
id: "main",
|
||||
label: "Main",
|
||||
items: [
|
||||
{ id: "general", label: "General" },
|
||||
{ id: "terminal", label: "Terminal" },
|
||||
],
|
||||
},
|
||||
]}
|
||||
>
|
||||
<EditorSection id="general" label="General">
|
||||
<Field label="Address">
|
||||
<input />
|
||||
</Field>
|
||||
<Field label="Port">
|
||||
<input />
|
||||
</Field>
|
||||
</EditorSection>
|
||||
<EditorSection id="terminal" label="Terminal">
|
||||
<LazySection>
|
||||
<Field label="Font size">
|
||||
<input />
|
||||
</Field>
|
||||
</LazySection>
|
||||
</EditorSection>
|
||||
</EditorPane>,
|
||||
);
|
||||
}
|
||||
|
||||
const hidden = (el: Element | null) => !!el?.closest(`[${HIDDEN_ATTR}]`);
|
||||
|
||||
describe("EditorPane search", () => {
|
||||
it("filters sections and fields, and hides their nav entries", async () => {
|
||||
renderEditor();
|
||||
fireEvent.change(screen.getByLabelText("manage.searchSettings"), {
|
||||
target: { value: "port" },
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(hidden(screen.getByText("Port"))).toBe(false);
|
||||
expect(hidden(screen.getByText("Address"))).toBe(true);
|
||||
expect(hidden(document.querySelector('[data-section="terminal"]'))).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
await waitFor(() =>
|
||||
expect(screen.queryByRole("button", { name: "Terminal" })).toBeNull(),
|
||||
);
|
||||
});
|
||||
|
||||
it("mounts lazy sections so their fields can be found", async () => {
|
||||
renderEditor();
|
||||
fireEvent.change(screen.getByLabelText("manage.searchSettings"), {
|
||||
target: { value: "font" },
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(hidden(screen.getByText("Font size"))).toBe(false);
|
||||
expect(hidden(document.querySelector('[data-section="general"]'))).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user