test functional and working all tests passed

main
Oeyuu 2024-06-19 11:58:49 +02:00
parent fd1536ddd9
commit f6a5108759
1 changed files with 50 additions and 8 deletions

View File

@ -19,15 +19,22 @@ void main() {
expect(find.byType(PlayerRegistry), findsOneWidget); expect(find.byType(PlayerRegistry), findsOneWidget);
// Add players // Add players
for (int i = 0; i < 6; i++) { for (int i = 1; i <= 6; i++) {
await tester.enterText(find.byType(TextField), 'Player $i'); // Find the TextField, enter text, and simulate the 'done' action on the keyboard
await tester.tap(find.byType(TextField).first);
await tester.enterText(find.byType(TextField).first, 'Player $i');
await tester.testTextInput.receiveAction(TextInputAction.done); await tester.testTextInput.receiveAction(TextInputAction.done);
// Wait for the UI to settle before proceeding
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Debug print to check entered text
debugPrint('Entered Player $i');
} }
// Ensure all players are added // Ensure all players are added
for (int i = 0; i < 6; i++) { for (int i = 1; i <= 6; i++) {
expect(find.text('Player $i'), findsOneWidget); expect(find.text('Player $i'), findsOneWidget);
// Debug print to confirm text presence
debugPrint('Confirmed Player $i is present');
} }
// Navigate to GameSettings screen // Navigate to GameSettings screen
@ -49,10 +56,39 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(FlipingCard), findsOneWidget); expect(find.byType(FlipingCard), findsOneWidget);
// Track player roles
Map<String, String> playerRoles = {};
// Flip through all players // Flip through all players
for (int i = 0; i < 6; i++) { for (int i = 1; i <= 5; i++) {
await tester.tap(find.text('Klick um deine Rolle zu sehen!')); await tester.tap(find.text('Klick um deine Rolle zu sehen!'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Debug print to check the UI and role text
tester.allWidgets.forEach((widget) {
if (widget is Text) {
debugPrint('Text widget: ${widget.data}');
}
});
// Assuming the role is displayed somewhere we can read
// Adjust the role extraction to how your app displays the role
String role = tester
.widgetList<Text>(find.byType(Text))
.map((e) => e.data!)
.firstWhere(
(text) =>
text.contains('Dorfbewohner') ||
text.contains('Werwolf') ||
text.contains('Joker'),
orElse: () => 'Unknown');
if (role == 'Unknown') {
throw StateError('No valid role found for Player $i');
}
playerRoles['Player $i'] = role;
await tester.tap(find.text('Nächster Spieler')); await tester.tap(find.text('Nächster Spieler'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
@ -62,15 +98,21 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(PlayerGridView), findsOneWidget); expect(find.byType(PlayerGridView), findsOneWidget);
// Tap to kill a player // Find a player who is not a Werewolf to kill
await tester.tap(find.text('Player 0')); String playerToKill = playerRoles.entries
.firstWhere((entry) => entry.value != 'Werwolf')
.key;
// Tap to kill a non-Werewolf player
await tester.tap(find.text(playerToKill));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byIcon(Icons.close), findsOneWidget); expect(find.byIcon(Icons.close), findsOneWidget);
expect(find.byIcon(Icons.wb_sunny), findsOneWidget);
// Skip phase // Skip phase
await tester.tap(find.text('Tag skippen')); await tester.tap(find.byType(ElevatedButton).first);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Nacht skippen'), findsOneWidget); expect(find.byIcon(Icons.nights_stay), findsOneWidget);
}); });
}); });
} }