| 1 | using CascadeIDE.Cockpit.Composition.Shell; |
| 2 | using CascadeIDE.Models; |
| 3 | using CascadeIDE.Services.Presentation; |
| 4 | using Xunit; |
| 5 | |
| 6 | using CascadeIDE.Features.Agent.Environment; |
| 7 | |
| 8 | namespace CascadeIDE.Tests; |
| 9 | |
| 10 | public sealed class PresentationTierShellCompositorTests |
| 11 | { |
| 12 | private static PresentationGrammarTokens Grammar() => |
| 13 | PresentationGrammarTokens.FromSettings("()", " ", "+", "P", "F", "M"); |
| 14 | |
| 15 | [Fact] |
| 16 | public void Compact_tier_hides_pfd_and_shows_aux_panel_when_expanded() |
| 17 | { |
| 18 | var parse = PresentationParser.Parse("(P+F) (M)", Grammar()); |
| 19 | var display = new DisplaySettings |
| 20 | { |
| 21 | Presentation = new DisplayPresentationSettings { CompactAuxiliaryPanelWidthPx = 400 }, |
| 22 | }; |
| 23 | |
| 24 | var c = MainWindowShellSurfaceCompositor.Compose( |
| 25 | new MainWindowShellSurfaceCompositionInput( |
| 26 | parse, |
| 27 | IntentSolutionExplorerVisible: true, |
| 28 | IntentChatPanelExpanded: true, |
| 29 | SuppressPfdColumnForPfdHostWindow: false, |
| 30 | SuppressMfdColumnForMfdHostWindow: false, |
| 31 | ExpandedMfdWidthPixels: 340, |
| 32 | CollapsedMfdWidthPixels: 8, |
| 33 | display, |
| 34 | AgentSafetyLevel.Confirm, |
| 35 | PresentationTierKind.Compact)); |
| 36 | |
| 37 | Assert.False(c.PfdSurfaceVisible); |
| 38 | Assert.True(c.CompactIdeLayout); |
| 39 | Assert.True(c.IntercomAuxColumnVisible); |
| 40 | Assert.False(c.MfdColumnVisibleInMainGrid); |
| 41 | Assert.Equal(400, c.IntercomAuxColumnPixelWidth); |
| 42 | Assert.Equal(400, c.CompactRightChromeColumnPixelWidth); |
| 43 | } |
| 44 | |
| 45 | [Fact] |
| 46 | public void Compact_tier_bottom_intercom_placement_uses_bottom_dock_not_side_aux() |
| 47 | { |
| 48 | var parse = PresentationParser.Parse("(F)", Grammar()); |
| 49 | var display = new DisplaySettings |
| 50 | { |
| 51 | Presentation = new DisplayPresentationSettings |
| 52 | { |
| 53 | CompactIntercomPlacement = "bottom", |
| 54 | CompactIntercomBottomDockHeightPx = 300, |
| 55 | }, |
| 56 | }; |
| 57 | |
| 58 | var c = MainWindowShellSurfaceCompositor.Compose( |
| 59 | new MainWindowShellSurfaceCompositionInput( |
| 60 | parse, |
| 61 | IntentSolutionExplorerVisible: false, |
| 62 | IntentChatPanelExpanded: true, |
| 63 | SuppressPfdColumnForPfdHostWindow: false, |
| 64 | SuppressMfdColumnForMfdHostWindow: false, |
| 65 | ExpandedMfdWidthPixels: 340, |
| 66 | CollapsedMfdWidthPixels: 8, |
| 67 | display, |
| 68 | AgentSafetyLevel.Confirm, |
| 69 | PresentationTierKind.Compact)); |
| 70 | |
| 71 | Assert.False(c.IntercomAuxColumnVisible); |
| 72 | Assert.True(c.IntercomBottomDockVisible); |
| 73 | Assert.Equal(300, c.IntercomBottomDockHeightPx); |
| 74 | Assert.False(c.CompactRightChromeColumnVisible); |
| 75 | } |
| 76 | |
| 77 | [Fact] |
| 78 | public void Compact_tier_pfd_right_when_solution_explorer_intent() |
| 79 | { |
| 80 | var parse = PresentationParser.Parse("(F)", Grammar()); |
| 81 | var display = new DisplaySettings { Presentation = new DisplayPresentationSettings() }; |
| 82 | |
| 83 | var c = MainWindowShellSurfaceCompositor.Compose( |
| 84 | new MainWindowShellSurfaceCompositionInput( |
| 85 | parse, |
| 86 | IntentSolutionExplorerVisible: true, |
| 87 | IntentChatPanelExpanded: false, |
| 88 | SuppressPfdColumnForPfdHostWindow: false, |
| 89 | SuppressMfdColumnForMfdHostWindow: false, |
| 90 | ExpandedMfdWidthPixels: 340, |
| 91 | CollapsedMfdWidthPixels: 8, |
| 92 | display, |
| 93 | AgentSafetyLevel.Confirm, |
| 94 | PresentationTierKind.Compact)); |
| 95 | |
| 96 | Assert.True(c.PfdRightColumnVisible); |
| 97 | Assert.Equal(220, c.PfdRightColumnPixelWidth); |
| 98 | Assert.False(c.IntercomAuxColumnVisible); |
| 99 | } |
| 100 | |
| 101 | [Fact] |
| 102 | public void Compact_tier_collapsed_aux_panel_zero_width() |
| 103 | { |
| 104 | var parse = PresentationParser.Parse("(F)", Grammar()); |
| 105 | var display = new DisplaySettings { Presentation = new DisplayPresentationSettings() }; |
| 106 | |
| 107 | var c = MainWindowShellSurfaceCompositor.Compose( |
| 108 | new MainWindowShellSurfaceCompositionInput( |
| 109 | parse, |
| 110 | IntentSolutionExplorerVisible: false, |
| 111 | IntentChatPanelExpanded: false, |
| 112 | SuppressPfdColumnForPfdHostWindow: false, |
| 113 | SuppressMfdColumnForMfdHostWindow: false, |
| 114 | ExpandedMfdWidthPixels: 340, |
| 115 | CollapsedMfdWidthPixels: 8, |
| 116 | display, |
| 117 | AgentSafetyLevel.Confirm, |
| 118 | PresentationTierKind.Compact)); |
| 119 | |
| 120 | Assert.False(c.PfdSurfaceVisible); |
| 121 | Assert.False(c.MfdColumnVisibleInMainGrid); |
| 122 | Assert.Equal(0, c.MfdColumnPixelWidthInMainGrid); |
| 123 | } |
| 124 | } |
| 125 | |