// In-place help widgets + the satellite dialog that consumes them. // The pattern (usertest): explain a surface where it happens — // an intro strip saying what this is and what will happen, plus a // per-field "?" for the details. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:chain_studio/l10n/app_localizations.dart'; import 'package:chain_studio/pages/federation.dart'; import 'package:chain_studio/widgets/chain_field_help.dart'; import 'support/fake_hub.dart'; Widget _host(Widget child) => MaterialApp( localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, locale: const Locale('de'), home: Scaffold(body: child), ); void main() { testWidgets('ChainInlineHelp shows the text and fires Learn more', ( tester, ) async { var learned = false; await tester.pumpWidget( _host( ChainInlineHelp( text: 'Ein Satellit ist ein weiterer Hub.', onLearnMore: () => learned = true, learnMoreLabel: 'Mehr erfahren', ), ), ); expect(find.text('Ein Satellit ist ein weiterer Hub.'), findsOneWidget); await tester.tap(find.text('Mehr erfahren')); expect(learned, isTrue); }); testWidgets('ChainInlineHelp hides Learn more when no callback', ( tester, ) async { await tester.pumpWidget( _host(const ChainInlineHelp(text: 'Nur Text, kein Link.')), ); expect(find.text('Nur Text, kein Link.'), findsOneWidget); expect(find.byIcon(Icons.arrow_forward), findsNothing); }); testWidgets('ChainFieldHelp tap reveals the tooltip message', (tester) async { await tester.pumpWidget( _host( const ChainFieldLabel( label: 'Satelliten-Name', help: 'Frei wählbarer Anzeigename.', ), ), ); // The help text is not shown until the affordance is used. expect(find.text('Frei wählbarer Anzeigename.'), findsNothing); await tester.tap(find.byIcon(Icons.help_outline)); await tester.pump(const Duration(milliseconds: 400)); expect(find.text('Frei wählbarer Anzeigename.'), findsOneWidget); }); testWidgets('Add-satellite dialog explains what a satellite is', ( tester, ) async { SharedPreferences.setMockInitialValues({}); installFakeHub(); await tester.pumpWidget(_host(const FederationPage())); await tester.pump(const Duration(milliseconds: 200)); // Open the add flow via the AppBar action (the label also // appears in the empty-state CTA; either opens the dialog). await tester.tap(find.text('Satellit hinzufügen').first); await tester.pumpAndSettle(); // The intro strip + its Learn-more link are present BEFORE any // input is asked for — no more bare "name" field. expect(find.textContaining('Ein Satellit ist ein weiterer Hub'), findsOneWidget); expect(find.text('Mehr erfahren'), findsOneWidget); // Field-level "?" is wired too. expect(find.byType(ChainFieldHelp), findsWidgets); }); }