@@ -14,7 +14,7 @@ import type {ObservableApiClientOptions, PostDeployUploadedRequest} from "../src
1414import type { GetCurrentUserResponse } from "../src/observableApiClient.js" ;
1515import { ObservableApiClient } from "../src/observableApiClient.js" ;
1616import type { DeployConfig } from "../src/observableApiConfig.js" ;
17- import { stripColor } from "../src/tty.js" ;
17+ import { link , stripColor } from "../src/tty.js" ;
1818import { MockAuthEffects } from "./mocks/authEffects.js" ;
1919import { TestClackEffects } from "./mocks/clack.js" ;
2020import { MockConfigEffects } from "./mocks/configEffects.js" ;
@@ -207,7 +207,7 @@ describe("deploy", () => {
207207 describe ( "in isolated directory with git repo" , ( ) => {
208208 mockIsolatedDirectory ( { git : true } ) ;
209209
210- it ( "fails continuous deployment if repo has no GitHub remote" , async ( ) => {
210+ it ( "fails cloud build if repo has no GitHub remote" , async ( ) => {
211211 getCurrentObservableApi ( )
212212 . handleGetCurrentUser ( )
213213 . handleGetWorkspaceProjects ( {
@@ -234,7 +234,39 @@ describe("deploy", () => {
234234 effects . close ( ) ;
235235 } ) ;
236236
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 git@github.com: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 ( ) => {
238270 const deployId = "deploy123" ;
239271 getCurrentObservableApi ( )
240272 . handleGetCurrentUser ( )
@@ -282,6 +314,7 @@ describe("deploy", () => {
282314 } ,
283315 latestCreatedDeployId : null
284316 } )
317+ . handleGetRepository ( { useProviderId : false } )
285318 . handleGetRepository ( { useProviderId : true } )
286319 . handlePostProjectBuild ( )
287320 . handleGetProject ( {
@@ -297,9 +330,6 @@ describe("deploy", () => {
297330 . handleGetDeploy ( { deployId, deployStatus : "uploaded" } )
298331 . start ( ) ;
299332 const effects = new MockDeployEffects ( { deployConfig : { ...DEPLOY_CONFIG , continuousDeployment : true } } ) ;
300- effects . clack . inputs . push (
301- "bi" // Which app do you want to use?
302- ) ;
303333
304334 await ( await open ( "readme.md" , "a" ) ) . close ( ) ;
305335 await promisify ( exec ) (
@@ -315,7 +345,7 @@ describe("deploy", () => {
315345 describe ( "in isolated directory without git repo" , ( ) => {
316346 mockIsolatedDirectory ( { git : false } ) ;
317347
318- it ( "fails continuous deployment if not in a git repo" , async ( ) => {
348+ it ( "fails cloud build if not in a git repo" , async ( ) => {
319349 getCurrentObservableApi ( )
320350 . handleGetCurrentUser ( )
321351 . handleGetWorkspaceProjects ( {
0 commit comments