|
| 1 | +import { describe, expect, it } from "@effect/vitest" |
| 2 | + |
| 3 | +import type { ProjectConfig } from "../../src/core/domain.js" |
| 4 | +import { defaultTemplateConfig } from "../../src/core/domain.js" |
| 5 | +import { formatConnectionInfo } from "../../src/usecases/menu-helpers.js" |
| 6 | + |
| 7 | +const makeProjectConfig = (overrides: Partial<ProjectConfig["template"]> = {}): ProjectConfig => ({ |
| 8 | + schemaVersion: 1, |
| 9 | + template: { |
| 10 | + ...defaultTemplateConfig, |
| 11 | + repoUrl: "https://github.com/org/repo.git", |
| 12 | + containerName: "dg-test", |
| 13 | + serviceName: "dg-test", |
| 14 | + sshUser: "dev", |
| 15 | + targetDir: "/home/dev/org/repo", |
| 16 | + volumeName: "dg-test-home", |
| 17 | + dockerGitPath: "/workspace/.docker-git", |
| 18 | + authorizedKeysPath: "/workspace/authorized_keys", |
| 19 | + envGlobalPath: "/workspace/.orch/env/global.env", |
| 20 | + envProjectPath: "/workspace/.orch/env/project.env", |
| 21 | + codexAuthPath: "/workspace/.orch/auth/codex", |
| 22 | + codexSharedAuthPath: "/workspace/.orch/auth/codex-shared", |
| 23 | + geminiAuthPath: "/workspace/.orch/auth/gemini", |
| 24 | + ...overrides |
| 25 | + } |
| 26 | +}) |
| 27 | + |
| 28 | +describe("formatConnectionInfo", () => { |
| 29 | + it("includes clonedOnHostname when present", () => { |
| 30 | + const config = makeProjectConfig({ clonedOnHostname: "my-laptop" }) |
| 31 | + const output = formatConnectionInfo("/project", config, "/keys", true, "ssh dev@localhost") |
| 32 | + expect(output).toContain("Cloned on device: my-laptop") |
| 33 | + }) |
| 34 | + |
| 35 | + it("omits clonedOnHostname line when undefined", () => { |
| 36 | + const config = makeProjectConfig() |
| 37 | + const output = formatConnectionInfo("/project", config, "/keys", true, "ssh dev@localhost") |
| 38 | + expect(output).not.toContain("Cloned on device") |
| 39 | + }) |
| 40 | +}) |
0 commit comments