@@ -851,3 +851,37 @@ function createPackageJson(tmpDir: string, type: string, version: string) {
851851 const dirPath = joinPath ( tmpDir , 'node_modules' , '@shopify' , type )
852852 return mkdir ( dirPath ) . then ( ( ) => writeFile ( packagePath , JSON . stringify ( packageJson ) ) )
853853}
854+
855+ describe ( 'preDeployValidation awaiting' , ( ) => {
856+ test ( 'awaits extension validation and catches rejections' , async ( ) => {
857+ // Given
858+ const extension = await testUIExtension ( )
859+ vi . spyOn ( extension , 'preDeployValidation' ) . mockRejectedValue ( new Error ( 'Validation failed' ) )
860+
861+ const app = testApp ( {
862+ allExtensions : [ extension ] ,
863+ } )
864+
865+ // When / Then
866+ await expect ( app . preDeployValidation ( ) ) . rejects . toThrow ( 'Validation failed' )
867+ } )
868+
869+ test ( 'awaits validation for multiple extensions and catches rejections' , async ( ) => {
870+ // Given
871+ const validExtension = await testUIExtension ( )
872+ const invalidExtension = await testUIExtension ( )
873+ const validPreDeployValidation = vi . spyOn ( validExtension , 'preDeployValidation' ) . mockResolvedValue ( )
874+ const invalidPreDeployValidation = vi
875+ . spyOn ( invalidExtension , 'preDeployValidation' )
876+ . mockRejectedValue ( new Error ( 'Validation failed' ) )
877+
878+ const app = testApp ( {
879+ allExtensions : [ validExtension , invalidExtension ] ,
880+ } )
881+
882+ // When / Then
883+ await expect ( app . preDeployValidation ( ) ) . rejects . toThrow ( 'Validation failed' )
884+ expect ( validPreDeployValidation ) . toHaveBeenCalledOnce ( )
885+ expect ( invalidPreDeployValidation ) . toHaveBeenCalledOnce ( )
886+ } )
887+ } )
0 commit comments