@@ -154,6 +154,31 @@ def test_root_redirects_to_view(self) -> None:
154154 self .assertEqual (response .status_code , 302 )
155155 self .assertEqual (response .headers .get ("Location" ), "/view" )
156156
157+ def test_spa_entry_serves_dist_asset_when_present (self ) -> None :
158+ with tempfile .TemporaryDirectory () as temp_dir :
159+ root = Path (temp_dir )
160+ dist_dir = root / "chronicle-ui" / "dist"
161+ assets_dir = dist_dir / "assets"
162+ assets_dir .mkdir (parents = True , exist_ok = True )
163+ (dist_dir / "index.html" ).write_text ("<html><body><div id='root'></div></body></html>" , encoding = "utf-8" )
164+ (assets_dir / "index.js" ).write_text ("console.log('spa boot');" , encoding = "utf-8" )
165+
166+ with patch .object (api_server , "PROJECT_ROOT" , root ):
167+ response = self .client .get ("/app/assets/index.js" )
168+ self .assertEqual (response .status_code , 200 )
169+ self .assertIn ("spa boot" , response .get_data (as_text = True ))
170+
171+ def test_spa_entry_returns_404_for_missing_dist_asset (self ) -> None :
172+ with tempfile .TemporaryDirectory () as temp_dir :
173+ root = Path (temp_dir )
174+ dist_dir = root / "chronicle-ui" / "dist"
175+ dist_dir .mkdir (parents = True , exist_ok = True )
176+ (dist_dir / "index.html" ).write_text ("<html><body><div id='root'></div></body></html>" , encoding = "utf-8" )
177+
178+ with patch .object (api_server , "PROJECT_ROOT" , root ):
179+ response = self .client .get ("/app/assets/missing.js" )
180+ self .assertEqual (response .status_code , 404 )
181+
157182 def test_dashboard_page_endpoint (self ) -> None :
158183 response = self .client .get ("/dashboard" )
159184 self .assertEqual (response .status_code , 200 )
0 commit comments