62 lines
2 KiB
Dart
62 lines
2 KiB
Dart
|
|
import 'package:flutter_test/flutter_test.dart';
|
||
|
|
import 'package:halkyon_app/halkyon_app.dart';
|
||
|
|
import 'package:halkyon_app/testing.dart';
|
||
|
|
import 'package:halkyon_ui/halkyon_ui.dart';
|
||
|
|
import 'package:material_ui/material_ui.dart';
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
/// Shows [profile] for someone signed in.
|
||
|
|
Future<void> show(WidgetTester tester, HalkyonProfile profile) async {
|
||
|
|
tester.view.physicalSize = const Size(1000, 1800);
|
||
|
|
tester.view.devicePixelRatio = 1;
|
||
|
|
addTearDown(tester.view.reset);
|
||
|
|
await tester.pumpWidget(
|
||
|
|
testApp(profile, dependencies: TestAppDependencies()),
|
||
|
|
);
|
||
|
|
await tester.pumpAndSettle();
|
||
|
|
}
|
||
|
|
|
||
|
|
testWidgets("the person's own tab first: the account and how they sign "
|
||
|
|
"in, the app's sections, then the public profile", (tester) async {
|
||
|
|
await show(
|
||
|
|
tester,
|
||
|
|
const HalkyonProfile(sections: [Text('Inbox of the app')]),
|
||
|
|
);
|
||
|
|
|
||
|
|
expect(find.widgetWithText(AppBar, 'Profile'), findsOneWidget);
|
||
|
|
expect(find.text('Account'), findsOneWidget);
|
||
|
|
expect(find.text('Ways to sign in'), findsOneWidget);
|
||
|
|
expect(
|
||
|
|
tester.getTopLeft(find.text('Ways to sign in')).dy,
|
||
|
|
lessThan(tester.getTopLeft(find.text('Inbox of the app')).dy),
|
||
|
|
);
|
||
|
|
expect(
|
||
|
|
tester.getTopLeft(find.text('Inbox of the app')).dy,
|
||
|
|
lessThan(tester.getTopLeft(find.text('Public profile')).dy),
|
||
|
|
);
|
||
|
|
// With no tabs of the app's, no tab row.
|
||
|
|
expect(find.byType(FoldingTabs), findsNothing);
|
||
|
|
});
|
||
|
|
|
||
|
|
testWidgets("the app's tabs follow the person's own, which folds with "
|
||
|
|
'them', (tester) async {
|
||
|
|
await show(
|
||
|
|
tester,
|
||
|
|
const HalkyonProfile(
|
||
|
|
tabs: [FoldingTab(label: 'Statistics', body: Text('Charts'))],
|
||
|
|
),
|
||
|
|
);
|
||
|
|
|
||
|
|
expect(
|
||
|
|
[
|
||
|
|
for (final tab in tester.widgetList<Tab>(find.byType(Tab))) tab.text,
|
||
|
|
],
|
||
|
|
['Profile', 'Statistics'],
|
||
|
|
);
|
||
|
|
expect(find.text('Public profile'), findsOneWidget);
|
||
|
|
|
||
|
|
await tester.tap(find.widgetWithText(Tab, 'Statistics'));
|
||
|
|
await tester.pumpAndSettle();
|
||
|
|
expect(find.text('Charts'), findsOneWidget);
|
||
|
|
});
|
||
|
|
}
|