Some checks failed
Security / Security check (push) Failing after 2s
New ChainInlineHelp (intro strip: what this is + what will happen, with an optional 'Learn more' into the doc sheet) and ChainFieldHelp / ChainFieldLabel (a '?' affordance per field). First applied to the add-satellite dialog, which asked for a bare 'name' with no hint of what a satellite is or does (usertest): it now leads with a plain explanation + a federation 'Learn more', and the name field carries a '?'. Both widgets are quiet by design. Verified: field_help_test covers the widgets + that the dialog explains itself; dialog_shots_test.dart (a reusable headed dialog-capture harness) proved the layout in light + dark. Studio 0.76.0. Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
89 lines
3.1 KiB
Dart
89 lines
3.1 KiB
Dart
// 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);
|
|
});
|
|
}
|