todo-app/test/motion/motion_tokens_test.dart
Krzysztof kuhy Rudnicki 3a747c2e51
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
file-length / file length <= 250 lines (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
release-apk / release (APK) (push) Has been cancelled
repo-contract / repo contract (push) Has been cancelled
Report errors and slow waits to the board
crdt_sync_flutter 0.9.0's installAppErrors in main(): uncaught errors and
every spinner shown over 1 s (WaitWatch: sync.run, mirror.test) upload to
RTDB /todo/errors/<device> with the versionCode, where the PC app-errors
ingest files board tickets (kuhyx/utils DOCS-app-errors.md).

The app moves to material_ui first: sync_settings_ui 0.8.x and
design_system 0.4.x sit on it, and Flutter 3.50 deprecates
flutter/material. Pins: crdt_sync 0.14.1, csf 0.9.0, ssui 0.8.3,
gda 0.5.1, design_system 0.4.1, image 4.13.1, mcp_dart 2.4.4.
file_picker stays 13.3.3, held by data_transfer_flutter 0.2.2
(allowlisted, self-clearing).

appRoute takes a route name so each report names its screen; the
release build passes APP_BUILD/APP_VERSION. Nothing new on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 23:07:58 +01:00

93 lines
3.0 KiB
Dart

import 'dart:async';
import 'dart:io';
import 'package:design_system/design_system.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:todo/ui/app_route.dart';
import '../note_editor_harness.dart';
import 'motion_harness.dart';
double _barValue(WidgetTester tester) => tester
.widget<LinearProgressIndicator>(find.byType(LinearProgressIndicator))
.value!;
Future<Route<void>> _pushPage(WidgetTester tester) async {
late BuildContext ctx;
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (c) {
ctx = c;
return const Scaffold(body: Text('home'));
},
),
),
);
final route = appRoute<void>(ctx, (_) => const Scaffold(body: Text('page')));
unawaited(Navigator.of(ctx).push<void>(route));
await tester.pump();
return route;
}
void main() {
test('every page route goes through appRoute', () {
final offenders = <String>[];
for (final f in Directory('lib').listSync(recursive: true)) {
if (f is! File || !f.path.endsWith('.dart')) continue;
if (f.path.endsWith('ui/app_route.dart')) continue;
if (f.readAsStringSync().contains('MaterialPageRoute(')) {
offenders.add(f.path);
}
}
expect(offenders, isEmpty);
});
testWidgets('a pushed page is instant: no fade or slide', (tester) async {
final route = await _pushPage(tester) as PageRoute<void>;
expect(route.transitionDuration, Duration.zero);
expect(route.reverseTransitionDuration, Duration.zero);
// Fully visible and covering the old page after a single pump.
expect(find.text('home'), findsNothing);
expect(find.text('page'), findsOneWidget);
final page = find.ancestor(
of: find.text('page'),
matching: find.byType(FadeTransition),
);
for (final f in tester.widgetList<FadeTransition>(page)) {
expect(f.opacity.value, 1);
}
});
testWidgets('remove-animations: the page is there at once', (tester) async {
disableAnimations(tester);
await _pushPage(tester);
await tester.pump(const Duration(milliseconds: 1));
expect(find.text('home'), findsNothing);
expect(find.text('page'), findsOneWidget);
});
testWidgets('wizard progress bar animates between steps', (tester) async {
await pumpEditor(tester, initialTemplate: spec);
final total = spec.sections.length;
expect(_barValue(tester), closeTo(1 / total, 1e-9));
await tester.tap(find.bySemanticsLabel('Next'));
await tester.pump();
await tester.pump(AppDuration.base ~/ 2);
expect(_barValue(tester), inExclusiveRange(1 / total, 2 / total));
await tester.pump(AppDuration.base);
expect(_barValue(tester), closeTo(2 / total, 1e-9));
});
testWidgets('remove-animations: the progress bar jumps', (tester) async {
disableAnimations(tester);
await pumpEditor(tester, initialTemplate: spec);
await tester.tap(find.bySemanticsLabel('Next'));
await tester.pump();
expect(_barValue(tester), closeTo(2 / spec.sections.length, 1e-9));
});
}