@@ -150,6 +150,7 @@ class ObservableApiMock {
150
150
title = "Build test case" ,
151
151
accessLevel = "private" ,
152
152
latestCreatedDeployId = null ,
153
+ source = null ,
153
154
status = 200
154
155
} : {
155
156
workspaceLogin : string ;
@@ -158,6 +159,7 @@ class ObservableApiMock {
158
159
title ?: string ;
159
160
accessLevel ?: string ;
160
161
status ?: number ;
162
+ source ?: GetProjectResponse [ "source" ] ;
161
163
latestCreatedDeployId ?: null | string ;
162
164
} ) : ObservableApiMock {
163
165
const response =
@@ -168,11 +170,11 @@ class ObservableApiMock {
168
170
slug : projectSlug ,
169
171
title,
170
172
creator : { id : "user-id" , login : "user-login" } ,
171
- owner : { id : "workspace-id" , login : "workspace-login" } ,
173
+ owner : { id : "workspace-id" , login : workspaceLogin } ,
172
174
latestCreatedDeployId,
173
175
automatic_builds_enabled : true ,
174
176
build_environment_id : "abc123" ,
175
- source : null
177
+ source
176
178
} satisfies GetProjectResponse )
177
179
: emptyErrorBody ;
178
180
const headers = authorizationHeader ( status !== 401 && status !== 403 ) ;
@@ -435,7 +437,7 @@ class ObservableApiMock {
435
437
return this ;
436
438
}
437
439
438
- handleGetRepository ( { status = 200 } : { status ?: number } = { } ) {
440
+ handleGetRepository ( { status = 200 , useProviderId = false } : { status ?: number ; useProviderId ?: boolean } = { } ) {
439
441
const response =
440
442
status === 200
441
443
? JSON . stringify ( {
@@ -448,11 +450,24 @@ class ObservableApiMock {
448
450
} )
449
451
: emptyErrorBody ;
450
452
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
- ) ;
453
+ if ( useProviderId ) {
454
+ // version that accepts provider_id
455
+ this . _handlers . push ( ( pool ) =>
456
+ pool
457
+ . intercept ( {
458
+ path : `/cli/github/repository?provider_id=${ encodeURIComponent ( "123:456" ) } ` ,
459
+ headers : headersMatcher ( headers )
460
+ } )
461
+ . reply ( status , response , { headers : { "content-type" : "application/json" } } )
462
+ ) ;
463
+ } else {
464
+ // version that accepts owner & repo
465
+ this . _handlers . push ( ( pool ) =>
466
+ pool
467
+ . intercept ( { path : "/cli/github/repository?owner=observablehq&repo=test" , headers : headersMatcher ( headers ) } )
468
+ . reply ( status , response , { headers : { "content-type" : "application/json" } } )
469
+ ) ;
470
+ }
456
471
return this ;
457
472
}
458
473
0 commit comments