| 1 | using CascadeIDE.Cockpit.Composition.HostSurface; |
| 2 | using CascadeIDE.Cockpit.Composition.Shell; |
| 3 | using CascadeIDE.Models; |
| 4 | using CascadeIDE.Services.Presentation; |
| 5 | using Xunit; |
| 6 | |
| 7 | using CascadeIDE.Features.Agent.Environment; |
| 8 | |
| 9 | namespace CascadeIDE.Tests; |
| 10 | |
| 11 | public sealed class InstrumentPlacementWorkspaceRoutingTests |
| 12 | { |
| 13 | private static PresentationGrammarTokens DefaultGrammar() => |
| 14 | PresentationGrammarTokens.FromSettings("()", " ", "+", "P", "F", "M"); |
| 15 | |
| 16 | [Fact] |
| 17 | public void Workspace_routing_alias_overrides_default_for_pfd_on_both_surfaces() |
| 18 | { |
| 19 | try |
| 20 | { |
| 21 | InstrumentPlacementRuntime.ResetToCodeDefaults(); |
| 22 | InstrumentPlacementRuntime.ApplyWorkspaceInstrumentRouting( |
| 23 | new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) |
| 24 | { |
| 25 | [InstrumentRoutingSlotKeys.PfdPrimary] = "workspace_map" |
| 26 | }); |
| 27 | |
| 28 | var parse = PresentationParser.Parse("(P+F) (M)", DefaultGrammar()); |
| 29 | Assert.True(parse.IsSuccess); |
| 30 | |
| 31 | var frame = MainWindowHostSurfaceCompositor.ComposeFrame( |
| 32 | new MainWindowShellSurfaceCompositionInput( |
| 33 | parse, |
| 34 | IntentSolutionExplorerVisible: true, |
| 35 | IntentChatPanelExpanded: false, |
| 36 | SuppressPfdColumnForPfdHostWindow: false, |
| 37 | SuppressMfdColumnForMfdHostWindow: false, |
| 38 | ExpandedMfdWidthPixels: 300, |
| 39 | CollapsedMfdWidthPixels: 12, |
| 40 | DisplaySettings: new DisplaySettings { PreferRepoInstruments = true }, |
| 41 | SafetyLevel: AgentSafetyLevel.Confirm)); |
| 42 | |
| 43 | Assert.Single(frame.Instruments); |
| 44 | Assert.Equal(CockpitStandardInstrumentIds.WorkspaceNavigationMap, frame.Instruments[0].InstrumentId); |
| 45 | } |
| 46 | finally |
| 47 | { |
| 48 | InstrumentPlacementRuntime.ResetToCodeDefaults(); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |