Skip to content

Commit f121c58

Browse files
committed
Fix tests
1 parent 8daa046 commit f121c58

8 files changed

Lines changed: 53 additions & 20 deletions

File tree

src/NodeDev.Blazor/DiagramsModels/LambdaGroupModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace NodeDev.Blazor.DiagramsModels;
1414
public sealed class LambdaGroupModel : GroupModel
1515
{
1616
public const byte MinimumPadding = 60;
17-
public const byte FuncPadding = 90;
17+
public const byte FuncPadding = MinimumPadding;
1818
public const double MinimumWidth = 600;
1919
public const double MinimumHeight = 420;
2020

src/NodeDev.Blazor/DiagramsModels/LambdaGroupWidget.razor

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
<div class="lambda-signature-editor" data-test-id="lambda-signature-editor">
2020
@if (Group.DelegateNode is CreateFuncNode)
2121
{
22-
<button class="lambda-signature-chip lambda-result-chip" @onclick="SelectResultType" @onclick:stopPropagation="true">
22+
<button class="lambda-signature-chip lambda-result-chip"
23+
title="Returns @Group.DelegateNode.ResultType?.FriendlyName"
24+
@onclick="SelectResultType"
25+
@onclick:stopPropagation="true">
2326
returns @(Group.DelegateNode.ResultType?.FriendlyName ?? "?")
2427
</button>
2528
}

src/NodeDev.Blazor/wwwroot/styles.css

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,14 @@ g.diagram-link path:not(.selection-helper) {
227227

228228
.lambda-region-title-row {
229229
justify-content: space-between;
230+
flex: 1 1 auto;
231+
min-width: 0;
230232
}
231233

232234
.lambda-signature-editor {
235+
flex: 0 1 auto;
233236
flex-wrap: wrap;
234-
margin-top: 0.25rem;
237+
justify-content: flex-end;
235238
font-size: 0.7rem;
236239
}
237240

@@ -245,6 +248,7 @@ g.diagram-link path:not(.selection-helper) {
245248
}
246249

247250
.lambda-signature-chip button,
251+
.lambda-result-chip,
248252
.lambda-signature-add {
249253
border: 0;
250254
background: transparent;
@@ -268,6 +272,13 @@ g.diagram-link path:not(.selection-helper) {
268272
border-radius: 999px;
269273
}
270274

275+
.lambda-result-chip {
276+
max-width: 180px;
277+
overflow: hidden;
278+
text-overflow: ellipsis;
279+
white-space: nowrap;
280+
}
281+
271282
.lambda-chip-remove {
272283
font-weight: 700;
273284
padding-left: 0.2rem !important;
@@ -315,7 +326,7 @@ g.diagram-link path:not(.selection-helper) {
315326
position: absolute;
316327
right: -1px;
317328
bottom: 18px;
318-
width: 190px;
329+
width: 156px;
319330
box-sizing: border-box;
320331
overflow: visible;
321332
padding: 0 10px 7px 14px;

src/NodeDev.Core/Nodes/Delegates/CreateFuncNode.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
using NodeDev.Core.Types;
2-
31
namespace NodeDev.Core.Nodes.Delegates;
42

53
public sealed class CreateFuncNode : CreateDelegateNode
64
{
75
public CreateFuncNode(Graph graph, string? id = null) : base(graph, id)
86
{
97
Name = "Create Func";
10-
InitializeSignature(new UndefinedGenericType($"LambdaResult_{Id.Replace('-', '_')}"));
8+
InitializeSignature(TypeFactory.Get<bool>());
119
}
1210

1311
public override DelegateKind Kind => DelegateKind.Func;

src/NodeDev.EndToEndTests/Pages/HomePage.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,25 +179,27 @@ public async Task DragNodeTo(string nodeName, float targetX, float targetY)
179179
if (box == null)
180180
throw new Exception($"Could not get bounding box for node '{nodeName}'");
181181

182-
await node.ClickAsync();
183-
184182
// Calculate center of node as the starting point
185183
var sourceX = (float)(box.X + box.Width / 2);
186184
var sourceY = (float)(box.Y + box.Height / 2);
187185

188186
Console.WriteLine($"Dragging {nodeName} from ({sourceX}, {sourceY}) to ({targetX}, {targetY})");
189187

190-
// Perform manual drag with proper event sequence for Blazor.Diagrams
191-
// 1. Move mouse to starting position
188+
// Dismiss any hover UI left by the preceding action (for example, a MudBlazor
189+
// tooltip from a node-search result) before interacting with the diagram node.
190+
await _user.Mouse.MoveAsync(0, 0);
191+
192+
// Perform manual drag with proper event sequence for Blazor.Diagrams.
193+
// Moving to the node and pressing the mouse button selects it and starts the drag;
194+
// a separate click is both redundant and vulnerable to transient popovers.
192195
await _user.Mouse.MoveAsync(sourceX, sourceY);
193-
// 2. Press mouse button down (pointerdown event)
194196
await _user.Mouse.DownAsync();
195197
await Task.Delay(50); // Single delay for event propagation
196198

197-
// 3. Move mouse to target position with multiple steps (pointermove events)
199+
// Move mouse to target position with multiple steps (pointermove events)
198200
await _user.Mouse.MoveAsync(targetX, targetY, new() { Steps = 15 });
199201

200-
// 4. Release mouse button (pointerup event)
202+
// Release mouse button (pointerup event)
201203
await _user.Mouse.UpAsync();
202204

203205
// Wait for the UI to update after drag
@@ -316,7 +318,11 @@ public async Task DeleteConnection(string sourceNodeName, string sourcePortName,
316318

317319
public async Task TakeScreenshot(string fileName)
318320
{
319-
await _user.ScreenshotAsync(new() { Path = fileName });
321+
var screenshotPath = fileName;
322+
if (OperatingSystem.IsWindows() && fileName.StartsWith("/tmp/", StringComparison.Ordinal))
323+
screenshotPath = Path.Combine(Path.GetTempPath(), fileName["/tmp/".Length..]);
324+
325+
await _user.ScreenshotAsync(new() { Path = screenshotPath });
320326
}
321327

322328
// Advanced Node Operations

src/NodeDev.EndToEndTests/Tests/LambdaRegionTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ public async Task CreateFunc_ShowsLiveRegionBodyAndSignatureControls()
4040
var rebuiltRegion = Page.Locator("[data-test-id='lambda-region']").Last;
4141
await rebuiltRegion.Locator("[data-test-id='lambda-parameter']").WaitForAsync(new() { State = WaitForSelectorState.Visible });
4242

43-
await HomePage.SearchForNodes("TypeOf");
44-
await HomePage.AddNodeFromSearch("TypeOf");
43+
// CreateFunc now has a bool result by default, so use a compatible root-scope
44+
// output to exercise automatic capture across the lambda boundary.
45+
await HomePage.SearchForNodes("And");
46+
await HomePage.AddNodeFromSearch("And");
4547
var sourcePort = Page
46-
.Locator("[data-test-id='graph-node'][data-test-node-name='TypeOf']")
48+
.Locator("[data-test-id='graph-node'][data-test-node-name='And']")
4749
.Last
4850
.Locator(".col.output")
49-
.Filter(new() { HasText = "Type" })
51+
.Filter(new() { HasText = "c" })
5052
.Locator(".diagram-port")
5153
.First;
5254
var resultPort = rebuiltRegion

src/NodeDev.Tests/GraphPortModelTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void MinimumSizeGroup_KeepsWorkspaceWhileChildrenMoveInsideIt()
5555

5656
child.SetPosition(520, 250);
5757

58-
Assert.Equal(710, group.Size.Width);
58+
Assert.Equal(520 + 100 + (double)LambdaGroupModel.FuncPadding, group.Size.Width);
5959
Assert.Equal(420, group.Size.Height);
6060
}
6161

src/NodeDev.Tests/LambdaRegionTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ namespace NodeDev.Tests;
99

1010
public class LambdaRegionTests
1111
{
12+
[Fact]
13+
public void CreateFunc_DefaultsResultTypeToBool()
14+
{
15+
var (_, method, _) = CreateMethod<int>("Run");
16+
var graph = method.Graph;
17+
var func = AddDelegate<CreateFuncNode>(graph);
18+
var lambdaReturn = Assert.Single(graph.GetNodesInScope(func.BodyScopeId).OfType<LambdaReturnNode>());
19+
20+
Assert.Equal(graph.Project.TypeFactory.Get<bool>(), func.ResultType);
21+
Assert.Equal(typeof(Func<bool>), func.DelegateType.MakeRealType());
22+
Assert.Equal(func.ResultType, lambdaReturn.ResultInput.Type);
23+
}
24+
1225
[Fact]
1326
public void CreateFunc_CreatesScopedEntryAndReturn_AndProjectsSignature()
1427
{

0 commit comments

Comments
 (0)