11using Blake . IntegrationTests . Infrastructure ;
2+ using System . ComponentModel ;
23
34namespace Blake . IntegrationTests . Commands ;
45
@@ -17,11 +18,10 @@ public async Task BlakeServe_WithNonExistentPath_ShowsError()
1718
1819 // Act - Use a short timeout since serve command runs indefinitely
1920 using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 5 ) ) ;
20- var result = await RunBlakeFromDotnetAsync ( "serve" , nonExistentPath , cancellationToken : cts . Token ) ;
21+ var action = RunBlakeFromDotnetAsync ( "serve" , nonExistentPath , cancellationToken : cts . Token ) ;
2122
2223 // Assert
23- Assert . NotEqual ( 0 , result . ExitCode ) ;
24- Assert . Contains ( "does not exist" , result . ErrorText ) ;
24+ await Assert . ThrowsAsync < Win32Exception > ( async ( ) => await action ) ;
2525 }
2626
2727 [ Fact ]
@@ -44,8 +44,8 @@ public async Task BlakeServe_BakesBeforeServing()
4444<div>@Body</div>"
4545 ) ;
4646
47- // Act - Start serve command but cancel quickly
48- using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 10 ) ) ;
47+ // Act - Start serve command
48+ using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 20 ) ) ;
4949 var result = await RunBlakeFromDotnetAsync ( "serve" , testDir , cancellationToken : cts . Token ) ;
5050
5151 // Assert
@@ -78,7 +78,7 @@ public async Task BlakeServe_WithBakeFailure_DoesNotStartServer()
7878 // Intentionally don't create template to potentially cause failure
7979
8080 // Act
81- using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 10 ) ) ;
81+ using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 20 ) ) ;
8282 var result = await RunBlakeFromDotnetAsync ( "serve" , testDir , cancellationToken : cts . Token ) ;
8383
8484 // Assert
@@ -98,7 +98,7 @@ public async Task BlakeServe_WithValidProject_AttemptsToRunDotnetRun()
9898 await FileSystemHelper . CreateBlazorWasmProjectAsync ( testDir , "ValidServe" ) ;
9999
100100 // Act
101- using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 15 ) ) ;
101+ using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 20 ) ) ;
102102 var result = await RunBlakeFromDotnetAsync ( "serve" , testDir , cancellationToken : cts . Token ) ;
103103
104104 // Assert
@@ -117,13 +117,29 @@ public async Task BlakeServe_PassesThroughOptions()
117117 // Arrange
118118 var testDir = CreateTempDirectory ( "blake-serve-options" ) ;
119119 await FileSystemHelper . CreateBlazorWasmProjectAsync ( testDir , "OptionsTest" ) ;
120+
121+ var content = @"
122+ This is a test post with a default container. The resulting Razor should not include Bootstrap styles.
123+
124+ :::tip
125+ This is a tip block that should not be styled with Bootstrap.
126+ :::
127+ " ;
120128
121129 FileSystemHelper . CreateMarkdownFile (
122130 Path . Combine ( testDir , "Posts" , "post.md" ) ,
123131 "Test Post" ,
124- "Content"
132+ content
125133 ) ;
126134
135+ // Create a Razor template that does not use Bootstrap styles
136+ FileSystemHelper . CreateRazorTemplate (
137+ Path . Combine ( testDir , "Components" , "TipContainer.razor" ) ,
138+ @"<div>@ChildContent</div>
139+ @code {
140+ [Parameter] public RenderFragment? ChildContent { get; set;
141+ }" ) ;
142+
127143 FileSystemHelper . CreateRazorTemplate (
128144 Path . Combine ( testDir , "Posts" , "template.razor" ) ,
129145 @"@page ""/posts/{Slug}""
@@ -136,11 +152,14 @@ public async Task BlakeServe_PassesThroughOptions()
136152 var result = await RunBlakeCommandAsync ( [ "serve" , testDir , "--disableDefaultRenderers" ] , cts . Token ) ;
137153
138154 // Assert
139- // Should have passed through the option to the bake step
140- Assert . Contains ( result . OutputText , o => o . Contains ( "Baking in:" ) ) ;
141-
142- // Should have created generated content despite the option
155+ // Should have created generated content despite the option//
143156 FileSystemHelper . AssertDirectoryExists ( Path . Combine ( testDir , ".generated" ) ) ;
157+ // Generated Razor file should not include Bootstrap styles
158+ var generatedFile = Path . Combine ( testDir , ".generated" , "posts" , "Post.razor" ) ;
159+ Assert . True ( File . Exists ( generatedFile ) , "Generated Razor file should exist after serving with options." ) ;
160+ var generatedContent = await File . ReadAllTextAsync ( generatedFile ) ;
161+ Assert . Contains ( "<TipContainer" , generatedContent ) ;
162+ Assert . DoesNotContain ( "alert-secondary" , generatedContent ) ;
144163 }
145164
146165 [ Fact ]
@@ -149,16 +168,16 @@ public async Task BlakeServe_WithMissingContentFolder_HandlesGracefully()
149168 // Arrange
150169 var testDir = CreateTempDirectory ( "blake-serve-no-content" ) ;
151170 await FileSystemHelper . CreateBlazorWasmProjectAsync ( testDir , "NoContent" ) ;
152-
171+
153172 // Don't create any Posts or Pages folders
154173
155174 // Act
156- using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 10 ) ) ;
175+ using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 20 ) ) ;
157176 var result = await RunBlakeFromDotnetAsync ( "serve" , testDir , cancellationToken : cts . Token ) ;
158177
159178 // Assert
160179 // Should handle missing content gracefully and still try to serve
161- Assert . True ( result . ExitCode == 0 || result . ErrorText . Contains ( "was canceled" ) ) ;
180+ Assert . True ( ( result . Canceled . HasValue && result . Canceled . Value == true ) || result . ExitCode == 0 ) ;
162181
163182 // Should still attempt baking
164183 Assert . Contains ( result . OutputText , o => o . Contains ( "Baking in:" ) ) ;
@@ -172,10 +191,13 @@ public async Task BlakeServe_CreatesGeneratedFolder()
172191 await FileSystemHelper . CreateBlazorWasmProjectAsync ( testDir , "CreateFolder" ) ;
173192
174193 // Act
175- using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 8 ) ) ;
194+ using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 20 ) ) ;
176195 var result = await RunBlakeFromDotnetAsync ( "serve" , testDir , cancellationToken : cts . Token ) ;
177196
178197 // Assert
198+ // Should be cancelled
199+ Assert . True ( ( result . Canceled . HasValue && result . Canceled . Value == true ) || result . ExitCode == 0 ) ;
200+
179201 // Should create .generated folder as part of the bake step
180202 FileSystemHelper . AssertDirectoryExists ( Path . Combine ( testDir , ".generated" ) ) ;
181203 }
@@ -188,11 +210,11 @@ public async Task BlakeServe_UsesCurrentDirectoryWhenNoPathProvided()
188210 await FileSystemHelper . CreateBlazorWasmProjectAsync ( testDir , "CurrentDir" ) ;
189211
190212 // Act - Run blake serve without path argument from the project directory
191- using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 8 ) ) ;
213+ using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 20 ) ) ;
192214 var result = await RunBlakeFromDotnetAsync ( "serve" , testDir , cancellationToken : cts . Token ) ;
193215
194216 // Assert
195- Assert . True ( result . ExitCode == 0 || result . ErrorText . Contains ( "was canceled" ) ) ;
217+ Assert . True ( ( result . Canceled . HasValue && result . Canceled . Value == true ) || result . ExitCode == 0 ) ;
196218 Assert . Contains ( result . OutputText , o => o . Contains ( "Baking in:" ) ) ;
197219
198220 // Should create .generated in the working directory
@@ -207,7 +229,7 @@ public async Task BlakeServe_ShowsProgressMessages()
207229 await FileSystemHelper . CreateBlazorWasmProjectAsync ( testDir , "Progress" ) ;
208230
209231 // Act
210- using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 10 ) ) ;
232+ using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 20 ) ) ;
211233 var result = await RunBlakeFromDotnetAsync ( "serve" , testDir , cancellationToken : cts . Token ) ;
212234
213235 // Assert
@@ -245,7 +267,7 @@ public async Task BlakeServe_IntegrationWithBakeOptions()
245267 ) ;
246268
247269 // Act - Should not include drafts by default
248- using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 8 ) ) ;
270+ using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 20 ) ) ;
249271 var result = await RunBlakeFromDotnetAsync ( "serve" , testDir , cancellationToken : cts . Token ) ;
250272
251273 // Assert
@@ -264,7 +286,7 @@ public async Task BlakeServe_HandlesProjectWithoutCsproj()
264286 // Just create a directory without a proper Blazor project
265287
266288 // Act
267- using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 5 ) ) ;
289+ using var cts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 20 ) ) ;
268290 var result = await RunBlakeFromDotnetAsync ( "serve" , testDir , cancellationToken : cts . Token ) ;
269291
270292 // Assert
0 commit comments