Skip to content

Commit 4da5eb9

Browse files
committed
🤖 Update createWorkspace integration tests for new tilde resolution logic
- Change tests from expecting tilde rejection to expecting tilde resolution - Update "rejects tilde paths" → "resolves tilde paths to absolute paths" - Update "rejects bare tilde" → "resolves bare tilde to home directory" - Verify that resolved paths are stored in config (not tilde paths) - Remove skip logic for missing SSH server - SSH server is now required - Change skip checks to throw errors if SSH server unavailable - Fix type errors: use workspace.name instead of workspace.branch Tests now verify that: 1. Tildes are accepted in srcBaseDir for both local and SSH runtimes 2. Tildes are resolved to absolute paths via runtime.resolvePath() 3. Resolved paths are stored in config (ensuring consistency) 4. SSH server must be available for SSH tests (no silent skips) Generated with `cmux`
1 parent dd9f92f commit 4da5eb9

File tree

1 file changed

+49
-25
lines changed

1 file changed

+49
-25
lines changed

‎tests/ipcMain/createWorkspace.test.ts‎

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -590,22 +590,20 @@ exit 1
590590
);
591591

592592
test.concurrent(
593-
"rejects tilde paths in srcBaseDir (SSH only)",
593+
"resolves tilde paths in srcBaseDir to absolute paths (SSH only)",
594594
async () => {
595-
// Skip if SSH server not available
596595
if (!sshConfig) {
597-
console.log("Skipping SSH-specific test: SSH server not available");
598-
return;
596+
throw new Error("SSH server is required for SSH integration tests");
599597
}
600598

601599
const env = await createTestEnvironment();
602600
const tempGitRepo = await createTempGitRepo();
603601

604602
try {
605-
const branchName = generateBranchName("tilde-rejection-test");
603+
const branchName = generateBranchName("tilde-resolution-test");
606604
const trunkBranch = await detectDefaultTrunkBranch(tempGitRepo);
607605

608-
// Try to use tilde path - should be rejected
606+
// Use tilde path - should be accepted and resolved
609607
const tildeRuntimeConfig: RuntimeConfig = {
610608
type: "ssh",
611609
host: `testuser@localhost`,
@@ -614,17 +612,32 @@ exit 1
614612
port: sshConfig.port,
615613
};
616614

617-
const result = await env.mockIpcRenderer.invoke(
618-
IPC_CHANNELS.WORKSPACE_CREATE,
615+
const { result, cleanup } = await createWorkspaceWithCleanup(
616+
env,
619617
tempGitRepo,
620618
branchName,
621619
trunkBranch,
622620
tildeRuntimeConfig
623621
);
624622

625-
// Should fail with error about tilde
626-
expect(result.success).toBe(false);
627-
expect(result.error).toMatch(/cannot start with tilde/i);
623+
// Should succeed and resolve tilde to absolute path
624+
expect(result.success).toBe(true);
625+
if (!result.success) {
626+
throw new Error(`Failed to create workspace: ${result.error}`);
627+
}
628+
629+
// Verify the stored runtimeConfig has resolved path (not tilde)
630+
const projectsConfig = env.config.loadConfigOrDefault();
631+
const projectWorkspaces =
632+
projectsConfig.projects.get(tempGitRepo)?.workspaces ?? [];
633+
const workspace = projectWorkspaces.find((w) => w.name === branchName);
634+
635+
expect(workspace).toBeDefined();
636+
expect(workspace?.runtimeConfig?.srcBaseDir).toBeDefined();
637+
expect(workspace?.runtimeConfig?.srcBaseDir).toMatch(/^\/home\//);
638+
expect(workspace?.runtimeConfig?.srcBaseDir).not.toContain("~");
639+
640+
await cleanup();
628641
} finally {
629642
await cleanupTestEnvironment(env);
630643
await cleanupTempGitRepo(tempGitRepo);
@@ -634,22 +647,20 @@ exit 1
634647
);
635648

636649
test.concurrent(
637-
"rejects bare tilde in srcBaseDir (SSH only)",
650+
"resolves bare tilde in srcBaseDir to home directory (SSH only)",
638651
async () => {
639-
// Skip if SSH server not available
640652
if (!sshConfig) {
641-
console.log("Skipping SSH-specific test: SSH server not available");
642-
return;
653+
throw new Error("SSH server is required for SSH integration tests");
643654
}
644655

645656
const env = await createTestEnvironment();
646657
const tempGitRepo = await createTempGitRepo();
647658

648659
try {
649-
const branchName = generateBranchName("bare-tilde-rejection");
660+
const branchName = generateBranchName("bare-tilde-resolution");
650661
const trunkBranch = await detectDefaultTrunkBranch(tempGitRepo);
651662

652-
// Try to use bare tilde - should be rejected
663+
// Use bare tilde - should be accepted and resolved to home directory
653664
const tildeRuntimeConfig: RuntimeConfig = {
654665
type: "ssh",
655666
host: `testuser@localhost`,
@@ -658,17 +669,32 @@ exit 1
658669
port: sshConfig.port,
659670
};
660671

661-
const result = await env.mockIpcRenderer.invoke(
662-
IPC_CHANNELS.WORKSPACE_CREATE,
672+
const { result, cleanup } = await createWorkspaceWithCleanup(
673+
env,
663674
tempGitRepo,
664675
branchName,
665676
trunkBranch,
666677
tildeRuntimeConfig
667678
);
668679

669-
// Should fail with error about tilde
670-
expect(result.success).toBe(false);
671-
expect(result.error).toMatch(/cannot start with tilde/i);
680+
// Should succeed and resolve tilde to home directory
681+
expect(result.success).toBe(true);
682+
if (!result.success) {
683+
throw new Error(`Failed to create workspace: ${result.error}`);
684+
}
685+
686+
// Verify the stored runtimeConfig has resolved path (not tilde)
687+
const projectsConfig = env.config.loadConfigOrDefault();
688+
const projectWorkspaces =
689+
projectsConfig.projects.get(tempGitRepo)?.workspaces ?? [];
690+
const workspace = projectWorkspaces.find((w) => w.name === branchName);
691+
692+
expect(workspace).toBeDefined();
693+
expect(workspace?.runtimeConfig?.srcBaseDir).toBeDefined();
694+
expect(workspace?.runtimeConfig?.srcBaseDir).toMatch(/^\/home\//);
695+
expect(workspace?.runtimeConfig?.srcBaseDir).not.toContain("~");
696+
697+
await cleanup();
672698
} finally {
673699
await cleanupTestEnvironment(env);
674700
await cleanupTempGitRepo(tempGitRepo);
@@ -783,10 +809,8 @@ exit 1
783809
test.concurrent(
784810
"forwards origin remote instead of bundle path",
785811
async () => {
786-
// Skip if SSH server not available
787812
if (!sshConfig) {
788-
console.log("Skipping SSH-specific test: SSH server not available");
789-
return;
813+
throw new Error("SSH server is required for SSH integration tests");
790814
}
791815

792816
const env = await createTestEnvironment();

0 commit comments

Comments
 (0)