@@ -14,7 +14,7 @@ import type {ObservableApiClientOptions, PostDeployUploadedRequest} from "../src
14
14
import type { GetCurrentUserResponse } from "../src/observableApiClient.js" ;
15
15
import { ObservableApiClient } from "../src/observableApiClient.js" ;
16
16
import type { DeployConfig } from "../src/observableApiConfig.js" ;
17
- import { stripColor } from "../src/tty.js" ;
17
+ import { link , stripColor } from "../src/tty.js" ;
18
18
import { MockAuthEffects } from "./mocks/authEffects.js" ;
19
19
import { TestClackEffects } from "./mocks/clack.js" ;
20
20
import { MockConfigEffects } from "./mocks/configEffects.js" ;
@@ -207,7 +207,7 @@ describe("deploy", () => {
207
207
describe ( "in isolated directory with git repo" , ( ) => {
208
208
mockIsolatedDirectory ( { git : true } ) ;
209
209
210
- it ( "fails continuous deployment if repo has no GitHub remote" , async ( ) => {
210
+ it ( "fails cloud build if repo has no GitHub remote" , async ( ) => {
211
211
getCurrentObservableApi ( )
212
212
. handleGetCurrentUser ( )
213
213
. handleGetWorkspaceProjects ( {
@@ -234,7 +234,39 @@ describe("deploy", () => {
234
234
effects . close ( ) ;
235
235
} ) ;
236
236
237
- it ( "starts cloud build when continuous deployment is enabled and repo is valid" , async ( ) => {
237
+ it ( "fails cloud build if repo doesn’t match" , async ( ) => {
238
+ getCurrentObservableApi ( )
239
+ . handleGetCurrentUser ( )
240
+ . handleGetProject ( {
241
+ ...DEPLOY_CONFIG ,
242
+ source : {
243
+ provider : "github" ,
244
+ provider_id : "123:456" ,
245
+ url : "https://github.com/observablehq/test.git" ,
246
+ branch : "main"
247
+ } ,
248
+ latestCreatedDeployId : null
249
+ } )
250
+ . handleGetRepository ( { ownerName : "observablehq" , repoName : "wrongrepo" , provider_id : "000:001" } )
251
+ . start ( ) ;
252
+ const effects = new MockDeployEffects ( { deployConfig : { ...DEPLOY_CONFIG , continuousDeployment : true } } ) ;
253
+
254
+ await ( await open ( "readme.md" , "a" ) ) . close ( ) ;
255
+ await promisify ( exec ) (
256
+ "git add . && git commit -m 'initial' && git remote add origin [email protected] :observablehq/wrongrepo.git"
257
+ ) ;
258
+
259
+ try {
260
+ await deploy ( TEST_OPTIONS , effects ) ;
261
+ assert . fail ( "expected error" ) ;
262
+ } catch ( error ) {
263
+ CliError . assert ( error , { message : `Configured repository does not match local repository; check build settings on ${ link ( `https://observablehq.com/projects/@${ DEPLOY_CONFIG . workspaceLogin } /${ DEPLOY_CONFIG . projectSlug } /settings` ) } ` } ) ;
264
+ }
265
+
266
+ effects . close ( ) ;
267
+ } ) ;
268
+
269
+ it ( "starts cloud build when continuous deployment is enabled for new project and repo is valid" , async ( ) => {
238
270
const deployId = "deploy123" ;
239
271
getCurrentObservableApi ( )
240
272
. handleGetCurrentUser ( )
@@ -282,6 +314,7 @@ describe("deploy", () => {
282
314
} ,
283
315
latestCreatedDeployId : null
284
316
} )
317
+ . handleGetRepository ( { useProviderId : false } )
285
318
. handleGetRepository ( { useProviderId : true } )
286
319
. handlePostProjectBuild ( )
287
320
. handleGetProject ( {
@@ -297,9 +330,6 @@ describe("deploy", () => {
297
330
. handleGetDeploy ( { deployId, deployStatus : "uploaded" } )
298
331
. start ( ) ;
299
332
const effects = new MockDeployEffects ( { deployConfig : { ...DEPLOY_CONFIG , continuousDeployment : true } } ) ;
300
- effects . clack . inputs . push (
301
- "bi" // Which app do you want to use?
302
- ) ;
303
333
304
334
await ( await open ( "readme.md" , "a" ) ) . close ( ) ;
305
335
await promisify ( exec ) (
@@ -315,7 +345,7 @@ describe("deploy", () => {
315
345
describe ( "in isolated directory without git repo" , ( ) => {
316
346
mockIsolatedDirectory ( { git : false } ) ;
317
347
318
- it ( "fails continuous deployment if not in a git repo" , async ( ) => {
348
+ it ( "fails cloud build if not in a git repo" , async ( ) => {
319
349
getCurrentObservableApi ( )
320
350
. handleGetCurrentUser ( )
321
351
. handleGetWorkspaceProjects ( {
0 commit comments