Forge
csharp4405de34
1using CascadeIDE.Cockpit.Composition.Shell;
2using CascadeIDE.Models;
3using CascadeIDE.Services.Presentation;
4using Xunit;
5
6using CascadeIDE.Features.Agent.Environment;
7
8namespace CascadeIDE.Tests;
9
10public sealed class MainWindowShellSurfaceCompositorTests
11{
12 private static PresentationGrammarTokens DefaultGrammar() =>
13 PresentationGrammarTokens.FromSettings("()", " ", "+", "P", "F", "M");
14
15 [Fact]
16 public void WhenHostSuppressesMfd_ColumnWidthZeroEvenIfIntentExpanded()
17 {
18 var parse = PresentationParser.Parse("(P+F) (M)", DefaultGrammar());
19 Assert.True(parse.IsSuccess);
20
21 var c = MainWindowShellSurfaceCompositor.Compose(
22 new MainWindowShellSurfaceCompositionInput(
23 parse,
24 IntentSolutionExplorerVisible: true,
25 IntentChatPanelExpanded: true,
26 SuppressPfdColumnForPfdHostWindow: false,
27 SuppressMfdColumnForMfdHostWindow: true,
28 ExpandedMfdWidthPixels: 340,
29 CollapsedMfdWidthPixels: 8,
30 DisplaySettings: new DisplaySettings(),
31 SafetyLevel: AgentSafetyLevel.Confirm));
32
33 Assert.True(c.PfdSurfaceVisible);
34 Assert.True(c.MfdSurfaceExpanded);
35 Assert.False(c.MfdColumnVisibleInMainGrid);
36 Assert.Equal(0, c.MfdColumnPixelWidthInMainGrid);
37 }
38
39 [Fact]
40 public void WhenMRequiredOnFirstScreen_IntentCollapsedStillExpandedSurface()
41 {
42 var parse = PresentationParser.Parse("(P+F+M)", DefaultGrammar());
43 Assert.True(parse.IsSuccess);
44
45 var c = MainWindowShellSurfaceCompositor.Compose(
46 new MainWindowShellSurfaceCompositionInput(
47 parse,
48 IntentSolutionExplorerVisible: true,
49 IntentChatPanelExpanded: false,
50 SuppressPfdColumnForPfdHostWindow: false,
51 SuppressMfdColumnForMfdHostWindow: false,
52 ExpandedMfdWidthPixels: 300,
53 CollapsedMfdWidthPixels: 12,
54 DisplaySettings: new DisplaySettings(),
55 SafetyLevel: AgentSafetyLevel.Confirm));
56
57 Assert.True(c.MfdSurfaceExpanded);
58 Assert.True(c.MfdColumnVisibleInMainGrid);
59 Assert.Equal(300, c.MfdColumnPixelWidthInMainGrid);
60 }
61
62 [Fact]
63 public void WhenPmPlusForwardPreset_MainWindowIsForwardOnly_IntentDoesNotShowPOrMInMain()
64 {
65 var parse = PresentationParser.Parse("(P+M)(F)", DefaultGrammar());
66 Assert.True(parse.IsSuccess);
67
68 var c = MainWindowShellSurfaceCompositor.Compose(
69 new MainWindowShellSurfaceCompositionInput(
70 parse,
71 IntentSolutionExplorerVisible: true,
72 IntentChatPanelExpanded: true,
73 SuppressPfdColumnForPfdHostWindow: false,
74 SuppressMfdColumnForMfdHostWindow: false,
75 ExpandedMfdWidthPixels: 340,
76 CollapsedMfdWidthPixels: 8,
77 DisplaySettings: new DisplaySettings(),
78 SafetyLevel: AgentSafetyLevel.Confirm));
79
80 Assert.False(c.PfdSurfaceVisible);
81 Assert.False(c.MfdColumnVisibleInMainGrid);
82 Assert.Equal(0, c.MfdColumnPixelWidthInMainGrid);
83 }
84
85 [Fact]
86 public void WhenForwardMfdTwoScreen_MainWindowIsForwardOnly_IntentDoesNotShowPOrMInMain()
87 {
88 var parse = PresentationParser.Parse("(F) (M)", DefaultGrammar());
89 Assert.True(parse.IsSuccess);
90
91 var c = MainWindowShellSurfaceCompositor.Compose(
92 new MainWindowShellSurfaceCompositionInput(
93 parse,
94 IntentSolutionExplorerVisible: true,
95 IntentChatPanelExpanded: true,
96 SuppressPfdColumnForPfdHostWindow: false,
97 SuppressMfdColumnForMfdHostWindow: true,
98 ExpandedMfdWidthPixels: 340,
99 CollapsedMfdWidthPixels: 8,
100 DisplaySettings: new DisplaySettings(),
101 SafetyLevel: AgentSafetyLevel.Confirm));
102
103 Assert.False(c.PfdSurfaceVisible);
104 Assert.False(c.MfdColumnVisibleInMainGrid);
105 Assert.Equal(0, c.MfdColumnPixelWidthInMainGrid);
106 }
107}
108
View only · write via MCP/CIDE