import { afterEach, describe, expect, it, vi } from "vitest"; import { cleanup, fireEvent, render, screen } from "@testing-library/react"; import "@testing-library/jest-dom/vitest"; import { HostStatsTab } from "../../src/frontend/HostEditorStatsTab"; afterEach(cleanup); function renderSection(pluginSettings: Record = {}) { let form: Record = { quickActions: [], pluginSettings: { "host-metrics": pluginSettings, other: { keep: 1 } }, }; const updateForm = vi.fn( (patch: (current: Record) => Record) => { form = { ...form, ...patch(form) }; }, ); render( , ); return { updateForm, form: () => form }; } describe("HostStatsTab", () => { it("writes the plugin's host settings and leaves other plugins alone", () => { const { form } = renderSection({ metricsEnabled: true }); fireEvent.change( screen.getByPlaceholderText("hosts.excludedMountsPlaceholder"), { target: { value: "/snap" } }, ); fireEvent.click(screen.getByText(/hosts.addExcludedMount/)); expect(form().pluginSettings).toEqual({ "host-metrics": { metricsEnabled: true, excludedMounts: ["/snap"] }, other: { keep: 1 }, }); }); it("has no status check options, which are core's", () => { renderSection(); expect(screen.queryByText("hosts.statusChecksLabel")).toBeNull(); }); });