Open History to see the last commit
1import { EnvironmentId } from "@t3tools/contracts";
2import { describe, expect, it, vi } from "vite-plus/test";
3import { page, userEvent } from "vite-plus/test/browser";
4
5import "~/index.css";
6import { render } from "../../../test/render";
7import { newEasDeviceHost } from "./easDeviceHostsSettings.logic";
8
9vi.mock(import("../../state/device"), async () => {
10 const { AsyncResult, Atom } = await import("effect/reactivity");
11 const accountAtom = Atom.make(AsyncResult.initial());
12 return {
13 deviceEasAccountCheck: (() => accountAtom) as never,
14 deviceEnvironment: { easAccount: { label: "easAccount" } } as never,
15 };
16});
17vi.mock(import("./SecretSourceInput"), () => ({
18 useSecretSources: () => [],
19 SecretSourceInput: (() => <input />) as never,
20}));
21
22import { EasDeviceHostEditor } from "./EasDeviceHostEditor";
23
24describe("EasDeviceHostEditor", () => {
25 it("leaves a cleared limit field empty and keeps Save off until a number is entered", async () => {
26 await using _screen = await render(
27 <EasDeviceHostEditor
28 environmentId={EnvironmentId.make("local")}
29 host={newEasDeviceHost("eas")}
30 isNew
31 busy={false}
32 onSave={() => {}}
33 onClose={() => {}}
34 />,
35 );
36
37 const saveButton = page.getByRole("button", { name: "Save host" });
38 await expect.element(saveButton).not.toBeDisabled();
39
40 const input = page.getByLabelText("Sessions at once");
41 await userEvent.clear(input);
42 await expect.element(input).toHaveDisplayValue("");
43 await expect.element(saveButton).toBeDisabled();
44
45 await userEvent.type(input, "5");
46 await expect.element(input).toHaveDisplayValue("5");
47 await expect.element(saveButton).not.toBeDisabled();
48 });
49});