Skip to content

Commit 3b02c43

Browse files
committed
chore: cleanup test cases to remove unused variables, improve expectations, and update deprecated API usage
1 parent 1e93f98 commit 3b02c43

26 files changed

Lines changed: 104 additions & 89 deletions

packages/vyuh_node_flow/test/unit/controller/editor_init_api_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ void main() {
214214
theme: NodeFlowTheme.light,
215215
portSizeResolver: (port) => const Size(10, 10),
216216
connectionHitTesterBuilder: (painter) {
217-
receivedPainterWasNotNull = painter != null;
217+
// painter is non-nullable, so this callback being invoked means we received a valid painter
218+
receivedPainterWasNotNull = true;
218219
return (connection, point) => false;
219220
},
220221
);
@@ -699,6 +700,7 @@ void main() {
699700
expect(controller.isEditorInitialized, isTrue);
700701
expect(controller.theme, equals(NodeFlowTheme.light));
701702
expect(controller.events, equals(events));
703+
expect(shapeBuilderCalled, isTrue);
702704
expect(hitTesterCalled, isTrue);
703705
expect(segmentCalculatorCalled, isTrue);
704706
});

packages/vyuh_node_flow/test/unit/editor/connections_layer_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,13 +868,11 @@ void main() {
868868

869869
group('Connection Style Builder', () {
870870
test('connectionStyleBuilder is called for each connection', () {
871-
var callCount = 0;
872871
ConnectionStyle? styleBuilder(
873872
Connection connection,
874873
Node sourceNode,
875874
Node targetNode,
876875
) {
877-
callCount++;
878876
return ConnectionStyles.bezier;
879877
}
880878

packages/vyuh_node_flow/test/unit/editor/element_scope_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ void main() {
13661366
home: Scaffold(
13671367
body: ValueListenableBuilder<int>(
13681368
valueListenable: counter,
1369-
builder: (context, _, __) {
1369+
builder: (context, _, _) {
13701370
return Center(
13711371
child: ElementScope(
13721372
onDragStart: _noOpDragStart,

packages/vyuh_node_flow/test/unit/editor/interaction_layer_test.dart

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/// - InteractionLayerPainter shouldRepaint logic
88
/// - Canvas transform application
99
/// - Edge cases and null states
10+
// ignore_for_file: deprecated_member_use
1011
@Tags(['unit'])
1112
library;
1213

@@ -1491,10 +1492,8 @@ void main() {
14911492
final startNode = controller.nodes['node-a'];
14921493
expect(startNode, isNotNull);
14931494

1494-
final isStartFromOutput = true;
1495-
final portList = isStartFromOutput
1496-
? startNode!.outputPorts
1497-
: startNode!.inputPorts;
1495+
// Starting from output - use output ports
1496+
final portList = startNode!.outputPorts;
14981497

14991498
Port? startPort;
15001499
for (final port in portList) {
@@ -1523,10 +1522,8 @@ void main() {
15231522
final startNode = controller.nodes['node-b'];
15241523
expect(startNode, isNotNull);
15251524

1526-
final isStartFromOutput = false;
1527-
final portList = isStartFromOutput
1528-
? startNode!.outputPorts
1529-
: startNode!.inputPorts;
1525+
// Starting from input - use input ports
1526+
final portList = startNode!.inputPorts;
15301527

15311528
Port? startPort;
15321529
for (final port in portList) {
@@ -1559,17 +1556,14 @@ void main() {
15591556
final controller = createTestController(nodes: [nodeA, nodeB]);
15601557

15611558
// Simulate painter logic for finding hovered port
1562-
final isStartFromOutput = true;
15631559
final targetNodeId = 'node-b';
15641560
final targetPortId = 'input-1';
15651561

15661562
final hoveredNode = controller.nodes[targetNodeId];
15671563
expect(hoveredNode, isNotNull);
15681564

1569-
// Hovered port is the opposite type of start port
1570-
final portList = isStartFromOutput
1571-
? hoveredNode!.inputPorts
1572-
: hoveredNode!.outputPorts;
1565+
// Starting from output, so hovered port should be an input
1566+
final portList = hoveredNode!.inputPorts;
15731567

15741568
Port? hoveredPort;
15751569
for (final port in portList) {
@@ -1602,17 +1596,14 @@ void main() {
16021596
final controller = createTestController(nodes: [nodeA, nodeB]);
16031597

16041598
// Simulate starting from input (node-b), hovering over output (node-a)
1605-
final isStartFromOutput = false;
16061599
final targetNodeId = 'node-a';
16071600
final targetPortId = 'output-1';
16081601

16091602
final hoveredNode = controller.nodes[targetNodeId];
16101603
expect(hoveredNode, isNotNull);
16111604

1612-
// Hovered port is the opposite type of start port (input -> output)
1613-
final portList = isStartFromOutput
1614-
? hoveredNode!.inputPorts
1615-
: hoveredNode!.outputPorts;
1605+
// Starting from input, so hovered port should be an output
1606+
final portList = hoveredNode!.outputPorts;
16161607

16171608
Port? hoveredPort;
16181609
for (final port in portList) {

packages/vyuh_node_flow/test/unit/effects/gradient_particle_effects_test.dart

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,12 @@ void main() {
371371
effect.paint(canvas, path, basePaint, 0.5);
372372

373373
// With 0 opacity, base path should not be drawn
374-
// Only gradient segment should be drawn
375-
final pathOps = canvas.operations.whereType<DrawPathOperation>();
376-
for (final op in pathOps) {
377-
// Any visible paths should have shader (gradient) or be the gradient segment
378-
// The base path with 0 opacity should not be drawn
379-
}
380-
expect(canvas.operations, isNotEmpty);
374+
// Only gradient segment should be drawn - verify we have path operations
375+
expect(
376+
canvas.operations.whereType<DrawPathOperation>(),
377+
isNotEmpty,
378+
reason: 'Gradient segment should still be drawn',
379+
);
381380
});
382381

383382
test('connectionOpacity 1 shows full base connection', () {
@@ -871,7 +870,10 @@ void main() {
871870
.whereType<DrawCircleOperation>()
872871
.toList();
873872
// Compare Color values (MaterialColor wraps a Color)
874-
expect(circleOps[0].paint.color.value, equals(Colors.red.value));
873+
expect(
874+
circleOps[0].paint.color.toARGB32(),
875+
equals(Colors.red.toARGB32()),
876+
);
875877
});
876878

877879
test('uses base paint color when no custom color', () {
@@ -889,7 +891,10 @@ void main() {
889891
.whereType<DrawCircleOperation>()
890892
.toList();
891893
// Compare Color values (MaterialColor wraps a Color)
892-
expect(circleOps[0].paint.color.value, equals(Colors.green.value));
894+
expect(
895+
circleOps[0].paint.color.toARGB32(),
896+
equals(Colors.green.toARGB32()),
897+
);
893898
});
894899

895900
test('circle particle size is correct', () {
@@ -977,7 +982,10 @@ void main() {
977982
.toList();
978983
// Last path op should be the arrow
979984
// Compare Color values (MaterialColor wraps a Color)
980-
expect(pathOps.last.paint.color.value, equals(Colors.purple.value));
985+
expect(
986+
pathOps.last.paint.color.toARGB32(),
987+
equals(Colors.purple.toARGB32()),
988+
);
981989
});
982990

983991
test('arrow particle size reflects dimensions', () {

packages/vyuh_node_flow/test/unit/effects/pulse_effect_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ void main() {
332332
});
333333

334334
test('pulse calculation is mathematically correct', () {
335-
final effect = PulseEffect(minOpacity: 0.0, maxOpacity: 1.0);
335+
// This test verifies the math used in PulseEffect for calculating pulse progress
336+
// The effect uses: pulseProgress = (sin(animationValue * 2 * pi) + 1) / 2
336337

337338
// pulseProgress at animationValue 0:
338339
// (sin(0) + 1) / 2 = (0 + 1) / 2 = 0.5

packages/vyuh_node_flow/test/unit/events/node_flow_events_test.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,9 @@ void main() {
601601

602602
group('Events Integration', () {
603603
test('controller setEvents applies events correctly', () {
604-
Node<String>? tappedNode;
604+
var tapCount = 0;
605605
void onTap(Node<String> node) {
606-
tappedNode = node;
606+
tapCount++;
607607
}
608608

609609
final controller = createTestController();
@@ -612,6 +612,10 @@ void main() {
612612
);
613613

614614
expect(controller.events.node?.onTap, isNotNull);
615+
// Verify the callback is wired correctly by invoking it
616+
final testNode = createTestNode(id: 'test');
617+
controller.events.node?.onTap?.call(testNode);
618+
expect(tapCount, equals(1));
615619
});
616620

617621
test('node events fire correctly', () {

packages/vyuh_node_flow/test/unit/extensions/debug_overlays_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/// - SpatialIndexDebugPainter properties and shouldRepaint logic
66
/// - AutopanZoneDebugLayer construction and conditional rendering
77
/// - DebugTheme integration with painters
8+
// ignore_for_file: deprecated_member_use
89
@Tags(['unit'])
910
library;
1011

packages/vyuh_node_flow/test/unit/extensions/minimap_widget_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ void main() {
272272

273273
await tester.pumpAndSettle();
274274

275-
final initialViewport = controller.viewport;
276-
277275
// Tap on the minimap
278276
await tester.tap(find.byType(NodeFlowMinimap<String>));
279277
await tester.pumpAndSettle();

packages/vyuh_node_flow/test/unit/graph/graph_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,8 @@ void main() {
796796
final groupNodes = mixedGraph.getGroupNodes();
797797

798798
expect(groupNodes.length, equals(2));
799-
expect(groupNodes.every((n) => n is GroupNode<String>), isTrue);
799+
// getGroupNodes returns List<GroupNode<T>>, so all elements are GroupNodes
800+
expect(groupNodes, everyElement(isA<GroupNode<String>>()));
800801
expect(
801802
groupNodes.map((n) => n.id),
802803
containsAll(['group-1', 'group-2']),
@@ -819,7 +820,8 @@ void main() {
819820
final commentNodes = mixedGraph.getCommentNodes();
820821

821822
expect(commentNodes.length, equals(1));
822-
expect(commentNodes.every((n) => n is CommentNode<String>), isTrue);
823+
// getCommentNodes returns List<CommentNode<T>>, so all elements are CommentNodes
824+
expect(commentNodes, everyElement(isA<CommentNode<String>>()));
823825
expect(commentNodes.first.id, equals('comment-1'));
824826
});
825827

0 commit comments

Comments
 (0)