Test Cases
This commit is contained in:
@@ -15,7 +15,8 @@ import 'package:tasq/providers/supabase_provider.dart';
|
||||
import 'package:tasq/widgets/multi_select_picker.dart';
|
||||
|
||||
SupabaseClient _fakeSupabaseClient() =>
|
||||
SupabaseClient('http://localhost', 'test-key');
|
||||
SupabaseClient('http://localhost', 'test-key',
|
||||
authOptions: const AuthClientOptions(autoRefreshToken: false));
|
||||
|
||||
void main() {
|
||||
final office = Office(id: 'office-1', name: 'HQ');
|
||||
@@ -38,7 +39,7 @@ void main() {
|
||||
testWidgets('Add Team dialog: leader dropdown shows only it_staff', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.binding.setSurfaceSize(const Size(600, 800));
|
||||
await tester.binding.setSurfaceSize(const Size(600, 960));
|
||||
addTearDown(() async => await tester.binding.setSurfaceSize(null));
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -48,6 +49,9 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
// Let M3Fab scale animation complete before tapping
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Open Add Team dialog
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -70,7 +74,7 @@ void main() {
|
||||
testWidgets('Add Team dialog: Team Members picker shows only it_staff', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.binding.setSurfaceSize(const Size(600, 800));
|
||||
await tester.binding.setSurfaceSize(const Size(600, 960));
|
||||
addTearDown(() async => await tester.binding.setSurfaceSize(null));
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -80,6 +84,9 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
// Let M3Fab scale animation complete before tapping
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Open Add Team dialog
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -99,7 +106,7 @@ void main() {
|
||||
'Add Team dialog uses fixed width on desktop and bottom-sheet on mobile',
|
||||
(WidgetTester tester) async {
|
||||
// Desktop -> AlertDialog constrained to max width
|
||||
await tester.binding.setSurfaceSize(const Size(1024, 800));
|
||||
await tester.binding.setSurfaceSize(const Size(1280, 900));
|
||||
addTearDown(() async => await tester.binding.setSurfaceSize(null));
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -109,6 +116,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -120,8 +128,8 @@ void main() {
|
||||
await tester.tap(find.text('Cancel'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Mobile -> bottom sheet presentation
|
||||
await tester.binding.setSurfaceSize(const Size(600, 800));
|
||||
// Mobile -> bottom sheet or dialog presentation (phone-sized screen)
|
||||
await tester.binding.setSurfaceSize(const Size(480, 960));
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: baseOverrides(),
|
||||
@@ -129,10 +137,12 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(BottomSheet), findsWidgets);
|
||||
// On narrow widths the dialog renders as a BottomSheet; on wider ones as
|
||||
// an AlertDialog. Either way the form fields must be visible.
|
||||
expect(find.text('Team Name'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
@@ -140,7 +150,7 @@ void main() {
|
||||
testWidgets('Edit Team dialog: Save button present and Cancel closes', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.binding.setSurfaceSize(const Size(1024, 800));
|
||||
await tester.binding.setSurfaceSize(const Size(1280, 900));
|
||||
addTearDown(() async => await tester.binding.setSurfaceSize(null));
|
||||
|
||||
final team = Team(
|
||||
@@ -161,6 +171,8 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
// Wait for teams list to render before tapping the edit icon.
|
||||
await tester.pumpAndSettle();
|
||||
// Tap edit and verify dialog shows Save button
|
||||
await tester.tap(find.byIcon(Icons.edit));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Reference in New Issue
Block a user