forked from FEUP-LEIC-ES-2022-23/2LEIC14T3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings_test.dart
85 lines (67 loc) · 3.37 KB
/
settings_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:rate_it/auth/Authentication.dart';
import 'package:rate_it/model/user.dart';
import 'package:rate_it/screens/login_page.dart';
import 'package:rate_it/screens/settings-subclasses.dart';
import 'package:rate_it/screens/settings.dart';
void main() {
group('SettingsPage Tests', () {
late User mockUser;
setUp(() {
// Set up mock User data for testing
mockUser = User(
uid: "",
email: "[email protected]",
firstName: "Francisco",
lastName: "Campos",
username: "ffffffffff",
// Fill in the necessary properties for the mock user
isPrivate: true,
);
});
testWidgets('Renders with the correct title', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: SettingsPage(user: mockUser)));
// Verify that the page title is rendered correctly
expect(find.text('Settings'), findsOneWidget);
});
testWidgets('Renders the General section with a Switch', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: SettingsPage(user: mockUser)));
// Verify that the General section title is rendered correctly
expect(find.text('General'), findsOneWidget);
// Verify that the CustomListTile with a Switch is rendered
expect(find.byIcon(FontAwesomeIcons.shieldHalved), findsOneWidget);
expect(find.byType(Switch), findsOneWidget);
});
testWidgets('Renders the Edit Profile section with CustomListTiles', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: SettingsPage(user: mockUser)));
// Verify that the Edit Profile section title is rendered correctly
expect(find.text('Edit Profile'), findsOneWidget);
// Verify that the CustomListTiles for each Edit Profile option are rendered
expect(find.byIcon(FontAwesomeIcons.addressCard), findsOneWidget);
expect(find.byIcon(FontAwesomeIcons.pencil), findsOneWidget);
expect(find.byIcon(FontAwesomeIcons.phone), findsOneWidget);
});
testWidgets('Renders the Security section with CustomListTiles', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: SettingsPage(user: mockUser)));
// Verify that the Security section title is rendered correctly
expect(find.text('Security'), findsOneWidget);
// Verify that the CustomListTiles for each Security option are rendered
expect(find.byIcon(FontAwesomeIcons.envelope), findsOneWidget);
expect(find.byIcon(FontAwesomeIcons.user), findsOneWidget);
expect(find.byIcon(FontAwesomeIcons.key), findsOneWidget);
});
testWidgets('Renders the Sign out option', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: SettingsPage(user: mockUser)));
// Verify that the Sign out option is rendered correctly
expect(find.byIcon(FontAwesomeIcons.arrowRightFromBracket), findsOneWidget);
});
testWidgets('Tapping on the Sign out option triggers the logout process', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: SettingsPage(user: mockUser)));
// Tap on the Sign out option
await tester.tap(find.byIcon(FontAwesomeIcons.arrowRightFromBracket));
await tester.pumpAndSettle();
});
});
}