mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Add overview page for the trophies
This commit is contained in:
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2025 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Mocks generated by Mockito 5.4.6 from annotations
|
||||
// in wger/test/core/validators_test.dart.
|
||||
// Do not manually edit this file.
|
||||
@@ -785,6 +767,17 @@ class MockAppLocalizations extends _i1.Mock implements _i2.AppLocalizations {
|
||||
)
|
||||
as String);
|
||||
|
||||
@override
|
||||
String get trophies =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#trophies),
|
||||
returnValue: _i3.dummyValue<String>(
|
||||
this,
|
||||
Invocation.getter(#trophies),
|
||||
),
|
||||
)
|
||||
as String);
|
||||
|
||||
@override
|
||||
String get routines =>
|
||||
(super.noSuchMethod(
|
||||
|
||||
@@ -58,6 +58,15 @@ List<UserTrophyProgression> getUserTrophyProgression() {
|
||||
targetValue: null,
|
||||
progressDisplay: null,
|
||||
),
|
||||
UserTrophyProgression(
|
||||
trophy: trophies[1],
|
||||
progress: 40,
|
||||
isEarned: false,
|
||||
earnedAt: null,
|
||||
currentValue: 12,
|
||||
targetValue: 30,
|
||||
progressDisplay: '12 / 30',
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2025 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Mocks generated by Mockito 5.4.6 from annotations
|
||||
// in wger/test/trophies/provider/trophies_provider_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
60
test/trophies/widgets/trophies_overview_test.dart
Normal file
60
test/trophies/widgets/trophies_overview_test.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2025 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:network_image_mock/network_image_mock.dart';
|
||||
import 'package:wger/providers/trophies.dart';
|
||||
import 'package:wger/widgets/trophies/trophies_overview.dart';
|
||||
|
||||
import '../../test_data/trophies.dart';
|
||||
import 'dashboard_trophies_widget_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([TrophyRepository])
|
||||
void main() {
|
||||
testWidgets('TrophiesOverview shows trophies', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
final mockRepository = MockTrophyRepository();
|
||||
when(mockRepository.fetchProgression()).thenAnswer((_) async => getUserTrophyProgression());
|
||||
|
||||
// Act
|
||||
await mockNetworkImagesFor(() async {
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
trophyRepositoryProvider.overrideWithValue(mockRepository),
|
||||
],
|
||||
child: const MaterialApp(
|
||||
home: Scaffold(body: TrophiesOverview()),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Assert
|
||||
expect(find.text('New Year, New Me'), findsOneWidget);
|
||||
expect(find.text('Work out on January 1st'), findsOneWidget);
|
||||
|
||||
expect(find.text('Unstoppable'), findsOneWidget);
|
||||
expect(find.text('Maintain a 30-day workout streak'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user