// Surface-level tests for the diagnostic-strip Fix dialog // support. The dialog itself is a private widget; this file // exercises the controller-side API the dialog reads (issues, // fixesFor, analyzerErrorCount, AnalyzerStrings) so a future // regression on the data flow surfaces in CI. import 'package:chain_studio_flow_editor/src/flow_yaml_controller.dart'; import 'package:chain_studio_flow_editor/src/l10n.dart'; import 'package:chain_studio_flow_editor/src/quick_fix.dart'; import 'package:flutter_code_editor/flutter_code_editor.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { group('FlowYamlCodeController quick-fix exposure', () { test('fixesFor returns the analyzer-attached list', () async { final c = FlowYamlCodeController( availableCapabilities: () => const ['debug.echo'], storeCapabilities: () => const ['text.classify'], ); addTearDown(c.dispose); c.fullText = ''' name: hello steps: - id: c use: text.classify@^1 '''; // Wait for the analyzer's debounce. await Future.delayed(const Duration(milliseconds: 700)); final issues = c.analysisResult.issues; expect( issues, isNotEmpty, reason: 'analyzer should flag the unknown capability', ); final fixes = c.fixesFor(issues.first); expect(fixes, hasLength(1)); expect(fixes.first, isA()); }); test('analyzerErrorCount tracks error severity', () async { final c = FlowYamlCodeController( availableCapabilities: () => const ['debug.echo'], ); addTearDown(c.dispose); expect(c.analysisResult.issues, isEmpty); c.fullText = ''' steps: - id: x use: nope@^1 '''; await Future.delayed(const Duration(milliseconds: 700)); final errors = c.analysisResult.issues .where((i) => i.type == IssueType.error) .length; expect(errors, greaterThan(0)); }); test('AnalyzerStrings.english produces the expected fix labels', () { final strings = AnalyzerStrings.english; expect(strings.fixInstallCap('text.echo'), 'Install text.echo'); expect(strings.fixAddSource('text.echo'), 'Add source for text.echo…'); expect(strings.fixChangeTo('bytes'), 'Change to "bytes"'); expect(strings.fixUseInstead('text.echo@^0.1'), 'Use "text.echo@^0.1"'); }); }); }