@@ -730,6 +730,114 @@ def __init__(self):
730730 expected_ignore = ['css' , 'js' ]
731731 assert mock_app .config .assets_path_ignore == expected_ignore
732732
733+ def test_set_assets_path_ignore_extends_existing (self ):
734+ """Test _set_assets_path_ignore method extends existing assets_path_ignore."""
735+ build_assets_paths = ['./assets/css' , 'assets/js' ]
736+ entry_js_paths = ['assets/js/main.js' ]
737+ npm_packages = [NpmPackage ('react' )]
738+
739+ plugin = VitePlugin (
740+ build_assets_paths = build_assets_paths , entry_js_paths = entry_js_paths , npm_packages = npm_packages
741+ )
742+
743+ # Create a mock Dash app with existing assets_path_ignore
744+ class MockConfig :
745+ def __init__ (self ):
746+ self .assets_folder = 'assets'
747+ self .assets_path_ignore = ['existing/ignore' ]
748+
749+ mock_app = MagicMock ()
750+ mock_app .config = MockConfig ()
751+
752+ # Call _set_assets_path_ignore
753+ plugin ._set_assets_path_ignore (mock_app )
754+
755+ # Check that assets_path_ignore was extended correctly
756+ expected_ignore = ['existing/ignore' , 'css' , 'js' ]
757+ assert mock_app .config .assets_path_ignore == expected_ignore
758+
759+ def test_set_assets_path_ignore_no_matching_paths (self ):
760+ """Test _set_assets_path_ignore method when no paths match assets_dir_name."""
761+ build_assets_paths = ['other/css' , './public/js' ]
762+ entry_js_paths = ['assets/js/main.js' ]
763+ npm_packages = [NpmPackage ('react' )]
764+
765+ plugin = VitePlugin (
766+ build_assets_paths = build_assets_paths , entry_js_paths = entry_js_paths , npm_packages = npm_packages
767+ )
768+
769+ # Create a mock Dash app with real config object
770+ class MockConfig :
771+ def __init__ (self ):
772+ self .assets_folder = 'assets'
773+ self .assets_path_ignore = []
774+
775+ mock_app = MagicMock ()
776+ mock_app .config = MockConfig ()
777+
778+ # Call _set_assets_path_ignore
779+ plugin ._set_assets_path_ignore (mock_app )
780+
781+ # Check that assets_path_ignore remains empty
782+ assert mock_app .config .assets_path_ignore == []
783+
784+ def test_set_assets_path_ignore_empty_build_assets_paths (self ):
785+ """Test _set_assets_path_ignore method when build_assets_paths is empty."""
786+ build_assets_paths = []
787+ entry_js_paths = ['assets/js/main.js' ]
788+ npm_packages = [NpmPackage ('react' )]
789+
790+ plugin = VitePlugin (
791+ build_assets_paths = build_assets_paths , entry_js_paths = entry_js_paths , npm_packages = npm_packages
792+ )
793+
794+ # Create a mock Dash app with real config object
795+ class MockConfig :
796+ def __init__ (self ):
797+ self .assets_folder = 'assets'
798+ self .assets_path_ignore = []
799+
800+ mock_app = MagicMock ()
801+ mock_app .config = MockConfig ()
802+
803+ # Call _set_assets_path_ignore
804+ plugin ._set_assets_path_ignore (mock_app )
805+
806+ # Check that assets_path_ignore remains empty
807+ assert mock_app .config .assets_path_ignore == []
808+
809+ def test_set_assets_path_ignore_complex_paths (self ):
810+ """Test _set_assets_path_ignore method with complex paths."""
811+ build_assets_paths = [
812+ 'assets/js' ,
813+ './assets/css/styles' ,
814+ 'assets/images/icons' ,
815+ 'public/assets/js' , # Should not match
816+ './public/css' , # Should not match
817+ ]
818+ entry_js_paths = ['assets/js/main.js' ]
819+ npm_packages = [NpmPackage ('react' )]
820+
821+ plugin = VitePlugin (
822+ build_assets_paths = build_assets_paths , entry_js_paths = entry_js_paths , npm_packages = npm_packages
823+ )
824+
825+ # Create a mock Dash app with real config object
826+ class MockConfig :
827+ def __init__ (self ):
828+ self .assets_folder = 'assets'
829+ self .assets_path_ignore = []
830+
831+ mock_app = MagicMock ()
832+ mock_app .config = MockConfig ()
833+
834+ # Call _set_assets_path_ignore
835+ plugin ._set_assets_path_ignore (mock_app )
836+
837+ # Check that assets_path_ignore contains the correct paths
838+ expected_ignore = ['js' , 'css/styles' , 'images/icons' ]
839+ assert mock_app .config .assets_path_ignore == expected_ignore
840+
733841 def test_build_assets_with_vite (self ):
734842 """Test _build_assets_with_vite method."""
735843 build_assets_paths = ['assets/js' ]
0 commit comments