Skip to content

Commit

Permalink
[ADD] Rent UT
Browse files Browse the repository at this point in the history
  • Loading branch information
tbellicha committed Nov 21, 2024
1 parent cf990e8 commit ab59c61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions Application/mobile/app_code/lib/pages/rent/rent_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ class RentArticlePageState extends State<RentArticlePage> {
/// This function shows an alert dialog to confirm the rent.
void confirmRent() async {
await MyAlertDialog.showChoiceAlertDialog(
key: const Key('alert_dialog_confirm_rent'),
context: context,
title: AppLocalizations.of(context)!.rentConfirmation,
message: AppLocalizations.of(context)!
Expand Down
13 changes: 12 additions & 1 deletion Application/mobile/app_code/test/rent_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:risu/globals.dart';
import 'package:risu/pages/article/article_list_data.dart';
import 'package:risu/pages/rent/rent_page.dart';

Expand All @@ -9,6 +10,7 @@ import 'globals.dart';
void main() {
group('Test RentArticlePage', () {
testWidgets('Rent Article Page UI', (WidgetTester tester) async {
userInformation = initExampleUser();
await tester.pumpWidget(
initPage(
RentArticlePage(
Expand Down Expand Up @@ -60,7 +62,16 @@ void main() {
// Simulate another user interaction
await tester.scrollUntilVisible(confirmButtonFinder, 100.0);
await tester.tap(confirmButtonFinder);
await tester.pump();
await tester.pumpAndSettle();

Finder alertDialog = find.byKey(const Key('alert_dialog_confirm_rent'));
expect(alertDialog, findsOneWidget);

Finder confirmButton = find.byKey(const Key('alertdialog-button_ok'));
expect(confirmButton, findsOneWidget);

await tester.tap(confirmButton);
await tester.pumpAndSettle();
});
});
}

0 comments on commit ab59c61

Please sign in to comment.