Skip to content

Commit

Permalink
Add more page test
Browse files Browse the repository at this point in the history
  • Loading branch information
camillebrulotte committed Sep 20, 2023
1 parent 755dcbc commit 0355b01
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
2 changes: 2 additions & 0 deletions lib/ui/views/faq_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class _FaqViewState extends State<FaqView> {
children: <Widget>[
Text(
title,
textScaleFactor: 1.0,
style: Theme.of(context).textTheme.bodyText2.copyWith(
fontSize: 20,
color: Colors.black,
Expand All @@ -179,6 +180,7 @@ class _FaqViewState extends State<FaqView> {
const SizedBox(height: 20.0),
Text(
description,
textScaleFactor: 1.0,
style: Theme.of(context).textTheme.bodyText2.copyWith(
fontSize: 16,
color: Colors.black,
Expand Down
16 changes: 7 additions & 9 deletions test/ui/views/faq_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:notredame/core/managers/settings_manager.dart';

// SERVICES
import 'package:notredame/core/services/preferences_service.dart';
import '../../mock/managers/settings_manager_mock.dart';

// MANAGERS
import 'package:notredame/core/managers/settings_manager.dart';

// VIEW
import 'package:notredame/ui/views/faq_view.dart';

Expand All @@ -18,10 +19,8 @@ import '../../helpers.dart';
// CONSTANTS
import 'package:notredame/core/constants/faq.dart';


void main() {
group('FaqView - ', () {
PreferencesService preferencesService;
AppIntl appIntl;

SettingsManager settingsManager;
Expand All @@ -37,7 +36,7 @@ void main() {
group('UI - ', () {
testWidgets('has x ElevatedButton', (WidgetTester tester) async {
SettingsManagerMock.stubLocale(settingsManager as SettingsManagerMock);

await tester.pumpWidget(localizedWidget(child: const FaqView()));
await tester.pumpAndSettle();

Expand All @@ -50,15 +49,14 @@ void main() {

testWidgets('has x IntrinsicHeight for the questions', (WidgetTester tester) async {
SettingsManagerMock.stubLocale(settingsManager as SettingsManagerMock);

await tester.pumpWidget(localizedWidget(child: const FaqView()));
await tester.pumpAndSettle();

final instrinsicHeight = find.byType(IntrinsicHeight, skipOffstage: false);

final Faq faq = Faq();
final numberOfQuestions = faq.questions.length;
expect(instrinsicHeight, findsNWidgets(numberOfQuestions));
// Seulement 3 tuiles du carousel sont affichées à la fois
expect(instrinsicHeight, findsNWidgets(3));
});

testWidgets('has 2 subtitles', (WidgetTester tester) async {
Expand Down
18 changes: 16 additions & 2 deletions test/ui/views/more_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void main() {
});

group('UI - ', () {
testWidgets('has 1 listView and 6 listTiles',
testWidgets('has 1 listView and 8 listTiles',
(WidgetTester tester) async {
await tester.pumpWidget(
localizedWidget(child: FeatureDiscovery(child: MoreView())));
Expand All @@ -58,7 +58,7 @@ void main() {
expect(listview, findsOneWidget);

final listTile = find.byType(ListTile);
expect(listTile, findsNWidgets(7));
expect(listTile, findsNWidgets(8));
});

group('navigation - ', () {
Expand Down Expand Up @@ -147,6 +147,20 @@ void main() {
expect(find.byType(AboutDialog), findsOneWidget);
});

testWidgets('need help', (WidgetTester tester) async {
await tester.pumpWidget(
localizedWidget(child: FeatureDiscovery(child: MoreView())));
await tester.pumpAndSettle(const Duration(seconds: 1));

// Tap the button.
await tester.tap(find.widgetWithText(ListTile, intl.need_help));

// Rebuild the widget after the state has changed.
await tester.pump();

verify(navigation.pushNamed(RouterPaths.faq, arguments: Colors.white)).called(1);
});

testWidgets('settings', (WidgetTester tester) async {
await tester.pumpWidget(
localizedWidget(child: FeatureDiscovery(child: MoreView())));
Expand Down

0 comments on commit 0355b01

Please sign in to comment.