|
1 | 1 | import 'package:flutter/material.dart'; |
2 | 2 | import 'package:flutter_test/flutter_test.dart'; |
| 3 | +import 'package:log_file_client/components/advanced_options_dropdown.dart'; |
3 | 4 | import 'package:log_file_client/components/chart_series_selector.dart'; |
4 | 5 | import 'package:log_file_client/components/graph_view.dart'; |
5 | 6 | import 'package:log_file_client/components/project_card.dart'; |
@@ -99,6 +100,69 @@ void main() { |
99 | 100 | expect(find.text('tank-70'), findsOneWidget); |
100 | 101 | }); |
101 | 102 |
|
| 103 | + testWidgets('Changing deviation controllers updates TankCard widgets', |
| 104 | + (WidgetTester tester) async { |
| 105 | + tester.view.physicalSize = const Size(1920, 1080); |
| 106 | + tester.view.devicePixelRatio = 1.0; |
| 107 | + await tester.pumpWidget( |
| 108 | + MaterialApp( |
| 109 | + home: ProjectPage( |
| 110 | + project: Project('ProjectA', [ |
| 111 | + Log('tank-24', 'ProjectA-tank-24.log'), |
| 112 | + ]), |
| 113 | + httpClient: HttpClientTest(), |
| 114 | + ), |
| 115 | + ), |
| 116 | + ); |
| 117 | + await tester.pumpAndSettle(); |
| 118 | + |
| 119 | + // Find the chart widgets and verify it built with default deviation values |
| 120 | + SfCartesianChart phChart = |
| 121 | + tester.widget(find.byType(SfCartesianChart).first); |
| 122 | + SfCartesianChart tempChart = |
| 123 | + tester.widget(find.byType(SfCartesianChart).last); |
| 124 | + NumericAxis phAxis = phChart.primaryYAxis as NumericAxis; |
| 125 | + NumericAxis tempAxis = tempChart.primaryYAxis as NumericAxis; |
| 126 | + expect(phAxis.minimum, closeTo(6.25 - 0.5, 0.01)); |
| 127 | + expect(phAxis.maximum, closeTo(6.25 + 0.5, 0.01)); |
| 128 | + expect(tempAxis.minimum, closeTo(21.45 - 0.5, 0.01)); |
| 129 | + expect(tempAxis.maximum, closeTo(21.45 + 0.5, 0.01)); |
| 130 | + |
| 131 | + // Click on the AdvancedOptionsDropdown to open it |
| 132 | + await tester.tap(find.byType(AdvancedOptionsDropdown).first); |
| 133 | + await tester.pumpAndSettle(); |
| 134 | + |
| 135 | + // Find the AdvancedOptionsDropdown text fields |
| 136 | + final tempField = find.byWidgetPredicate( |
| 137 | + (w) => |
| 138 | + w is TextField && |
| 139 | + w.decoration!.labelText!.toLowerCase().contains('temp deviation'), |
| 140 | + ); |
| 141 | + final phField = find.byWidgetPredicate( |
| 142 | + (w) => |
| 143 | + w is TextField && |
| 144 | + w.decoration!.labelText!.toLowerCase().contains('ph deviation'), |
| 145 | + ); |
| 146 | + |
| 147 | + expect(tempField, findsOneWidget); |
| 148 | + expect(phField, findsOneWidget); |
| 149 | + |
| 150 | + // Enter new values in the controllers |
| 151 | + await tester.enterText(phField, '2.5'); |
| 152 | + await tester.enterText(tempField, '1.2'); |
| 153 | + await tester.pumpAndSettle(); |
| 154 | + |
| 155 | + // Verify the chart rebuilt with new deviation values |
| 156 | + phChart = tester.widget(find.byType(SfCartesianChart).first); |
| 157 | + tempChart = tester.widget(find.byType(SfCartesianChart).last); |
| 158 | + phAxis = phChart.primaryYAxis as NumericAxis; |
| 159 | + tempAxis = tempChart.primaryYAxis as NumericAxis; |
| 160 | + expect(phAxis.minimum, closeTo(6.25 - 2.5, 0.01)); |
| 161 | + expect(phAxis.maximum, closeTo(6.25 + 2.5, 0.01)); |
| 162 | + expect(tempAxis.minimum, closeTo(21.45 - 1.2, 0.01)); |
| 163 | + expect(tempAxis.maximum, closeTo(21.45 + 1.2, 0.01)); |
| 164 | + }); |
| 165 | + |
102 | 166 | testWidgets('TankCards have thumbnail graphs', (WidgetTester tester) async { |
103 | 167 | // Build the ProjectPage widget |
104 | 168 | await tester.pumpWidget( |
|
0 commit comments