| 1 | using CascadeIDE.Features.Agent.Environment; |
| 2 | using CascadeIDE.Features.Shell.Application; |
| 3 | using CascadeIDE.Features.UiChrome; |
| 4 | using Xunit; |
| 5 | |
| 6 | namespace CascadeIDE.Tests; |
| 7 | |
| 8 | public sealed class MainWindowPresentationCapabilitiesProjectionTests |
| 9 | { |
| 10 | private static UiModeCapabilities C(bool ideHealthStrip = true, IdeHealthUiSurface surface = IdeHealthUiSurface.BottomStrip) => |
| 11 | new( |
| 12 | QuickActions: true, |
| 13 | AgentOperationsPanel: true, |
| 14 | AgentTrace: false, |
| 15 | AutonomousAgentTelemetry: false, |
| 16 | IdeHealthOnTerminalTab: true, |
| 17 | IdeHealthMainColumnSpan: 5, |
| 18 | InstrumentationTabs: true, |
| 19 | HypothesesTab: true, |
| 20 | RiskSummaryCard: true, |
| 21 | ResultSummaryCard: true, |
| 22 | IdeHealthStripVisible: ideHealthStrip, |
| 23 | IdeHealthSurface: surface, |
| 24 | ProblemsPanelVisible: true, |
| 25 | EicasAlertsBarEnabled: true); |
| 26 | |
| 27 | [Fact] |
| 28 | public void ShowIdeHealthStrip_requires_bottom_strip_and_flag() |
| 29 | { |
| 30 | Assert.True(MainWindowPresentationCapabilitiesProjection.ShowIdeHealthStrip(C())); |
| 31 | Assert.False(MainWindowPresentationCapabilitiesProjection.ShowIdeHealthStrip(C(ideHealthStrip: false))); |
| 32 | Assert.False(MainWindowPresentationCapabilitiesProjection.ShowIdeHealthStrip( |
| 33 | C(surface: IdeHealthUiSurface.DedicatedPage))); |
| 34 | } |
| 35 | |
| 36 | [Fact] |
| 37 | public void IdeHealthOnTerminalTab_hides_when_bottom_strip_visible() |
| 38 | { |
| 39 | var c = C(); |
| 40 | Assert.False(MainWindowPresentationCapabilitiesProjection.IdeHealthOnTerminalTab(c, showIdeHealthStrip: true)); |
| 41 | Assert.True(MainWindowPresentationCapabilitiesProjection.IdeHealthOnTerminalTab(c, showIdeHealthStrip: false)); |
| 42 | var offTab = C() with { IdeHealthOnTerminalTab = false }; |
| 43 | Assert.False(MainWindowPresentationCapabilitiesProjection.IdeHealthOnTerminalTab(offTab, showIdeHealthStrip: false)); |
| 44 | } |
| 45 | |
| 46 | [Fact] |
| 47 | public void ShowEicasAlertsBar_requires_messages_when_enabled() |
| 48 | { |
| 49 | Assert.False(MainWindowPresentationCapabilitiesProjection.ShowEicasAlertsBar(C(), 0)); |
| 50 | Assert.True(MainWindowPresentationCapabilitiesProjection.ShowEicasAlertsBar(C(), 1)); |
| 51 | Assert.False(MainWindowPresentationCapabilitiesProjection.ShowEicasAlertsBar(C() with { EicasAlertsBarEnabled = false }, 3)); |
| 52 | } |
| 53 | |
| 54 | [Fact] |
| 55 | public void ShowWorkspaceChromeBand_is_or_of_strip_layers() |
| 56 | { |
| 57 | Assert.False(MainWindowPresentationCapabilitiesProjection.ShowWorkspaceChromeBand(false, false)); |
| 58 | Assert.True(MainWindowPresentationCapabilitiesProjection.ShowWorkspaceChromeBand(true, false)); |
| 59 | Assert.True(MainWindowPresentationCapabilitiesProjection.ShowWorkspaceChromeBand(false, true)); |
| 60 | } |
| 61 | |
| 62 | [Fact] |
| 63 | public void LocBadgeSummary_empty_when_non_positive_loc() |
| 64 | { |
| 65 | Assert.Equal("", MainWindowPresentationCapabilitiesProjection.LocBadgeSummary(0, "High")); |
| 66 | Assert.Equal("LOC: 3 · Medium", MainWindowPresentationCapabilitiesProjection.LocBadgeSummary(3, "Medium")); |
| 67 | } |
| 68 | |
| 69 | [Fact] |
| 70 | public void IsSafetyLevel_is_ordinal_ignore_case() |
| 71 | { |
| 72 | Assert.True(MainWindowPresentationCapabilitiesProjection.IsSafetyLevel(AgentSafetyLevel.Observe, AgentSafetyLevel.Observe)); |
| 73 | Assert.False(MainWindowPresentationCapabilitiesProjection.IsSafetyLevel(AgentSafetyLevel.Confirm, AgentSafetyLevel.Observe)); |
| 74 | } |
| 75 | } |
| 76 | |