Add overview page for the trophies

This commit is contained in:
Roland Geider
2025-12-20 19:53:55 +01:00
parent 9e4897f516
commit 36a3e7ef4a
18 changed files with 387 additions and 188 deletions

View File

@@ -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(

View File

@@ -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',
),
];
}

View File

@@ -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.

View 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);
});
});
}