@@ -753,6 +753,45 @@ redirect_urls = [ "https://example.com/api/auth" ]
753753 expect ( app . webs . length ) . toBe ( 0 )
754754 } )
755755
756+ test ( 'ignores web blocks in gitignored directories' , async ( ) => {
757+ // Given
758+ const { webDirectory} = await writeConfig ( appConfiguration )
759+
760+ // Create a gitignored directory with a web config
761+ const ignoredDirectory = joinPath ( tmpDir , 'ignored-worktree' )
762+ await mkdir ( ignoredDirectory )
763+ await writeWebConfiguration ( { webDirectory : ignoredDirectory , role : 'backend' } )
764+
765+ // Create .gitignore file
766+ const gitignoreContent = 'ignored-worktree/\n'
767+ await writeFile ( joinPath ( tmpDir , '.gitignore' ) , gitignoreContent )
768+
769+ // When
770+ const app = await loadTestingApp ( )
771+
772+ // Then
773+ // Should only load the web from the non-ignored directory
774+ expect ( app . webs . length ) . toBe ( 1 )
775+ expect ( app . webs [ 0 ] ! . directory ) . not . toContain ( 'ignored-worktree' )
776+ } )
777+
778+ test ( 'loads all web blocks when no .gitignore file exists' , async ( ) => {
779+ // Given
780+ const { webDirectory} = await writeConfig ( appConfiguration )
781+
782+ // Create another directory with a web config (but no .gitignore file)
783+ const anotherDirectory = joinPath ( tmpDir , 'another-web' )
784+ await mkdir ( anotherDirectory )
785+ await writeWebConfiguration ( { webDirectory : anotherDirectory , role : 'frontend' } )
786+
787+ // When
788+ const app = await loadTestingApp ( )
789+
790+ // Then
791+ // Should load both web blocks since there's no .gitignore
792+ expect ( app . webs . length ) . toBe ( 2 )
793+ } )
794+
756795 test ( 'loads the app when it has a extension with a valid configuration' , async ( ) => {
757796 // Given
758797 await writeConfig ( appConfiguration )
@@ -834,6 +873,44 @@ redirect_urls = [ "https://example.com/api/auth" ]
834873 expect ( app . allExtensions [ 0 ] ! . localIdentifier ) . toBe ( 'custom-extension' )
835874 } )
836875
876+ test ( 'ignores extensions in gitignored directories' , async ( ) => {
877+ // Given
878+ await writeConfig ( appConfiguration )
879+
880+ // Create a non-ignored extension
881+ const blockConfiguration = `
882+ name = "my_extension"
883+ type = "checkout_post_purchase"
884+ `
885+ await writeBlockConfig ( {
886+ blockConfiguration,
887+ name : 'my-extension' ,
888+ } )
889+ await writeFile ( joinPath ( blockPath ( 'my-extension' ) , 'index.js' ) , '' )
890+
891+ // Create a gitignored directory with an extension
892+ const ignoredExtensionDir = joinPath ( tmpDir , 'extensions' , 'ignored-extension' )
893+ await mkdir ( ignoredExtensionDir )
894+ const ignoredBlockConfiguration = `
895+ name = "ignored_extension"
896+ type = "checkout_post_purchase"
897+ `
898+ await writeFile ( joinPath ( ignoredExtensionDir , 'my-ignored-extension.extension.toml' ) , ignoredBlockConfiguration )
899+ await writeFile ( joinPath ( ignoredExtensionDir , 'index.js' ) , '' )
900+
901+ // Create .gitignore file
902+ const gitignoreContent = 'extensions/ignored-extension/\n'
903+ await writeFile ( joinPath ( tmpDir , '.gitignore' ) , gitignoreContent )
904+
905+ // When
906+ const app = await loadTestingApp ( )
907+
908+ // Then
909+ // Should only load the non-ignored extension
910+ expect ( app . allExtensions . length ) . toBe ( 1 )
911+ expect ( app . allExtensions [ 0 ] ! . configuration . name ) . toBe ( 'my_extension' )
912+ } )
913+
837914 test ( 'loads the app from a extension directory when it has a extension with a valid configuration' , async ( ) => {
838915 // Given
839916 await writeConfig ( appConfiguration )
0 commit comments