@@ -246,6 +246,70 @@ public async Task ConsoleLogsManager_ClearLogs_LogsFilteredOutAsync()
246
246
cut . WaitForState ( ( ) => instance . _logEntries . EntriesCount > 0 ) ;
247
247
}
248
248
249
+ [ Fact ]
250
+ public void MenuButtons_SelectedResourceChanged_ButtonsUpdated ( )
251
+ {
252
+ // Arrange
253
+ var testResource = ModelTestHelpers . CreateResource (
254
+ appName : "test-resource" ,
255
+ state : KnownResourceState . Running ,
256
+ commands : [ new CommandViewModel ( "test-name" , CommandViewModelState . Enabled , "test-displayname" , "test-displaydescription" , confirmationMessage : "" , parameter : null , isHighlighted : true , iconName : string . Empty , iconVariant : IconVariant . Regular ) ] ) ;
257
+ var subscribedResourceNameTcs = new TaskCompletionSource < string > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
258
+ var consoleLogsChannel = Channel . CreateUnbounded < IReadOnlyList < ResourceLogLine > > ( ) ;
259
+ var resourceChannel = Channel . CreateUnbounded < IReadOnlyList < ResourceViewModelChange > > ( ) ;
260
+ var dashboardClient = new TestDashboardClient (
261
+ isEnabled : true ,
262
+ consoleLogsChannelProvider : name =>
263
+ {
264
+ subscribedResourceNameTcs . TrySetResult ( name ) ;
265
+ return consoleLogsChannel ;
266
+ } ,
267
+ resourceChannelProvider : ( ) => resourceChannel ,
268
+ initialResources : [ testResource ] ) ;
269
+
270
+ SetupConsoleLogsServices ( dashboardClient ) ;
271
+
272
+ var dimensionManager = Services . GetRequiredService < DimensionManager > ( ) ;
273
+ var viewport = new ViewportInformation ( IsDesktop : true , IsUltraLowHeight : false , IsUltraLowWidth : false ) ;
274
+ dimensionManager . InvokeOnViewportInformationChanged ( viewport ) ;
275
+
276
+ // Act 1
277
+ var cut = RenderComponent < Components . Pages . ConsoleLogs > ( builder =>
278
+ {
279
+ builder . Add ( p => p . ResourceName , "test-resource" ) ;
280
+ builder . Add ( p => p . ViewportInformation , viewport ) ;
281
+ } ) ;
282
+
283
+ var instance = cut . Instance ;
284
+ var logger = Services . GetRequiredService < ILogger < ConsoleLogsTests > > ( ) ;
285
+ var loc = Services . GetRequiredService < IStringLocalizer < Resources . ConsoleLogs > > ( ) ;
286
+
287
+ // Assert 1
288
+ cut . WaitForState ( ( ) => instance . PageViewModel . SelectedResource == testResource ) ;
289
+
290
+ cut . WaitForAssertion ( ( ) =>
291
+ {
292
+ var highlightedCommands = cut . FindAll ( ".highlighted-command" ) ;
293
+ Assert . Single ( highlightedCommands ) ;
294
+ } ) ;
295
+
296
+ // Act 2
297
+ testResource = ModelTestHelpers . CreateResource (
298
+ appName : "test-resource" ,
299
+ state : KnownResourceState . Running ,
300
+ commands : [ ] ) ;
301
+ resourceChannel . Writer . TryWrite ( [
302
+ new ResourceViewModelChange ( ResourceViewModelChangeType . Upsert , testResource )
303
+ ] ) ;
304
+
305
+ // Assert 2
306
+ cut . WaitForAssertion ( ( ) =>
307
+ {
308
+ var highlightedCommands = cut . FindAll ( ".highlighted-command" ) ;
309
+ Assert . Empty ( highlightedCommands ) ;
310
+ } ) ;
311
+ }
312
+
249
313
private void SetupConsoleLogsServices ( TestDashboardClient ? dashboardClient = null , TestTimeProvider ? timeProvider = null )
250
314
{
251
315
var version = typeof ( FluentMain ) . Assembly . GetName ( ) . Version ! ;
0 commit comments