@@ -149,6 +149,7 @@ class ObservableApiMock {
149
149
projectId = "project123" ,
150
150
title = "Build test case" ,
151
151
accessLevel = "private" ,
152
+ latestCreatedDeployId = null ,
152
153
status = 200
153
154
} : {
154
155
workspaceLogin : string ;
@@ -157,6 +158,7 @@ class ObservableApiMock {
157
158
title ?: string ;
158
159
accessLevel ?: string ;
159
160
status ?: number ;
161
+ latestCreatedDeployId ?: null | string ;
160
162
} ) : ObservableApiMock {
161
163
const response =
162
164
status === 200
@@ -167,8 +169,8 @@ class ObservableApiMock {
167
169
title,
168
170
creator : { id : "user-id" , login : "user-login" } ,
169
171
owner : { id : "workspace-id" , login : "workspace-login" } ,
170
- latestCreatedDeployId : null ,
171
- automatic_builds_enabled : null ,
172
+ latestCreatedDeployId,
173
+ automatic_builds_enabled : true ,
172
174
build_environment_id : "abc123" ,
173
175
source : null
174
176
} satisfies GetProjectResponse )
@@ -432,6 +434,66 @@ class ObservableApiMock {
432
434
) ;
433
435
return this ;
434
436
}
437
+
438
+ handleGetRepository ( { status = 200 } : { status ?: number } = { } ) {
439
+ const response =
440
+ status === 200
441
+ ? JSON . stringify ( {
442
+ provider : "github" ,
443
+ provider_id : "123:456" ,
444
+ url : "https://github.com/observablehq/test.git" ,
445
+ default_branch : "main" ,
446
+ name : "test" ,
447
+ linked_projects : [ ]
448
+ } )
449
+ : emptyErrorBody ;
450
+ const headers = authorizationHeader ( status !== 401 ) ;
451
+ this . _handlers . push ( ( pool ) =>
452
+ pool
453
+ . intercept ( { path : "/cli/github/repository?owner=observablehq&repo=test" , headers : headersMatcher ( headers ) } )
454
+ . reply ( status , response , { headers : { "content-type" : "application/json" } } )
455
+ ) ;
456
+ return this ;
457
+ }
458
+
459
+ handlePostProjectEnvironment ( { status = 200 } : { status ?: number } = { } ) {
460
+ const response =
461
+ status === 200
462
+ ? JSON . stringify ( {
463
+ automatic_builds_enabled : true ,
464
+ build_environment_id : "abc123" ,
465
+ source : {
466
+ provider : "github" ,
467
+ provider_id : "123:456" ,
468
+ url : "https://github.com/observablehq/test.git" ,
469
+ branch : "main"
470
+ }
471
+ } )
472
+ : emptyErrorBody ;
473
+ const headers = authorizationHeader ( status !== 401 ) ;
474
+ this . _handlers . push ( ( pool ) =>
475
+ pool
476
+ . intercept ( { path : "/cli/project/project123/environment" , method : "POST" , headers : headersMatcher ( headers ) } )
477
+ . reply ( status , response , { headers : { "content-type" : "application/json" } } )
478
+ ) ;
479
+ return this ;
480
+ }
481
+
482
+ handlePostProjectBuild ( { status = 200 } : { status ?: number } = { } ) {
483
+ const response =
484
+ status === 200
485
+ ? JSON . stringify ( {
486
+ id : "abc123"
487
+ } )
488
+ : emptyErrorBody ;
489
+ const headers = authorizationHeader ( status !== 401 ) ;
490
+ this . _handlers . push ( ( pool ) =>
491
+ pool
492
+ . intercept ( { path : "/cli/project/project123/build" , method : "POST" , headers : headersMatcher ( headers ) } )
493
+ . reply ( status , response , { headers : { "content-type" : "application/json" } } )
494
+ ) ;
495
+ return this ;
496
+ }
435
497
}
436
498
437
499
function authorizationHeader ( valid : boolean ) {
0 commit comments