@@ -410,15 +410,32 @@ public void RegeneratingScopedCss_ForProject()
410
410
411
411
// Make an edit
412
412
var scopedCssFile = Path . Combine ( ProjectDirectory . TestRoot , "Components" , "Pages" , "Index.razor.css" ) ;
413
- File . WriteAllLines ( scopedCssFile , File . ReadAllLines ( scopedCssFile ) . Concat ( new [ ] { "body { background-color: orangered; }" } ) ) ;
413
+ File . WriteAllLines ( scopedCssFile , File . ReadAllLines ( scopedCssFile ) . Concat ( [ "body { background-color: orangered; }" ] ) ) ;
414
+
415
+ build = CreateBuildCommand ( ProjectDirectory ) ;
416
+ ExecuteCommand ( build , "/t:UpdateStaticWebAssetsDesignTime" ) . Should ( ) . Pass ( ) ;
417
+
418
+ // Verify the generated file contains newly added css
419
+ AssertFileContains ( bundlePath , "background-color: orangered" ) ;
420
+
421
+ // Verify that CSS edits continue to apply after new JS modules are added to the project
422
+ // https://github.com/dotnet/aspnetcore/issues/57599
423
+ var collocatedJsFile = Path . Combine ( ProjectDirectory . TestRoot , "Components" , "Pages" , "Index.razor.js" ) ;
424
+ File . WriteAllLines ( collocatedJsFile , [ "console.log('Hello, world!');" ] ) ;
425
+ File . WriteAllLines ( scopedCssFile , File . ReadAllLines ( scopedCssFile ) . Concat ( [ "h1 { color: purple; }" ] ) ) ;
414
426
415
427
build = CreateBuildCommand ( ProjectDirectory ) ;
416
428
ExecuteCommand ( build , "/t:UpdateStaticWebAssetsDesignTime" ) . Should ( ) . Pass ( ) ;
417
429
418
- var fileInfo = new FileInfo ( bundlePath ) ;
419
- fileInfo . Should ( ) . Exist ( ) ;
420
430
// Verify the generated file contains newly added css
421
- fileInfo . ReadAllText ( ) . Should ( ) . Contain ( "background-color: orangered" ) ;
431
+ AssertFileContains ( bundlePath , "color: purple" ) ;
432
+
433
+ static void AssertFileContains ( string fileName , string content )
434
+ {
435
+ var fileInfo = new FileInfo ( fileName ) ;
436
+ fileInfo . Should ( ) . Exist ( ) ;
437
+ fileInfo . ReadAllText ( ) . Should ( ) . Contain ( content ) ;
438
+ }
422
439
}
423
440
}
424
441
0 commit comments