import { createElement } from "react"; import { renderToStaticMarkup } from "react-dom/server"; import { describe, expect, it, vi } from "vitest"; import { PlatformProvider } from "@/hooks/usePlatform.js"; import { ZCodeIntlProvider } from "@/i18n/IntlProvider.js"; import { RemoteConnectionFields } from "@/RemoteConnectionFields.js"; import type { IPlatformService } from "@zcode/shared"; const platform: IPlatformService = { activateOrSetWorkspace: vi.fn(), cancelRemoteConnection: vi.fn(), connectRemote: vi.fn(), detectShell: vi.fn(), getDataBaseDir: vi.fn(), getDefaultShell: vi.fn(), getShells: vi.fn(), isDockerAvailable: vi.fn(), isWindowsDesktop: vi.fn(), listDockerContainers: vi.fn(), listSSHConfigAliases: vi.fn(), listWSLDistros: vi.fn(), log: vi.fn(), notifyRendererReady: vi.fn(), onOAuthCallback: vi.fn(), onRemoteConnectionLog: vi.fn(), openExternal: vi.fn(), registerOAuthState: vi.fn(), selectDirectory: vi.fn(), selectFile: vi.fn(), }; function renderRemoteConnectionFields(locale: "zh-CN" | "en-US") { return renderToStaticMarkup( createElement( PlatformProvider, { platform }, createElement( ZCodeIntlProvider, { initialLocale: locale }, createElement(RemoteConnectionFields, { kind: "ssh", host: "", port: "22", username: "", sshAuthMethod: "password", assetInstallMode: "local-download-upload", password: "", privateKeyPath: "", privateKeyPassphrase: "", wslDistro: "", wslDistros: [], dockerContainer: "", manualDockerContainer: "", serverUrl: "", serverName: "", serverToken: "", serverWorkspacePath: "", dockerContainers: [], dockerAvailable: null, sshConfigAliases: [], sshConfigAliasesLoading: false, sshConfigAliasesError: "", selectedSshConfigAlias: null, runtimeOptionsLoading: false, applySshConfigAlias: vi.fn(), clearSelectedSshConfigAlias: vi.fn(), setHost: vi.fn(), setPort: vi.fn(), setUsername: vi.fn(), setSshAuthMethod: vi.fn(), setAssetInstallMode: vi.fn(), setPassword: vi.fn(), setPrivateKeyPath: vi.fn(), setPrivateKeyPassphrase: vi.fn(), setWslDistro: vi.fn(), setDockerContainer: vi.fn(), setManualDockerContainer: vi.fn(), setServerUrl: vi.fn(), setServerName: vi.fn(), setServerToken: vi.fn(), setServerWorkspacePath: vi.fn(), }), ), ), ); } describe("RemoteConnectionFields authentication method layout", () => { it("keeps SSH auth method options wide enough and non-wrapping for Chinese and English labels", () => { const zhHtml = renderRemoteConnectionFields("zh-CN"); const enHtml = renderRemoteConnectionFields("en-US"); for (const html of [zhHtml, enHtml]) { expect(html).toContain("sm:grid-cols-[minmax(0,1fr)_12rem]"); expect(html).toContain("whitespace-nowrap"); } }); });