@@ -6,75 +6,86 @@ import { createTempGitRepo, cleanupTempGitRepo } from "./helpers";
66const describeIntegration = shouldRunIntegrationTests ( ) ? describe : describe . skip ;
77
88describeIntegration ( "IpcMain create workspace integration tests" , ( ) => {
9- test . concurrent ( "should fail to create workspace with invalid name" , async ( ) => {
10- const env = await createTestEnvironment ( ) ;
11- const tempGitRepo = await createTempGitRepo ( ) ;
9+ test . concurrent (
10+ "should fail to create workspace with invalid name" ,
11+ async ( ) => {
12+ const env = await createTestEnvironment ( ) ;
13+ const tempGitRepo = await createTempGitRepo ( ) ;
1214
13- try {
14- // Test various invalid names
15- const invalidNames = [
16- { name : "" , expectedError : "empty" } ,
17- { name : "My-Branch" , expectedError : "lowercase" } ,
18- { name : "branch name" , expectedError : "lowercase" } ,
19- { name : "branch@123" , expectedError : "lowercase" } ,
20- { name : "branch/test" , expectedError : "lowercase" } ,
21- { name : "branch\\test" , expectedError : "lowercase" } ,
22- { name : "branch.test" , expectedError : "lowercase" } ,
23- { name : "a" . repeat ( 65 ) , expectedError : "64 characters" } ,
24- ] ;
15+ try {
16+ // Test various invalid names
17+ const invalidNames = [
18+ { name : "" , expectedError : "empty" } ,
19+ { name : "My-Branch" , expectedError : "lowercase" } ,
20+ { name : "branch name" , expectedError : "lowercase" } ,
21+ { name : "branch@123" , expectedError : "lowercase" } ,
22+ { name : "branch/test" , expectedError : "lowercase" } ,
23+ { name : "branch\\test" , expectedError : "lowercase" } ,
24+ { name : "branch.test" , expectedError : "lowercase" } ,
25+ { name : "a" . repeat ( 65 ) , expectedError : "64 characters" } ,
26+ ] ;
2527
26- for ( const { name, expectedError } of invalidNames ) {
27- const createResult = await env . mockIpcRenderer . invoke (
28- IPC_CHANNELS . WORKSPACE_CREATE ,
29- tempGitRepo ,
30- name
31- ) ;
32- expect ( createResult . success ) . toBe ( false ) ;
33- expect ( createResult . error . toLowerCase ( ) ) . toContain ( expectedError . toLowerCase ( ) ) ;
28+ for ( const { name, expectedError } of invalidNames ) {
29+ const createResult = await env . mockIpcRenderer . invoke (
30+ IPC_CHANNELS . WORKSPACE_CREATE ,
31+ tempGitRepo ,
32+ name
33+ ) ;
34+ expect ( createResult . success ) . toBe ( false ) ;
35+ expect ( createResult . error . toLowerCase ( ) ) . toContain ( expectedError . toLowerCase ( ) ) ;
36+ }
37+ } finally {
38+ await cleanupTestEnvironment ( env ) ;
39+ await cleanupTempGitRepo ( tempGitRepo ) ;
3440 }
35- } finally {
36- await cleanupTestEnvironment ( env ) ;
37- await cleanupTempGitRepo ( tempGitRepo ) ;
38- }
39- } , 15000 ) ;
41+ } ,
42+ 15000
43+ ) ;
4044
41- test . concurrent ( "should successfully create workspace with valid name" , async ( ) => {
42- const env = await createTestEnvironment ( ) ;
43- const tempGitRepo = await createTempGitRepo ( ) ;
45+ test . concurrent (
46+ "should successfully create workspace with valid name" ,
47+ async ( ) => {
48+ const env = await createTestEnvironment ( ) ;
49+ const tempGitRepo = await createTempGitRepo ( ) ;
4450
45- try {
46- // Test various valid names (avoid "main" as it's already checked out in the repo)
47- const validNames = [
48- "feature-branch" ,
49- "feature_branch" ,
50- "branch123" ,
51- "test-branch_123" ,
52- "x" , // Single character
53- "b" . repeat ( 64 ) , // Max length
54- ] ;
51+ try {
52+ // Test various valid names (avoid "main" as it's already checked out in the repo)
53+ const validNames = [
54+ "feature-branch" ,
55+ "feature_branch" ,
56+ "branch123" ,
57+ "test-branch_123" ,
58+ "x" , // Single character
59+ "b" . repeat ( 64 ) , // Max length
60+ ] ;
5561
56- for ( const name of validNames ) {
57- const createResult = await env . mockIpcRenderer . invoke (
58- IPC_CHANNELS . WORKSPACE_CREATE ,
59- tempGitRepo ,
60- name
61- ) ;
62- if ( ! createResult . success ) {
63- console . error ( `Failed to create workspace "${ name } ":` , createResult . error ) ;
64- }
65- expect ( createResult . success ) . toBe ( true ) ;
66- expect ( createResult . metadata . id ) . toBeDefined ( ) ;
67- expect ( createResult . metadata . workspacePath ) . toBeDefined ( ) ;
68- expect ( createResult . metadata . projectName ) . toBeDefined ( ) ;
62+ for ( const name of validNames ) {
63+ const createResult = await env . mockIpcRenderer . invoke (
64+ IPC_CHANNELS . WORKSPACE_CREATE ,
65+ tempGitRepo ,
66+ name
67+ ) ;
68+ if ( ! createResult . success ) {
69+ console . error ( `Failed to create workspace "${ name } ":` , createResult . error ) ;
70+ }
71+ expect ( createResult . success ) . toBe ( true ) ;
72+ expect ( createResult . metadata . id ) . toBeDefined ( ) ;
73+ expect ( createResult . metadata . workspacePath ) . toBeDefined ( ) ;
74+ expect ( createResult . metadata . projectName ) . toBeDefined ( ) ;
6975
70- // Clean up the workspace
71- if ( createResult . metadata . id ) {
72- await env . mockIpcRenderer . invoke ( IPC_CHANNELS . WORKSPACE_REMOVE , createResult . metadata . id ) ;
76+ // Clean up the workspace
77+ if ( createResult . metadata . id ) {
78+ await env . mockIpcRenderer . invoke (
79+ IPC_CHANNELS . WORKSPACE_REMOVE ,
80+ createResult . metadata . id
81+ ) ;
82+ }
7383 }
84+ } finally {
85+ await cleanupTestEnvironment ( env ) ;
86+ await cleanupTempGitRepo ( tempGitRepo ) ;
7487 }
75- } finally {
76- await cleanupTestEnvironment ( env ) ;
77- await cleanupTempGitRepo ( tempGitRepo ) ;
78- }
79- } , 30000 ) ;
88+ } ,
89+ 30000
90+ ) ;
8091} ) ;
0 commit comments