mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Add a new riverpod provider for the routines
This is not a wrapper around the old one, which was making problems. Delete unneeded generated files as well.
This commit is contained in:
@@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart' as riverpod;
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/models/workouts/session.dart';
|
||||
import 'package:wger/providers/body_weight_repository.dart';
|
||||
import 'package:wger/providers/measurement.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
@@ -14,7 +13,6 @@ import 'package:wger/theme/theme.dart';
|
||||
|
||||
import '../test/exercises/contribute_exercise_test.mocks.dart';
|
||||
import '../test/measurements/measurement_categories_screen_test.mocks.dart';
|
||||
import '../test/routine/gym_mode_screen_test.mocks.dart';
|
||||
import '../test/weight/weight_provider_test.mocks.dart';
|
||||
import '../test/weight/weight_screen_test.mocks.dart' as weight;
|
||||
import '../test_data/body_weight.dart';
|
||||
@@ -25,24 +23,6 @@ import '../test_data/profile.dart';
|
||||
import '../test_data/routines.dart';
|
||||
|
||||
Widget createDashboardScreen({String locale = 'en'}) {
|
||||
final mockWorkoutProvider = MockRoutinesProvider();
|
||||
when(
|
||||
mockWorkoutProvider.routines,
|
||||
).thenReturn([getTestRoutine(exercises: getScreenshotExercises())]);
|
||||
when(
|
||||
mockWorkoutProvider.currentRoutine,
|
||||
).thenReturn(getTestRoutine(exercises: getScreenshotExercises()));
|
||||
|
||||
when(mockWorkoutProvider.sessions).thenReturn([
|
||||
WorkoutSession(
|
||||
routineId: 1,
|
||||
date: DateTime.now().add(const Duration(days: -1)),
|
||||
timeStart: const TimeOfDay(hour: 17, minute: 34),
|
||||
timeEnd: const TimeOfDay(hour: 19, minute: 3),
|
||||
impression: 3,
|
||||
),
|
||||
]);
|
||||
|
||||
final mockNutritionProvider = weight.MockNutritionPlansProvider();
|
||||
|
||||
when(
|
||||
@@ -61,18 +41,23 @@ Widget createDashboardScreen({String locale = 'en'}) {
|
||||
final mockUserProvider = MockUserProvider();
|
||||
when(mockUserProvider.profile).thenReturn(tProfile1);
|
||||
|
||||
return riverpod.ProviderScope(
|
||||
final container = riverpod.ProviderContainer.test(
|
||||
overrides: [
|
||||
bodyWeightRepositoryProvider.overrideWithValue(mockBodyWeightRepository),
|
||||
],
|
||||
);
|
||||
container.read(routinesRiverpodProvider.notifier).state = RoutinesState(
|
||||
routines: [getTestRoutine(exercises: getScreenshotExercises())],
|
||||
);
|
||||
|
||||
return riverpod.UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<UserProvider>(
|
||||
create: (context) => mockUserProvider,
|
||||
),
|
||||
ChangeNotifierProvider<RoutinesProvider>(
|
||||
create: (context) => mockWorkoutProvider,
|
||||
),
|
||||
|
||||
ChangeNotifierProvider<NutritionPlansProvider>(
|
||||
create: (context) => mockNutritionProvider,
|
||||
),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart' as riverpod;
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
@@ -13,18 +14,13 @@ import '../test_data/routines.dart';
|
||||
Widget createWorkoutDetailScreen({locale = 'en'}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
final mockRoutinesProvider = MockRoutinesProvider();
|
||||
final routine = getTestRoutine(exercises: getScreenshotExercises());
|
||||
// when(mockRoutinesProvider.activeRoutine).thenReturn(routine);
|
||||
when(mockRoutinesProvider.findById(1)).thenReturn(routine);
|
||||
// when(mockRoutinesProvider.fetchAndSetRoutineFull(1)).thenAnswer((_) => Future.value(routine));
|
||||
final container = riverpod.ProviderContainer.test();
|
||||
container.read(routinesRiverpodProvider.notifier).state = RoutinesState(
|
||||
routines: [getTestRoutine(exercises: getScreenshotExercises())],
|
||||
);
|
||||
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<RoutinesProvider>(
|
||||
create: (context) => mockRoutinesProvider,
|
||||
),
|
||||
],
|
||||
return riverpod.UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
debugShowCheckedModeBanner: false,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart' as riverpod;
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/providers/exercise_state.dart';
|
||||
import 'package:wger/providers/exercise_state_notifier.dart';
|
||||
@@ -10,50 +8,44 @@ import 'package:wger/screens/gym_mode.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
|
||||
import '../test/routine/gym_mode_screen_test.mocks.dart';
|
||||
import '../test_data/exercises.dart';
|
||||
import '../test_data/routines.dart';
|
||||
|
||||
Widget createGymModeScreen({locale = 'en'}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
final routine = getTestRoutine(exercises: getScreenshotExercises());
|
||||
final mockRoutinesProvider = MockRoutinesProvider();
|
||||
|
||||
when(mockRoutinesProvider.fetchAndSetRoutineFull(1)).thenAnswer((_) async => routine);
|
||||
when(mockRoutinesProvider.findById(1)).thenAnswer((_) => routine);
|
||||
|
||||
return riverpod.ProviderScope(
|
||||
final container = riverpod.ProviderContainer.test(
|
||||
overrides: [
|
||||
exerciseStateProvider.overrideWithValue(ExerciseState(exercises: getTestExercises())),
|
||||
],
|
||||
child: MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<RoutinesProvider>(
|
||||
create: (context) => mockRoutinesProvider,
|
||||
),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
debugShowCheckedModeBanner: false,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
navigatorKey: key,
|
||||
theme: wgerLightTheme,
|
||||
home: TextButton(
|
||||
onPressed: () => key.currentState!.push(
|
||||
MaterialPageRoute<void>(
|
||||
settings: RouteSettings(
|
||||
arguments: GymModeArguments(routine.id!, routine.days.first.id!, 1),
|
||||
),
|
||||
builder: (_) => const GymModeScreen(),
|
||||
);
|
||||
container.read(routinesRiverpodProvider.notifier).state = RoutinesState(
|
||||
routines: [getTestRoutine(exercises: getScreenshotExercises())],
|
||||
);
|
||||
|
||||
return riverpod.UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
debugShowCheckedModeBanner: false,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
navigatorKey: key,
|
||||
theme: wgerLightTheme,
|
||||
home: TextButton(
|
||||
onPressed: () => key.currentState!.push(
|
||||
MaterialPageRoute<void>(
|
||||
settings: RouteSettings(
|
||||
arguments: GymModeArguments(routine.id!, routine.days.first.id!, 1),
|
||||
),
|
||||
builder: (_) => const GymModeScreen(),
|
||||
),
|
||||
child: const SizedBox(),
|
||||
),
|
||||
routes: {
|
||||
RoutineScreen.routeName: (ctx) => const RoutineScreen(),
|
||||
},
|
||||
child: const SizedBox(),
|
||||
),
|
||||
routes: {
|
||||
RoutineScreen.routeName: (ctx) => const RoutineScreen(),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,14 +18,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:wger/database/powersync/database.dart';
|
||||
import 'package:wger/exceptions/http_exception.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/helpers/date.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/base_config.dart';
|
||||
import 'package:wger/models/workouts/day.dart';
|
||||
import 'package:wger/models/workouts/day_data.dart';
|
||||
@@ -55,64 +50,253 @@ Stream<List<RepetitionUnit>> routineRepetitionUnit(Ref ref) {
|
||||
return db.select(db.routineRepetitionUnitTable).watch();
|
||||
}
|
||||
|
||||
@riverpod
|
||||
RoutinesProvider routinesChangeNotifier(Ref ref) {
|
||||
final logger = Logger('RoutinesChangeProvider');
|
||||
logger.fine('Creating routinesChangeNotifier notifier');
|
||||
|
||||
final baseProvider = ref.read(wgerBaseProvider);
|
||||
final provider = RoutinesProvider(baseProvider);
|
||||
|
||||
ref.listen(routineWeightUnitProvider, (_, next) {
|
||||
final data = next.asData?.value;
|
||||
if (data != null && ref.mounted) {
|
||||
logger.finer('Setting ${data.length} weight units');
|
||||
provider.weightUnits = data;
|
||||
}
|
||||
class RoutinesState {
|
||||
const RoutinesState({
|
||||
this.routines = const [],
|
||||
});
|
||||
|
||||
ref.listen(routineRepetitionUnitProvider, (_, next) {
|
||||
final data = next.asData?.value;
|
||||
if (data != null && ref.mounted) {
|
||||
logger.finer('Setting ${data.length} repetition units');
|
||||
provider.repetitionUnits = data;
|
||||
final List<Routine> routines;
|
||||
|
||||
RoutinesState copyWith({
|
||||
List<Routine>? routines,
|
||||
Routine? activeRoutine,
|
||||
}) {
|
||||
return RoutinesState(
|
||||
routines: routines ?? this.routines,
|
||||
);
|
||||
}
|
||||
|
||||
/// Return all sessions from all routines
|
||||
List<WorkoutSession> get sessions {
|
||||
if (routines.isNotEmpty) {
|
||||
return routines.expand((routine) => routine.sessions).toList();
|
||||
}
|
||||
});
|
||||
|
||||
ref.listen(exercisesProvider, (_, next) {
|
||||
final data = next.asData?.value;
|
||||
if (data != null) {
|
||||
logger.finer('Setting ${data.length} exercises');
|
||||
provider.exercises = data;
|
||||
}
|
||||
});
|
||||
|
||||
ref.listen(workoutSessionProvider, (_, next) {
|
||||
final data = next.asData?.value;
|
||||
if (data != null && ref.mounted) {
|
||||
logger.finer('Setting ${data.length} sessions');
|
||||
provider.sessions = data;
|
||||
}
|
||||
});
|
||||
|
||||
ref.listen(workoutLogProvider, (_, next) {
|
||||
final data = next.asData?.value;
|
||||
if (data != null && ref.mounted) {
|
||||
logger.finer('Setting ${data.length} logs');
|
||||
|
||||
// Merge logs into sessions, matching by date (no time component)
|
||||
for (final session in provider.sessions) {
|
||||
session.logs = data.where((log) => session.date.isSameDayAs(log.date)).toList();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return provider;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
class RoutinesProvider with ChangeNotifier {
|
||||
final _logger = Logger('RoutinesProvider');
|
||||
@Riverpod(keepAlive: true)
|
||||
class RoutinesRiverpod extends _$RoutinesRiverpod {
|
||||
final _logger = Logger('RoutinesRiverpod');
|
||||
|
||||
@override
|
||||
RoutinesState build() {
|
||||
_logger.fine('Building Routines Riverpod notifier');
|
||||
return const RoutinesState();
|
||||
}
|
||||
|
||||
Routine findById(int id) {
|
||||
return state.routines.firstWhere((routine) => routine.id == id);
|
||||
// return state.routines.firstWhereOrNull((routine) => routine.id == id);
|
||||
}
|
||||
|
||||
/// Returns the current active routine. At the moment this is just
|
||||
/// the latest, but this might change in the future.
|
||||
Routine? get currentRoutine {
|
||||
if (state.routines.isNotEmpty) {
|
||||
return state.routines.first;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Routines
|
||||
*/
|
||||
Future<void> fetchAllRoutinesSparse() async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
final routines = await repo.fetchAllRoutinesSparseServer();
|
||||
state = state.copyWith(routines: routines);
|
||||
}
|
||||
|
||||
Future<Routine> addRoutine(Routine routine) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
final created = await repo.addRoutineServer(routine);
|
||||
state = state.copyWith(routines: [created, ...state.routines]);
|
||||
return created;
|
||||
}
|
||||
|
||||
Future<void> fetchAndSetRoutineFull(int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
final exercises = await ref.read(exercisesProvider.future);
|
||||
final repetitionUnits = await ref.read(routineRepetitionUnitProvider.future);
|
||||
final weightUnits = await ref.read(routineWeightUnitProvider.future);
|
||||
final sessions = await ref.read(workoutSessionProvider.future);
|
||||
final logs = await ref.read(workoutLogProvider.future);
|
||||
|
||||
final routine = await repo.fetchAndSetRoutineFullServer(routineId);
|
||||
|
||||
// Hydrate data
|
||||
Future<void> setExercisesAndUnits(List<DayData> entries) async {
|
||||
for (final entry in entries) {
|
||||
for (final slot in entry.slots) {
|
||||
for (final setConfig in slot.setConfigs) {
|
||||
final exerciseId = setConfig.exerciseId;
|
||||
setConfig.exercise = exercises.firstWhere((e) => e.id == exerciseId);
|
||||
setConfig.repetitionsUnit = repetitionUnits.firstWhere(
|
||||
(e) => e.id == setConfig.repetitionsUnitId,
|
||||
);
|
||||
setConfig.weightUnit = weightUnits.firstWhere((e) => e.id == setConfig.weightUnitId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setExercisesAndUnits(routine.dayDataGym);
|
||||
setExercisesAndUnits(routine.dayData);
|
||||
|
||||
// Update state
|
||||
final updatedRoutines = [...state.routines];
|
||||
final index = updatedRoutines.indexWhere((r) => r.id == routineId);
|
||||
if (index != -1) {
|
||||
updatedRoutines[index] = routine;
|
||||
} else {
|
||||
updatedRoutines.add(routine);
|
||||
}
|
||||
state = state.copyWith(routines: updatedRoutines);
|
||||
}
|
||||
|
||||
Future<void> deleteRoutine(int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
await repo.deleteRoutineServer(routineId);
|
||||
|
||||
final routineIndex = state.routines.indexWhere((element) => element.id == routineId);
|
||||
state.routines.removeAt(routineIndex);
|
||||
}
|
||||
|
||||
Future<void> editRoutine(Routine routine) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
final updatedRoutine = await repo.editRoutineServer(routine);
|
||||
|
||||
final updatedRoutines = [...state.routines];
|
||||
final index = updatedRoutines.indexWhere((r) => r.id == routine.id);
|
||||
if (index != -1) {
|
||||
updatedRoutines[index] = updatedRoutine;
|
||||
state = state.copyWith(routines: updatedRoutines);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Days
|
||||
*/
|
||||
Future<Day> addDay(Day day) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
final newDay = await repo.addDayServer(day);
|
||||
await repo.fetchAndSetRoutineFullServer(day.routineId);
|
||||
|
||||
return newDay;
|
||||
}
|
||||
|
||||
Future<void> editDay(Day day) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
await repo.editDayServer(day);
|
||||
await repo.fetchAndSetRoutineFullServer(day.routineId);
|
||||
}
|
||||
|
||||
Future<void> editDays(List<Day> days) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
for (final day in days) {
|
||||
await repo.editDayServer(day);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteDay(int dayId, int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
await repo.deleteDayServer(dayId);
|
||||
await repo.fetchAndSetRoutineFullServer(routineId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Slots
|
||||
*/
|
||||
Future<Slot> addSlot(Slot slot, int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
final newSlot = await repo.addSlotServer(slot);
|
||||
await repo.fetchAndSetRoutineFullServer(routineId);
|
||||
return newSlot;
|
||||
}
|
||||
|
||||
Future<void> deleteSlot(int slotId, int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
await repo.deleteSlotServer(slotId);
|
||||
await repo.fetchAndSetRoutineFullServer(routineId);
|
||||
}
|
||||
|
||||
Future<void> editSlot(Slot slot, int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
await repo.editSlotServer(slot);
|
||||
await repo.fetchAndSetRoutineFullServer(routineId);
|
||||
}
|
||||
|
||||
Future<void> editSlots(List<Slot> slots, int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
for (final slot in slots) {
|
||||
await repo.editSlotServer(slot);
|
||||
}
|
||||
|
||||
await repo.fetchAndSetRoutineFullServer(routineId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Slot entries
|
||||
*/
|
||||
Future<SlotEntry> addSlotEntry(SlotEntry entry, int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
final newEntry = await repo.addSlotEntryServer(entry);
|
||||
await repo.fetchAndSetRoutineFullServer(routineId);
|
||||
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
Future<void> deleteSlotEntry(int id, int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
await repo.deleteSlotEntryServer(id);
|
||||
|
||||
await repo.fetchAndSetRoutineFullServer(routineId);
|
||||
}
|
||||
|
||||
Future<void> editSlotEntry(SlotEntry entry, int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
await repo.editSlotEntryServer(entry);
|
||||
|
||||
await repo.fetchAndSetRoutineFullServer(routineId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Configs
|
||||
*/
|
||||
Future<void> editConfig(SlotEntry entry, num? value, ConfigType type, int routineId) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
await repo.handleConfigServer(entry, value, type);
|
||||
await repo.fetchAndSetRoutineFullServer(routineId);
|
||||
}
|
||||
|
||||
Future<BaseConfig> addConfig(BaseConfig config, ConfigType type) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
return repo.addConfigServer(config, type);
|
||||
}
|
||||
|
||||
Future<void> deleteConfig(int id, ConfigType type) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
await repo.deleteConfigServer(id, type);
|
||||
}
|
||||
|
||||
Future<void> handleConfig(SlotEntry entry, num? value, ConfigType type) async {
|
||||
final repo = ref.read(routinesRepositoryProvider);
|
||||
await repo.handleConfigServer(entry, value, type);
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
RoutinesRepository routinesRepository(Ref ref) {
|
||||
final baseProvider = ref.watch(wgerBaseProvider);
|
||||
return RoutinesRepository(baseProvider);
|
||||
}
|
||||
|
||||
class RoutinesRepository {
|
||||
RoutinesRepository(this._baseProvider);
|
||||
|
||||
final WgerBaseProvider _baseProvider;
|
||||
static const _routinesUrlPath = 'routine';
|
||||
static const _routinesStructureSubpath = 'structure';
|
||||
static const _routinesDateSequenceDisplaySubpath = 'date-sequence-display';
|
||||
@@ -131,421 +315,151 @@ class RoutinesProvider with ChangeNotifier {
|
||||
static const _routineConfigRestTime = 'rest-config';
|
||||
static const _routineConfigMaxRestTime = 'max-rest-config';
|
||||
|
||||
Routine? activeRoutine;
|
||||
final WgerBaseProvider baseProvider;
|
||||
List<Routine> _routines = [];
|
||||
List<Exercise> _exercises = [];
|
||||
List<WorkoutSession> _sessions = [];
|
||||
List<WeightUnit> _weightUnits = [];
|
||||
List<RepetitionUnit> _repetitionUnits = [];
|
||||
|
||||
RoutinesProvider(
|
||||
this.baseProvider, {
|
||||
List<Routine>? entries,
|
||||
List<WeightUnit>? weightUnits,
|
||||
List<RepetitionUnit>? repetitionUnits,
|
||||
List<Exercise>? exercises,
|
||||
List<WorkoutSession>? sessions,
|
||||
}) {
|
||||
_routines = entries ?? [];
|
||||
_weightUnits = weightUnits ?? [];
|
||||
_repetitionUnits = repetitionUnits ?? [];
|
||||
_exercises = exercises ?? [];
|
||||
_sessions = sessions ?? [];
|
||||
}
|
||||
|
||||
Exercise _getExerciseById(int id) {
|
||||
// if (ref != null) {
|
||||
// final exercises = ref!.read(exercisesProvider);
|
||||
// return exercises.firstWhere((element) => element.id == id);
|
||||
// }
|
||||
return _exercises.firstWhere((element) => element.id == id);
|
||||
}
|
||||
|
||||
set exercises(List<Exercise> exercises) {
|
||||
_exercises = exercises;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
set repetitionUnits(List<RepetitionUnit> units) {
|
||||
_repetitionUnits = units;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
RepetitionUnit _getRepetitionUnitById(int? id) =>
|
||||
_repetitionUnits.firstWhere((element) => element.id == id);
|
||||
|
||||
set weightUnits(List<WeightUnit> units) {
|
||||
_weightUnits = units;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
List<WeightUnit> get weightUnits {
|
||||
return [..._weightUnits];
|
||||
}
|
||||
|
||||
WeightUnit _getWeightUnitById(int? id) => _weightUnits.firstWhere((element) => element.id == id);
|
||||
|
||||
set sessions(List<WorkoutSession> sessions) {
|
||||
_logger.finer('Setting ${sessions.length} sessions');
|
||||
_sessions = sessions;
|
||||
for (final routine in _routines) {
|
||||
routine.sessions = getSessionsForRoutine(routine.id!);
|
||||
}
|
||||
}
|
||||
|
||||
List<WorkoutSession> get sessions {
|
||||
return [..._sessions];
|
||||
}
|
||||
|
||||
List<WorkoutSession> getSessionsForRoutine(int id) =>
|
||||
_sessions.where((s) => s.routineId == id).toList();
|
||||
|
||||
/// Returns the current active nutritional plan. At the moment this is just
|
||||
/// the latest, but this might change in the future.
|
||||
Routine? get currentRoutine {
|
||||
if (_routines.isNotEmpty) {
|
||||
return _routines.first;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Routine> get routines {
|
||||
return [..._routines];
|
||||
}
|
||||
|
||||
/// Clears all lists
|
||||
void clear() {
|
||||
_routines = [];
|
||||
_weightUnits = [];
|
||||
_repetitionUnits = [];
|
||||
_sessions = [];
|
||||
_exercises = [];
|
||||
}
|
||||
|
||||
List<RepetitionUnit> get repetitionUnits {
|
||||
return [..._repetitionUnits];
|
||||
}
|
||||
|
||||
List<Routine> getPlans() {
|
||||
return _routines;
|
||||
}
|
||||
|
||||
Routine findById(int id) {
|
||||
return _routines.firstWhere((routine) => routine.id == id);
|
||||
}
|
||||
|
||||
int findIndexById(int id) {
|
||||
return _routines.indexWhere((routine) => routine.id == id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Routines
|
||||
*/
|
||||
|
||||
/// Fetches and sets all workout plans fully, i.e. with all corresponding child
|
||||
/// attributes
|
||||
Future<void> fetchAndSetAllRoutinesFull() async {
|
||||
_logger.fine('Fetching all routines fully');
|
||||
final data = await baseProvider.fetchPaginated(
|
||||
baseProvider.makeUrl(
|
||||
Future<List<Routine>> fetchAllRoutinesSparseServer() async {
|
||||
final data = await _baseProvider.fetch(
|
||||
_baseProvider.makeUrl(
|
||||
_routinesUrlPath,
|
||||
query: {'ordering': '-creation_date', 'limit': API_MAX_PAGE_SIZE, 'is_template': 'false'},
|
||||
query: {'limit': '1000', 'is_template': 'false'},
|
||||
),
|
||||
);
|
||||
for (final entry in data) {
|
||||
await fetchAndSetRoutineFull(entry['id']);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
final results = data['results'] as List;
|
||||
return results.map((json) => Routine.fromJson(json)).toList();
|
||||
}
|
||||
|
||||
/// Fetches all routines sparsely, i.e. only with the data on the object itself
|
||||
/// and no child attributes
|
||||
Future<void> fetchAndSetAllRoutinesSparse() async {
|
||||
_logger.fine('Fetching all routines sparsely');
|
||||
final data = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(
|
||||
_routinesUrlPath,
|
||||
query: {'limit': API_MAX_PAGE_SIZE, 'is_template': 'false'},
|
||||
),
|
||||
);
|
||||
_routines = [];
|
||||
for (final workoutPlanData in data['results']) {
|
||||
final plan = Routine.fromJson(workoutPlanData);
|
||||
_routines.add(plan);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> setExercisesAndUnits(List<DayData> entries) async {
|
||||
for (final entry in entries) {
|
||||
for (final slot in entry.slots) {
|
||||
for (final setConfig in slot.setConfigs) {
|
||||
final exerciseId = setConfig.exerciseId;
|
||||
setConfig.exercise = _getExerciseById(exerciseId);
|
||||
setConfig.repetitionsUnit = _getRepetitionUnitById(setConfig.repetitionsUnitId);
|
||||
setConfig.weightUnit = _getWeightUnitById(setConfig.weightUnitId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Fetches a routine sparsely, i.e. only with the data on the object itself
|
||||
/// and no child attributes
|
||||
Future<Routine> fetchAndSetRoutineSparse(int planId) async {
|
||||
final fullPlanData = await baseProvider.fetch(
|
||||
baseProvider.makeUrl(_routinesUrlPath, id: planId, query: {'limit': API_MAX_PAGE_SIZE}),
|
||||
);
|
||||
final routine = Routine.fromJson(fullPlanData);
|
||||
_routines.add(routine);
|
||||
_routines.sort((a, b) => b.created.compareTo(a.created));
|
||||
|
||||
notifyListeners();
|
||||
return routine;
|
||||
}
|
||||
|
||||
/// Fetches a workout plan fully, i.e. with all corresponding child attributes
|
||||
Future<Routine> fetchAndSetRoutineFull(int routineId) async {
|
||||
Future<Routine> fetchAndSetRoutineFullServer(int routineId) async {
|
||||
// Fetch structure and computed data
|
||||
final results = await Future.wait([
|
||||
baseProvider.fetch(
|
||||
baseProvider.makeUrl(
|
||||
_baseProvider.fetch(
|
||||
_baseProvider.makeUrl(
|
||||
_routinesUrlPath,
|
||||
objectMethod: _routinesStructureSubpath,
|
||||
id: routineId,
|
||||
),
|
||||
),
|
||||
baseProvider.fetch(
|
||||
baseProvider.makeUrl(
|
||||
_baseProvider.fetch(
|
||||
_baseProvider.makeUrl(
|
||||
_routinesUrlPath,
|
||||
id: routineId,
|
||||
objectMethod: _routinesDateSequenceDisplaySubpath,
|
||||
),
|
||||
),
|
||||
baseProvider.fetch(
|
||||
baseProvider.makeUrl(
|
||||
_baseProvider.fetch(
|
||||
_baseProvider.makeUrl(
|
||||
_routinesUrlPath,
|
||||
id: routineId,
|
||||
objectMethod: _routinesDateSequenceGymSubpath,
|
||||
),
|
||||
),
|
||||
// baseProvider.fetch(
|
||||
// baseProvider.makeUrl(
|
||||
// _routinesUrlPath,
|
||||
// id: routineId,
|
||||
// objectMethod: _routinesLogsSubpath,
|
||||
// ),
|
||||
// ),
|
||||
]);
|
||||
|
||||
final routine = Routine.fromJson(results[0] as Map<String, dynamic>);
|
||||
final dayData = results[1] as List<dynamic>;
|
||||
final dayDataGym = results[2] as List<dynamic>;
|
||||
// final sessionData = results[3] as List<dynamic>;
|
||||
|
||||
/*
|
||||
* Set exercise, repetition and weight unit objects
|
||||
*
|
||||
* note that setExercisesAndUnits modifies the list in-place
|
||||
*/
|
||||
final dayDataEntriesDisplay = dayData.map((entry) => DayData.fromJson(entry)).toList();
|
||||
await setExercisesAndUnits(dayDataEntriesDisplay);
|
||||
routine.dayData = dayData.map((entry) => DayData.fromJson(entry)).toList();
|
||||
routine.dayDataGym = dayDataGym.map((entry) => DayData.fromJson(entry)).toList();
|
||||
|
||||
final dayDataEntriesGym = dayDataGym.map((entry) => DayData.fromJson(entry)).toList();
|
||||
await setExercisesAndUnits(dayDataEntriesGym);
|
||||
|
||||
// final sessionDataEntries = sessionData
|
||||
// .map((entry) => WorkoutSessionApi.fromJson(entry))
|
||||
// .toList();
|
||||
|
||||
for (final day in routine.days) {
|
||||
for (final slot in day.slots) {
|
||||
for (final slotEntry in slot.entries) {
|
||||
final exerciseId = slotEntry.exerciseId;
|
||||
slotEntry.exerciseObj = _getExerciseById(exerciseId);
|
||||
|
||||
if (slotEntry.repetitionUnitId != null) {
|
||||
slotEntry.repetitionUnitObj = _getRepetitionUnitById(slotEntry.repetitionUnitId);
|
||||
}
|
||||
|
||||
if (slotEntry.weightUnitId != null) {
|
||||
slotEntry.weightUnitObj = _getWeightUnitById(slotEntry.weightUnitId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
routine.dayData = dayDataEntriesDisplay;
|
||||
routine.dayDataGym = dayDataEntriesGym;
|
||||
|
||||
// Logs
|
||||
routine.sessions = getSessionsForRoutine(routine.id!);
|
||||
|
||||
// ... and done
|
||||
final routineIndex = _routines.indexWhere((r) => r.id == routineId);
|
||||
if (routineIndex != -1) {
|
||||
_routines[routineIndex] = routine;
|
||||
} else {
|
||||
_routines.add(routine);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
return routine;
|
||||
}
|
||||
|
||||
Future<Routine> addRoutine(Routine routine) async {
|
||||
final data = await baseProvider.post(
|
||||
Future<Routine> addRoutineServer(Routine routine) async {
|
||||
final data = await _baseProvider.post(
|
||||
routine.toJson(),
|
||||
baseProvider.makeUrl(_routinesUrlPath),
|
||||
_baseProvider.makeUrl(_routinesUrlPath),
|
||||
);
|
||||
final plan = Routine.fromJson(data);
|
||||
_routines.insert(0, plan);
|
||||
notifyListeners();
|
||||
return plan;
|
||||
return Routine.fromJson(data);
|
||||
}
|
||||
|
||||
Future<void> editRoutine(Routine routine) async {
|
||||
await baseProvider.patch(
|
||||
Future<Routine> editRoutineServer(Routine routine) async {
|
||||
await _baseProvider.patch(
|
||||
routine.toJson(),
|
||||
baseProvider.makeUrl(_routinesUrlPath, id: routine.id),
|
||||
_baseProvider.makeUrl(_routinesUrlPath, id: routine.id),
|
||||
);
|
||||
await fetchAndSetRoutineFull(routine.id!);
|
||||
return fetchAndSetRoutineFullServer(routine.id!);
|
||||
}
|
||||
|
||||
Future<void> deleteRoutine(int id) async {
|
||||
final routineIndex = _routines.indexWhere((element) => element.id == id);
|
||||
final routine = _routines[routineIndex];
|
||||
_routines.removeAt(routineIndex);
|
||||
notifyListeners();
|
||||
|
||||
final response = await baseProvider.deleteRequest(_routinesUrlPath, id);
|
||||
|
||||
if (response.statusCode >= 400) {
|
||||
_routines.insert(routineIndex, routine);
|
||||
notifyListeners();
|
||||
throw WgerHttpException(response.body);
|
||||
}
|
||||
Future<void> deleteRoutineServer(int id) async {
|
||||
await _baseProvider.deleteRequest(_routinesUrlPath, id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Days
|
||||
*/
|
||||
Future<Day> addDay(Day day) async {
|
||||
/*
|
||||
* Saves a new day instance to the DB and adds it to the given workout
|
||||
*/
|
||||
final data = await baseProvider.post(
|
||||
Future<Day> addDayServer(Day day) async {
|
||||
final data = await _baseProvider.post(
|
||||
day.toJson(),
|
||||
baseProvider.makeUrl(_daysUrlPath),
|
||||
_baseProvider.makeUrl(_daysUrlPath),
|
||||
);
|
||||
day = Day.fromJson(data);
|
||||
|
||||
fetchAndSetRoutineFull(day.routineId);
|
||||
fetchAndSetRoutineFullServer(day.routineId);
|
||||
|
||||
return day;
|
||||
}
|
||||
|
||||
Future<void> editDay(Day day) async {
|
||||
await baseProvider.patch(
|
||||
Future<void> editDayServer(Day day) async {
|
||||
await _baseProvider.patch(
|
||||
day.toJson(),
|
||||
baseProvider.makeUrl(_daysUrlPath, id: day.id),
|
||||
_baseProvider.makeUrl(_daysUrlPath, id: day.id),
|
||||
);
|
||||
|
||||
fetchAndSetRoutineFull(day.routineId);
|
||||
}
|
||||
|
||||
Future<void> editDays(List<Day> days) async {
|
||||
if (days.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (final day in days) {
|
||||
await baseProvider.patch(
|
||||
day.toJson(),
|
||||
baseProvider.makeUrl(_daysUrlPath, id: day.id),
|
||||
);
|
||||
}
|
||||
|
||||
await fetchAndSetRoutineFull(days.first.routineId);
|
||||
}
|
||||
|
||||
Future<void> deleteDay(int dayId) async {
|
||||
await baseProvider.deleteRequest(_daysUrlPath, dayId);
|
||||
final routine = _routines.firstWhere((routine) => routine.days.any((day) => day.id == dayId));
|
||||
|
||||
fetchAndSetRoutineFull(routine.id!);
|
||||
Future<void> deleteDayServer(int dayId) async {
|
||||
await _baseProvider.deleteRequest(_daysUrlPath, dayId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets
|
||||
* Slots
|
||||
*/
|
||||
Future<Slot> addSlot(Slot slot, int routineId) async {
|
||||
final data = await baseProvider.post(
|
||||
Future<Slot> addSlotServer(Slot slot) async {
|
||||
final data = await _baseProvider.post(
|
||||
slot.toJson(),
|
||||
baseProvider.makeUrl(_slotsUrlPath),
|
||||
_baseProvider.makeUrl(_slotsUrlPath),
|
||||
);
|
||||
final newSlot = Slot.fromJson(data);
|
||||
|
||||
await fetchAndSetRoutineFull(routineId);
|
||||
|
||||
return newSlot;
|
||||
}
|
||||
|
||||
Future<void> deleteSlot(int slotId, int routineId) async {
|
||||
await baseProvider.deleteRequest(_slotsUrlPath, slotId);
|
||||
|
||||
await fetchAndSetRoutineFull(routineId);
|
||||
Future<void> deleteSlotServer(int slotId) async {
|
||||
await _baseProvider.deleteRequest(_slotsUrlPath, slotId);
|
||||
}
|
||||
|
||||
Future<void> editSlot(Slot slot, int routineId) async {
|
||||
await baseProvider.patch(
|
||||
Future<void> editSlotServer(Slot slot) async {
|
||||
await _baseProvider.patch(
|
||||
slot.toJson(),
|
||||
baseProvider.makeUrl(_slotsUrlPath, id: slot.id),
|
||||
_baseProvider.makeUrl(_slotsUrlPath, id: slot.id),
|
||||
);
|
||||
|
||||
await fetchAndSetRoutineFull(routineId);
|
||||
}
|
||||
|
||||
Future<void> editSlots(List<Slot> slots, int routineId) async {
|
||||
for (final slot in slots) {
|
||||
await baseProvider.patch(
|
||||
slot.toJson(),
|
||||
baseProvider.makeUrl(_slotsUrlPath, id: slot.id),
|
||||
);
|
||||
}
|
||||
|
||||
await fetchAndSetRoutineFull(routineId);
|
||||
}
|
||||
|
||||
Future<SlotEntry> addSlotEntry(SlotEntry entry, int routineId) async {
|
||||
final data = await baseProvider.post(
|
||||
/*
|
||||
* Slot entries
|
||||
*/
|
||||
Future<SlotEntry> addSlotEntryServer(SlotEntry entry) async {
|
||||
final data = await _baseProvider.post(
|
||||
entry.toJson(),
|
||||
baseProvider.makeUrl(_slotEntriesUrlPath),
|
||||
_baseProvider.makeUrl(_slotEntriesUrlPath),
|
||||
);
|
||||
final newEntry = SlotEntry.fromJson(data);
|
||||
await fetchAndSetRoutineFull(routineId);
|
||||
|
||||
return newEntry;
|
||||
return SlotEntry.fromJson(data);
|
||||
}
|
||||
|
||||
Future<void> deleteSlotEntry(int id, int routineId) async {
|
||||
await baseProvider.deleteRequest(_slotEntriesUrlPath, id);
|
||||
|
||||
await fetchAndSetRoutineFull(routineId);
|
||||
Future<void> deleteSlotEntryServer(int id) async {
|
||||
await _baseProvider.deleteRequest(_slotEntriesUrlPath, id);
|
||||
}
|
||||
|
||||
Future<void> editSlotEntry(SlotEntry entry, int routineId) async {
|
||||
await baseProvider.patch(
|
||||
Future<void> editSlotEntryServer(SlotEntry entry) async {
|
||||
await _baseProvider.patch(
|
||||
entry.toJson(),
|
||||
baseProvider.makeUrl(_slotEntriesUrlPath, id: entry.id),
|
||||
_baseProvider.makeUrl(_slotEntriesUrlPath, id: entry.id),
|
||||
);
|
||||
|
||||
await fetchAndSetRoutineFull(routineId);
|
||||
}
|
||||
|
||||
String getConfigUrl(ConfigType type) {
|
||||
/*
|
||||
* Configs
|
||||
*/
|
||||
String _getConfigUrl(ConfigType type) {
|
||||
switch (type) {
|
||||
case ConfigType.sets:
|
||||
return _routineConfigSets;
|
||||
@@ -570,31 +484,28 @@ class RoutinesProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<BaseConfig> editConfig(BaseConfig config, ConfigType type) async {
|
||||
final data = await baseProvider.patch(
|
||||
Future<BaseConfig> editConfigServer(BaseConfig config, ConfigType type) async {
|
||||
final data = await _baseProvider.patch(
|
||||
config.toJson(),
|
||||
baseProvider.makeUrl(getConfigUrl(type), id: config.id),
|
||||
_baseProvider.makeUrl(_getConfigUrl(type), id: config.id),
|
||||
);
|
||||
|
||||
notifyListeners();
|
||||
return BaseConfig.fromJson(data);
|
||||
}
|
||||
|
||||
Future<BaseConfig> addConfig(BaseConfig config, ConfigType type) async {
|
||||
final data = await baseProvider.post(
|
||||
Future<BaseConfig> addConfigServer(BaseConfig config, ConfigType type) async {
|
||||
final data = await _baseProvider.post(
|
||||
config.toJson(),
|
||||
baseProvider.makeUrl(getConfigUrl(type)),
|
||||
_baseProvider.makeUrl(_getConfigUrl(type)),
|
||||
);
|
||||
notifyListeners();
|
||||
return BaseConfig.fromJson(data);
|
||||
}
|
||||
|
||||
Future<void> deleteConfig(int id, ConfigType type) async {
|
||||
await baseProvider.deleteRequest(getConfigUrl(type), id);
|
||||
notifyListeners();
|
||||
Future<void> deleteConfigServer(int id, ConfigType type) async {
|
||||
await _baseProvider.deleteRequest(_getConfigUrl(type), id);
|
||||
}
|
||||
|
||||
Future<void> handleConfig(SlotEntry entry, num? value, ConfigType type) async {
|
||||
Future<void> handleConfigServer(SlotEntry entry, num? value, ConfigType type) async {
|
||||
final configs = entry.getConfigsByType(type);
|
||||
final config = configs.isNotEmpty ? configs.first : null;
|
||||
// final value = input.isNotEmpty ? num.parse(input) : null;
|
||||
@@ -602,15 +513,15 @@ class RoutinesProvider with ChangeNotifier {
|
||||
if (value == null && config != null) {
|
||||
// Value removed, delete entry
|
||||
configs.removeWhere((c) => c.id! == config.id!);
|
||||
await deleteConfig(config.id!, type);
|
||||
await deleteConfigServer(config.id!, type);
|
||||
} else if (config != null) {
|
||||
// Update existing value
|
||||
configs.first.value = value!;
|
||||
await editConfig(configs.first, type);
|
||||
await editConfigServer(configs.first, type);
|
||||
} else if (value != null && config == null) {
|
||||
// Create new config
|
||||
configs.add(
|
||||
await addConfig(
|
||||
await addConfigServer(
|
||||
BaseConfig.firstIteration(value, entry.id!),
|
||||
type,
|
||||
),
|
||||
|
||||
@@ -87,43 +87,96 @@ final class RoutineRepetitionUnitProvider
|
||||
|
||||
String _$routineRepetitionUnitHash() => r'7754a0197c3fed27feea2c6d33d5e5a5e1deab45';
|
||||
|
||||
@ProviderFor(routinesChangeNotifier)
|
||||
const routinesChangeProvider = RoutinesChangeNotifierProvider._();
|
||||
@ProviderFor(RoutinesRiverpod)
|
||||
const routinesRiverpodProvider = RoutinesRiverpodProvider._();
|
||||
|
||||
final class RoutinesChangeNotifierProvider
|
||||
extends $FunctionalProvider<RoutinesProvider, RoutinesProvider, RoutinesProvider>
|
||||
with $Provider<RoutinesProvider> {
|
||||
const RoutinesChangeNotifierProvider._()
|
||||
final class RoutinesRiverpodProvider extends $NotifierProvider<RoutinesRiverpod, RoutinesState> {
|
||||
const RoutinesRiverpodProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'routinesChangeProvider',
|
||||
name: r'routinesRiverpodProvider',
|
||||
isAutoDispose: false,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$routinesRiverpodHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
RoutinesRiverpod create() => RoutinesRiverpod();
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(RoutinesState value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<RoutinesState>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$routinesRiverpodHash() => r'4071d532d776ba550c2ff0f6bc558aa9e03b2cfa';
|
||||
|
||||
abstract class _$RoutinesRiverpod extends $Notifier<RoutinesState> {
|
||||
RoutinesState build();
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build();
|
||||
final ref = this.ref as $Ref<RoutinesState, RoutinesState>;
|
||||
final element =
|
||||
ref.element
|
||||
as $ClassProviderElement<
|
||||
AnyNotifier<RoutinesState, RoutinesState>,
|
||||
RoutinesState,
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
}
|
||||
}
|
||||
|
||||
@ProviderFor(routinesRepository)
|
||||
const routinesRepositoryProvider = RoutinesRepositoryProvider._();
|
||||
|
||||
final class RoutinesRepositoryProvider
|
||||
extends $FunctionalProvider<RoutinesRepository, RoutinesRepository, RoutinesRepository>
|
||||
with $Provider<RoutinesRepository> {
|
||||
const RoutinesRepositoryProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'routinesRepositoryProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$routinesChangeNotifierHash();
|
||||
String debugGetCreateSourceHash() => _$routinesRepositoryHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$ProviderElement<RoutinesProvider> $createElement($ProviderPointer pointer) =>
|
||||
$ProviderElement(pointer);
|
||||
$ProviderElement<RoutinesRepository> $createElement(
|
||||
$ProviderPointer pointer,
|
||||
) => $ProviderElement(pointer);
|
||||
|
||||
@override
|
||||
RoutinesProvider create(Ref ref) {
|
||||
return routinesChangeNotifier(ref);
|
||||
RoutinesRepository create(Ref ref) {
|
||||
return routinesRepository(ref);
|
||||
}
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(RoutinesProvider value) {
|
||||
Override overrideWithValue(RoutinesRepository value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<RoutinesProvider>(value),
|
||||
providerOverride: $SyncValueProvider<RoutinesRepository>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$routinesChangeNotifierHash() => r'fcdf8c1101761d0cfd26fce6b169e348dcbd55cb';
|
||||
String _$routinesRepositoryHash() => r'866fede3b610fa71c3204c57ad004465f3e5e3fc';
|
||||
|
||||
@@ -81,13 +81,13 @@ class WorkoutLogRepository {
|
||||
entry.weightUnit = weightUnit;
|
||||
}
|
||||
|
||||
try {
|
||||
log.exercise = exercisesProvider.getById(log.exerciseId);
|
||||
} catch (e) {
|
||||
_logger.warning(
|
||||
'Could not find exercise for log entry ${log.id} with exercise ID ${log.exerciseId}',
|
||||
);
|
||||
}
|
||||
// try {
|
||||
// log.exercise = exercisesProvider.getById(log.exerciseId);
|
||||
// } catch (e) {
|
||||
// _logger.warning(
|
||||
// 'Could not find exercise for log entry ${log.id} with exercise ID ${log.exerciseId}',
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
||||
return map.values.toList();
|
||||
|
||||
@@ -38,7 +38,7 @@ class GymModeScreen extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final args = ModalRoute.of(context)!.settings.arguments as GymModeArguments;
|
||||
|
||||
final routineProvider = ref.read(routinesChangeProvider);
|
||||
final routineProvider = ref.read(routinesRiverpodProvider.notifier);
|
||||
final routine = routineProvider.findById(args.routineId);
|
||||
final dayDataDisplay = routine.dayData.firstWhere(
|
||||
(e) => e.iteration == args.iteration && e.day?.id == args.dayId,
|
||||
|
||||
@@ -24,13 +24,13 @@ import 'package:provider/provider.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/providers/auth.dart';
|
||||
import 'package:wger/providers/body_weight.dart';
|
||||
import 'package:wger/providers/exercise_state_notifier.dart';
|
||||
import 'package:wger/providers/gallery.dart';
|
||||
import 'package:wger/providers/measurement.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/routines.dart';
|
||||
import 'package:wger/providers/user.dart';
|
||||
import 'package:wger/providers/workout_logs.dart';
|
||||
import 'package:wger/providers/workout_session.dart';
|
||||
import 'package:wger/screens/dashboard.dart';
|
||||
import 'package:wger/screens/gallery_screen.dart';
|
||||
@@ -46,8 +46,11 @@ class EagerInitialization extends riverpod.ConsumerWidget {
|
||||
// TODO: do we need all of these here?
|
||||
ref.watch(exerciseStateProvider);
|
||||
ref.watch(workoutSessionProvider);
|
||||
ref.watch(routineRepetitionUnitProvider);
|
||||
ref.watch(routineWeightUnitProvider);
|
||||
ref.watch(workoutLogProvider);
|
||||
// ref.watch(workoutLogProvider);
|
||||
ref.watch(routinesChangeProvider);
|
||||
// ref.watch(routinesChangeProvider);
|
||||
return HomeTabsScreen();
|
||||
}
|
||||
}
|
||||
@@ -96,12 +99,18 @@ class _HomeTabsScreenState extends riverpod.ConsumerState<HomeTabsScreen>
|
||||
final authProvider = context.read<AuthProvider>();
|
||||
|
||||
if (!authProvider.dataInit) {
|
||||
final routinesProvider = ref.read(routinesChangeProvider);
|
||||
final nutritionPlansProvider = context.read<NutritionPlansProvider>();
|
||||
final galleryProvider = context.read<GalleryProvider>();
|
||||
final measurementProvider = context.read<MeasurementProvider>();
|
||||
final userProvider = context.read<UserProvider>();
|
||||
|
||||
// ref.watch(routinesRiverpodProvider);
|
||||
// ref.read(exerciseStateProvider);
|
||||
await ref.read(exerciseStateReadyProvider.future);
|
||||
|
||||
// await ref.read(routineStateReadyProvider.future);
|
||||
// widget._logger.info('Routine state is ready.');
|
||||
|
||||
//
|
||||
// Base data
|
||||
widget._logger.info('Loading base data');
|
||||
@@ -111,9 +120,16 @@ class _HomeTabsScreenState extends riverpod.ConsumerState<HomeTabsScreen>
|
||||
nutritionPlansProvider.fetchIngredientsFromCache(),
|
||||
]);
|
||||
// await ref.read(routineWeightUnitProvider.future);
|
||||
await ref.read(exerciseStateReadyProvider.future);
|
||||
await ref.read(sessionStateReadyProvider.future);
|
||||
ref.read(weightEntryProvider());
|
||||
// await ref.read(exerciseStateReadyProvider.future);
|
||||
// await ref.read(routineStateReadyProvider.future);
|
||||
// await ref.read(sessionStateReadyProvider.future);
|
||||
// ref.watch(workoutLogProvider);
|
||||
// ref.read(weightEntryProvider());
|
||||
|
||||
// await ref.watch(workoutLogProvider.future);
|
||||
// await ref.read(workoutLogProvider.future);
|
||||
|
||||
final routinesProvider = ref.read(routinesRiverpodProvider.notifier);
|
||||
|
||||
//
|
||||
// Plans, weight and gallery
|
||||
@@ -121,8 +137,7 @@ class _HomeTabsScreenState extends riverpod.ConsumerState<HomeTabsScreen>
|
||||
await Future.wait([
|
||||
galleryProvider.fetchAndSetGallery(),
|
||||
nutritionPlansProvider.fetchAndSetAllPlansSparse(),
|
||||
routinesProvider.fetchAndSetAllRoutinesSparse(),
|
||||
// routinesProvider.fetchAndSetAllRoutinesFull(),
|
||||
routinesProvider.fetchAllRoutinesSparse(),
|
||||
measurementProvider.fetchAndSetAllCategoriesAndEntries(),
|
||||
]);
|
||||
|
||||
@@ -136,7 +151,7 @@ class _HomeTabsScreenState extends riverpod.ConsumerState<HomeTabsScreen>
|
||||
|
||||
//
|
||||
// Current routine
|
||||
widget._logger.info('Loading current routine');
|
||||
// widget._logger.info('Loading current routine');
|
||||
if (routinesProvider.currentRoutine != null) {
|
||||
final routineId = routinesProvider.currentRoutine!.id!;
|
||||
widget._logger.finer('Current routine ID: $routineId');
|
||||
|
||||
@@ -30,7 +30,7 @@ class RoutineEditScreen extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final routineId = ModalRoute.of(context)!.settings.arguments as int;
|
||||
final routine = ref.read(routinesChangeProvider).findById(routineId);
|
||||
final routine = ref.read(routinesRiverpodProvider.notifier).findById(routineId);
|
||||
|
||||
return Scaffold(
|
||||
appBar: EmptyAppBar(routine.name),
|
||||
|
||||
@@ -30,7 +30,7 @@ class WorkoutLogsScreen extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final routineId = ModalRoute.of(context)!.settings.arguments as int;
|
||||
final routine = ref.read(routinesChangeProvider).findById(routineId);
|
||||
final routine = ref.read(routinesRiverpodProvider.notifier).findById(routineId);
|
||||
|
||||
return Scaffold(
|
||||
appBar: EmptyAppBar(routine.name),
|
||||
|
||||
@@ -30,7 +30,7 @@ class RoutineScreen extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final routineId = ModalRoute.of(context)!.settings.arguments as int;
|
||||
final routineProvider = ref.read(routinesChangeProvider);
|
||||
final routineProvider = ref.read(routinesRiverpodProvider.notifier);
|
||||
|
||||
final routine = routineProvider.findById(routineId);
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/providers/auth.dart';
|
||||
import 'package:wger/providers/gallery.dart';
|
||||
import 'package:wger/providers/nutrition.dart';
|
||||
import 'package:wger/providers/routines.dart';
|
||||
import 'package:wger/providers/user.dart';
|
||||
import 'package:wger/screens/form_screen.dart';
|
||||
import 'package:wger/widgets/core/about.dart';
|
||||
@@ -132,7 +131,7 @@ class MainAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
||||
onTap: () {
|
||||
final auth = context.read<AuthProvider>();
|
||||
auth.logout();
|
||||
ref.read(routinesChangeProvider).clear();
|
||||
// ref.read(routinesChangeProvider).clear();
|
||||
context.read<NutritionPlansProvider>().clear();
|
||||
// ref.read(bodyWeightStateProvider.notifier).clear();
|
||||
context.read<GalleryProvider>().clear();
|
||||
|
||||
@@ -87,7 +87,7 @@ class _DashboardCalendarWidgetState extends riverpod.ConsumerState<DashboardCale
|
||||
/// This method asynchronously fetches and processes data from multiple sources:
|
||||
/// - **Weight entries**: Retrieves weight measurements from [BodyWeightProvider]
|
||||
/// - **Measurements**: Retrieves body measurements from [MeasurementProvider]
|
||||
/// - **Workout sessions**: Fetches workout session data from [RoutinesProvider]
|
||||
/// - **Workout sessions**: Fetches workout session data from [RoutinesRiverpod]
|
||||
/// - **Nutritional plans**: Retrieves calorie diary entries from [NutritionPlansProvider]
|
||||
///
|
||||
/// Each event is formatted according to the current locale and stored in the
|
||||
@@ -144,7 +144,7 @@ class _DashboardCalendarWidgetState extends riverpod.ConsumerState<DashboardCale
|
||||
}
|
||||
|
||||
// Process workout sessions
|
||||
final routinesProvider = ref.read(routinesChangeProvider);
|
||||
final routinesProvider = ref.read(routinesRiverpodProvider);
|
||||
for (final session in routinesProvider.sessions) {
|
||||
final date = DateFormatLists.format(session.date);
|
||||
if (!newEvents.containsKey(date)) {
|
||||
|
||||
@@ -45,7 +45,7 @@ class _DashboardRoutineWidgetState extends ConsumerState<DashboardRoutineWidget>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dateFormat = DateFormat.yMd(Localizations.localeOf(context).languageCode);
|
||||
final routine = ref.watch(routinesChangeProvider).currentRoutine;
|
||||
final routine = ref.watch(routinesRiverpodProvider.notifier).currentRoutine;
|
||||
_hasContent = routine != null;
|
||||
|
||||
return Card(
|
||||
|
||||
@@ -88,7 +88,7 @@ class RoutineDetailAppBar extends ConsumerWidget implements PreferredSizeWidget
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final i18n = AppLocalizations.of(context);
|
||||
final provider = ref.read(routinesChangeProvider);
|
||||
final provider = ref.read(routinesRiverpodProvider.notifier);
|
||||
final isOnline = ref.watch(networkStatusProvider);
|
||||
|
||||
return AppBar(
|
||||
|
||||
@@ -49,7 +49,7 @@ class _ReorderableDaysListState extends ConsumerState<ReorderableDaysList> {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
widget.days.remove(day);
|
||||
await ref.read(routinesChangeProvider).deleteDay(day.id!);
|
||||
await ref.read(routinesRiverpodProvider.notifier).deleteDay(day.id!, day.routineId);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text('Delete'),
|
||||
@@ -63,7 +63,7 @@ class _ReorderableDaysListState extends ConsumerState<ReorderableDaysList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final i18n = AppLocalizations.of(context);
|
||||
final provider = ref.read(routinesChangeProvider);
|
||||
final provider = ref.read(routinesRiverpodProvider.notifier);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
@@ -151,9 +151,6 @@ class _ReorderableDaysListState extends ConsumerState<ReorderableDaysList> {
|
||||
name: '${i18n.newDay} ${widget.days.length + 1}',
|
||||
order: widget.days.length + 1,
|
||||
);
|
||||
day.name = '${i18n.newDay} ${widget.days.length + 1}';
|
||||
day.routineId = widget.routineId;
|
||||
day.order = widget.days.length + 1;
|
||||
final newDay = await provider.addDay(day);
|
||||
|
||||
widget.onDaySelected(newDay.id!);
|
||||
@@ -324,7 +321,7 @@ class _DayFormWidgetState extends ConsumerState<DayFormWidget> {
|
||||
setState(() => isSaving = true);
|
||||
|
||||
try {
|
||||
await ref.read(routinesChangeProvider).editDay(widget.day);
|
||||
await ref.read(routinesRiverpodProvider.notifier).editDay(widget.day);
|
||||
if (context.mounted) {
|
||||
setState(() {
|
||||
errorMessage = const SizedBox.shrink();
|
||||
|
||||
@@ -216,7 +216,7 @@ class _RoutineFormState extends ConsumerState<RoutineForm> {
|
||||
|
||||
// Save to DB
|
||||
try {
|
||||
final routinesProvider = ref.read(routinesChangeProvider);
|
||||
final routinesProvider = ref.read(routinesRiverpodProvider.notifier);
|
||||
|
||||
if (widget._routine.id != null) {
|
||||
await routinesProvider.editRoutine(widget._routine);
|
||||
|
||||
@@ -48,7 +48,7 @@ class _SlotDetailWidgetState extends ConsumerState<SlotDetailWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final i18n = AppLocalizations.of(context);
|
||||
final provider = ref.read(routinesChangeProvider);
|
||||
final provider = ref.read(routinesRiverpodProvider.notifier);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
@@ -117,7 +117,7 @@ class _SlotFormWidgetStateNg extends ConsumerState<ReorderableSlotList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final i18n = AppLocalizations.of(context);
|
||||
final provider = ref.read(routinesChangeProvider);
|
||||
final provider = ref.read(routinesRiverpodProvider.notifier);
|
||||
final languageCode = Localizations.localeOf(context).languageCode;
|
||||
|
||||
return Column(
|
||||
|
||||
@@ -124,7 +124,7 @@ class _SlotEntryFormState extends ConsumerState<SlotEntryForm> {
|
||||
final languageCode = Localizations.localeOf(context).languageCode;
|
||||
final numberFormat = NumberFormat.decimalPattern(Localizations.localeOf(context).toString());
|
||||
|
||||
final provider = ref.read(routinesChangeProvider);
|
||||
final provider = ref.read(routinesRiverpodProvider.notifier);
|
||||
|
||||
return Form(
|
||||
key: _form,
|
||||
@@ -438,7 +438,7 @@ class _SlotDetailWidgetState extends ConsumerState<SlotDetailWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final i18n = AppLocalizations.of(context);
|
||||
final provider = ref.read(routinesChangeProvider);
|
||||
final provider = ref.read(routinesRiverpodProvider.notifier);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
@@ -507,7 +507,7 @@ class _SlotFormWidgetStateNg extends ConsumerState<ReorderableSlotList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final i18n = AppLocalizations.of(context);
|
||||
final provider = ref.read(routinesChangeProvider);
|
||||
final provider = ref.read(routinesRiverpodProvider.notifier);
|
||||
final languageCode = Localizations.localeOf(context).languageCode;
|
||||
|
||||
return Column(
|
||||
|
||||
@@ -122,8 +122,8 @@ class _GymModeState extends ConsumerState<GymMode> {
|
||||
|
||||
List<Widget> getContent() {
|
||||
final state = ref.watch(gymStateProvider);
|
||||
final exercisesAsync = ref.read(exerciseStateProvider.notifier);
|
||||
final routinesProvider = ref.watch(routinesChangeProvider);
|
||||
final exercisesProvider = ref.read(exerciseStateProvider.notifier);
|
||||
final routinesProvider = ref.watch(routinesRiverpodProvider.notifier);
|
||||
var currentElement = 1;
|
||||
final List<Widget> out = [];
|
||||
|
||||
@@ -131,7 +131,7 @@ class _GymModeState extends ConsumerState<GymMode> {
|
||||
var firstPage = true;
|
||||
for (final config in slotData.setConfigs) {
|
||||
final ratioCompleted = currentElement / _totalElements;
|
||||
final exercise = exercisesAsync.getById(config.exerciseId);
|
||||
final exercise = exercisesProvider.getById(config.exerciseId);
|
||||
currentElement++;
|
||||
|
||||
if (firstPage && state.showExercisePages) {
|
||||
@@ -204,7 +204,7 @@ class _GymModeState extends ConsumerState<GymMode> {
|
||||
StartPage(_controller, widget._dayDataDisplay, _exercisePages),
|
||||
...getContent(),
|
||||
SessionPage(
|
||||
ref.read(routinesChangeProvider).findById(widget._dayDataGym.day!.routineId),
|
||||
ref.read(routinesRiverpodProvider.notifier).findById(widget._dayDataGym.day!.routineId),
|
||||
_controller,
|
||||
ref.read(gymStateProvider).startTime,
|
||||
_exercisePages,
|
||||
|
||||
@@ -176,9 +176,7 @@ class DayLogWidget extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final isOnline = ref.watch(networkStatusProvider);
|
||||
|
||||
final session = _routine.sessions.firstWhere(
|
||||
(sessionApi) => sessionApi.date.isSameDayAs(_date),
|
||||
);
|
||||
final session = _routine.sessions.firstWhere((s) => s.date.isSameDayAs(_date));
|
||||
final exercises = session.exercises;
|
||||
|
||||
return Card(
|
||||
|
||||
@@ -39,17 +39,18 @@ class _RoutinesListState extends ConsumerState<RoutinesList> {
|
||||
Widget build(BuildContext context) {
|
||||
final isOnline = ref.watch(networkStatusProvider);
|
||||
final dateFormat = DateFormat.yMd(Localizations.localeOf(context).languageCode);
|
||||
final routineProvider = ref.read(routinesChangeProvider);
|
||||
final routineProvider = ref.read(routinesRiverpodProvider.notifier);
|
||||
final routinesState = ref.read(routinesRiverpodProvider);
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: isOnline ? () => routineProvider.fetchAndSetAllRoutinesSparse() : () async {},
|
||||
child: routineProvider.routines.isEmpty
|
||||
onRefresh: isOnline ? () => routineProvider.fetchAllRoutinesSparse() : () async {},
|
||||
child: routinesState.routines.isEmpty
|
||||
? const TextPrompt()
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
itemCount: routineProvider.routines.length,
|
||||
itemCount: routinesState.routines.length,
|
||||
itemBuilder: (context, index) {
|
||||
final currentRoutine = routineProvider.routines[index];
|
||||
final currentRoutine = routinesState.routines[index];
|
||||
|
||||
return Card(
|
||||
child: ListTile(
|
||||
|
||||
287
test/fixtures/routines/routine_logs.json
vendored
287
test/fixtures/routines/routine_logs.json
vendored
@@ -1,287 +0,0 @@
|
||||
[
|
||||
{
|
||||
"session": {
|
||||
"id": 5,
|
||||
"uuid": "3291b27b-1973-455d-896c-57e705373e6c",
|
||||
"routine": 2,
|
||||
"day": null,
|
||||
"date": "2025-01-06",
|
||||
"notes": null,
|
||||
"impression": "2",
|
||||
"time_start": "20:28:49",
|
||||
"time_end": "23:35:53"
|
||||
},
|
||||
"logs": [
|
||||
{
|
||||
"id": 4,
|
||||
"date": "2025-01-06T00:00:00+01:00",
|
||||
"session": 5,
|
||||
"routine": 2,
|
||||
"iteration": 1,
|
||||
"slot_entry": 2,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "11.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "78.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "4",
|
||||
"rir_target": null,
|
||||
"rest": 150,
|
||||
"rest_target": 120
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"date": "2025-01-06T00:00:00+01:00",
|
||||
"session": 5,
|
||||
"routine": 2,
|
||||
"iteration": 1,
|
||||
"slot_entry": 2,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "12.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "77.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "2",
|
||||
"rir_target": null,
|
||||
"rest": 159,
|
||||
"rest_target": 120
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"date": "2025-01-06T00:00:00+01:00",
|
||||
"session": 5,
|
||||
"routine": 2,
|
||||
"iteration": 1,
|
||||
"slot_entry": 2,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "12.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "78.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "2.5",
|
||||
"rir_target": null,
|
||||
"rest": 143,
|
||||
"rest_target": 120
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"date": "2025-01-06T00:00:00+01:00",
|
||||
"session": 5,
|
||||
"routine": 2,
|
||||
"iteration": 1,
|
||||
"slot_entry": 2,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "12.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "83.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "0.5",
|
||||
"rir_target": null,
|
||||
"rest": 160,
|
||||
"rest_target": 120
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"session": {
|
||||
"id": 6,
|
||||
"uuid":"7e3d2a44-1a99-46d7-a58c-955f5fee8145",
|
||||
"routine": 2,
|
||||
"day": null,
|
||||
"date": "2025-01-08",
|
||||
"notes": null,
|
||||
"impression": "2",
|
||||
"time_start": "12:55:54",
|
||||
"time_end": "14:25:31"
|
||||
},
|
||||
"logs": [
|
||||
{
|
||||
"id": 7,
|
||||
"date": "2025-01-08T00:00:00+01:00",
|
||||
"session": 6,
|
||||
"routine": 2,
|
||||
"iteration": 1,
|
||||
"slot_entry": 3,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "10.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "80.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "3",
|
||||
"rir_target": null,
|
||||
"rest": 131,
|
||||
"rest_target": 120
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"date": "2025-01-08T00:00:00+01:00",
|
||||
"session": 6,
|
||||
"routine": 2,
|
||||
"iteration": 1,
|
||||
"slot_entry": 3,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "11.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "83.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "3",
|
||||
"rir_target": null,
|
||||
"rest": 128,
|
||||
"rest_target": 120
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"date": "2025-01-08T00:00:00+01:00",
|
||||
"session": 6,
|
||||
"routine": 2,
|
||||
"iteration": 1,
|
||||
"slot_entry": 3,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "11.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "90.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "0.5",
|
||||
"rir_target": "0.5",
|
||||
"rest": 121,
|
||||
"rest_target": 120
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"date": "2025-01-08T00:00:00+01:00",
|
||||
"session": 6,
|
||||
"routine": 2,
|
||||
"iteration": 1,
|
||||
"slot_entry": 3,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "12.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "77.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "1.5",
|
||||
"rir_target": null,
|
||||
"rest": 129,
|
||||
"rest_target": 120
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"session": {
|
||||
"id": 7,
|
||||
"uuid": "226768ac-c011-46dd-937f-e81a4a9f6b6a",
|
||||
"routine": 2,
|
||||
"day": null,
|
||||
"date": "2025-01-13",
|
||||
"notes": null,
|
||||
"impression": "2",
|
||||
"time_start": "18:48:45",
|
||||
"time_end": "20:20:52"
|
||||
},
|
||||
"logs": [
|
||||
{
|
||||
"id": 11,
|
||||
"date": "2025-01-13T00:00:00+01:00",
|
||||
"session": 7,
|
||||
"routine": 2,
|
||||
"iteration": 2,
|
||||
"slot_entry": 2,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "9.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "84.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "0",
|
||||
"rir_target": null,
|
||||
"rest": 128,
|
||||
"rest_target": 120
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"date": "2025-01-13T00:00:00+01:00",
|
||||
"session": 7,
|
||||
"routine": 2,
|
||||
"iteration": 2,
|
||||
"slot_entry": 2,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "10.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "84.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "4",
|
||||
"rir_target": null,
|
||||
"rest": 149,
|
||||
"rest_target": 120
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"date": "2025-01-13T00:00:00+01:00",
|
||||
"session": 7,
|
||||
"routine": 2,
|
||||
"iteration": 2,
|
||||
"slot_entry": 2,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "10.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "89.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "1.5",
|
||||
"rir_target": null,
|
||||
"rest": 120,
|
||||
"rest_target": 120
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"date": "2025-01-13T00:00:00+01:00",
|
||||
"session": 7,
|
||||
"routine": 2,
|
||||
"iteration": 2,
|
||||
"slot_entry": 2,
|
||||
"next_log": null,
|
||||
"exercise": 4,
|
||||
"repetitions_unit": 1,
|
||||
"repetitions": "12.00",
|
||||
"repetitions_target": "10.00",
|
||||
"weight_unit": 1,
|
||||
"weight": "90.00",
|
||||
"weight_target": "80.00",
|
||||
"rir": "2.5",
|
||||
"rir_target": null,
|
||||
"rest": 119,
|
||||
"rest_target": 120
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -28,21 +28,24 @@ import 'package:wger/providers/routines.dart';
|
||||
import 'package:wger/widgets/routines/forms/day.dart';
|
||||
|
||||
import '../../test_data/routines.dart';
|
||||
import 'routine_edit_test.mocks.dart';
|
||||
import 'day_form_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RoutinesProvider])
|
||||
@GenerateMocks([RoutinesRepository])
|
||||
void main() {
|
||||
late MockRoutinesProvider mockRoutinesProvider;
|
||||
late MockRoutinesRepository mockRoutinesRepository;
|
||||
|
||||
setUp(() {
|
||||
mockRoutinesProvider = MockRoutinesProvider();
|
||||
when(mockRoutinesProvider.editDay(any)).thenAnswer((_) async => getTestRoutine().days[0]);
|
||||
mockRoutinesRepository = MockRoutinesRepository();
|
||||
when(mockRoutinesRepository.editDayServer(any)).thenAnswer((_) async => {});
|
||||
when(
|
||||
mockRoutinesRepository.fetchAndSetRoutineFullServer(any),
|
||||
).thenAnswer((_) => Future.value(getTestRoutine()));
|
||||
});
|
||||
|
||||
Widget renderWidget() {
|
||||
return ProviderScope(
|
||||
overrides: [
|
||||
routinesChangeProvider.overrideWithValue(mockRoutinesProvider),
|
||||
routinesRepositoryProvider.overrideWithValue(mockRoutinesRepository),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
@@ -96,7 +99,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
verify(
|
||||
mockRoutinesProvider.editDay(
|
||||
mockRoutinesRepository.editDayServer(
|
||||
argThat(
|
||||
isA<Day>()
|
||||
.having((d) => d.routineId, 'routineId', 1)
|
||||
|
||||
@@ -3,23 +3,15 @@
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i13;
|
||||
import 'dart:ui' as _i16;
|
||||
import 'dart:async' as _i8;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i12;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i7;
|
||||
import 'package:wger/models/workouts/day.dart' as _i4;
|
||||
import 'package:wger/models/workouts/day_data.dart' as _i14;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i11;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i3;
|
||||
import 'package:wger/models/workouts/session.dart' as _i10;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i5;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i6;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i9;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/routines.dart' as _i8;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i6;
|
||||
import 'package:wger/models/workouts/day.dart' as _i3;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i2;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i4;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i5;
|
||||
import 'package:wger/providers/routines.dart' as _i7;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -35,432 +27,228 @@ import 'package:wger/providers/routines.dart' as _i8;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
|
||||
: super(parent, parentInvocation);
|
||||
class _FakeRoutine_0 extends _i1.SmartFake implements _i2.Routine {
|
||||
_FakeRoutine_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeRoutine_1 extends _i1.SmartFake implements _i3.Routine {
|
||||
_FakeRoutine_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeDay_1 extends _i1.SmartFake implements _i3.Day {
|
||||
_FakeDay_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeDay_2 extends _i1.SmartFake implements _i4.Day {
|
||||
_FakeDay_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeSlot_2 extends _i1.SmartFake implements _i4.Slot {
|
||||
_FakeSlot_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlot_3 extends _i1.SmartFake implements _i5.Slot {
|
||||
_FakeSlot_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeSlotEntry_3 extends _i1.SmartFake implements _i5.SlotEntry {
|
||||
_FakeSlotEntry_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlotEntry_4 extends _i1.SmartFake implements _i6.SlotEntry {
|
||||
_FakeSlotEntry_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeBaseConfig_4 extends _i1.SmartFake implements _i6.BaseConfig {
|
||||
_FakeBaseConfig_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeBaseConfig_5 extends _i1.SmartFake implements _i7.BaseConfig {
|
||||
_FakeBaseConfig_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [RoutinesProvider].
|
||||
/// A class which mocks [RoutinesRepository].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockRoutinesProvider extends _i1.Mock implements _i8.RoutinesProvider {
|
||||
MockRoutinesProvider() {
|
||||
class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository {
|
||||
MockRoutinesRepository() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.WgerBaseProvider get baseProvider =>
|
||||
_i8.Future<List<_i2.Routine>> fetchAllRoutinesSparseServer() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(
|
||||
this,
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
Invocation.method(#fetchAllRoutinesSparseServer, []),
|
||||
returnValue: _i8.Future<List<_i2.Routine>>.value(<_i2.Routine>[]),
|
||||
)
|
||||
as _i2.WgerBaseProvider);
|
||||
as _i8.Future<List<_i2.Routine>>);
|
||||
|
||||
@override
|
||||
List<_i9.WeightUnit> get weightUnits =>
|
||||
_i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#weightUnits),
|
||||
returnValue: <_i9.WeightUnit>[],
|
||||
)
|
||||
as List<_i9.WeightUnit>);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> get sessions =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#sessions),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> get routines =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#routines),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
List<_i11.RepetitionUnit> get repetitionUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#repetitionUnits),
|
||||
returnValue: <_i11.RepetitionUnit>[],
|
||||
)
|
||||
as List<_i11.RepetitionUnit>);
|
||||
|
||||
@override
|
||||
set activeRoutine(_i3.Routine? _activeRoutine) => super.noSuchMethod(
|
||||
Invocation.setter(#activeRoutine, _activeRoutine),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set exercises(List<_i12.Exercise>? exercises) => super.noSuchMethod(
|
||||
Invocation.setter(#exercises, exercises),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set repetitionUnits(List<_i11.RepetitionUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#repetitionUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set weightUnits(List<_i9.WeightUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#weightUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set sessions(List<_i10.WorkoutSession>? sessions) => super.noSuchMethod(
|
||||
Invocation.setter(#sessions, sessions),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners =>
|
||||
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> getSessionsForRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getSessionsForRoutine, [id]),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(#clear, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> getPlans() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getPlans, []),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i3.Routine findById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findById, [id]),
|
||||
returnValue: _FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#findById, [id]),
|
||||
),
|
||||
)
|
||||
as _i3.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findIndexById, [id]),
|
||||
returnValue: 0,
|
||||
)
|
||||
as int);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesFull() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesFull, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesSparse() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesSparse, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> setExercisesAndUnits(List<_i14.DayData>? entries) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#setExercisesAndUnits, [entries]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineSparse(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
Invocation.method(#fetchAndSetRoutineFullServer, [routineId]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
Invocation.method(#fetchAndSetRoutineFullServer, [routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineFull(int? routineId) =>
|
||||
_i8.Future<_i2.Routine> addRoutineServer(_i2.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
Invocation.method(#addRoutineServer, [routine]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
Invocation.method(#addRoutineServer, [routine]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> addRoutine(_i3.Routine? routine) =>
|
||||
_i8.Future<_i2.Routine> editRoutineServer(_i2.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addRoutine, [routine]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(this, Invocation.method(#addRoutine, [routine])),
|
||||
Invocation.method(#editRoutineServer, [routine]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#editRoutineServer, [routine]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editRoutine(_i3.Routine? routine) =>
|
||||
_i8.Future<void> deleteRoutineServer(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editRoutine, [routine]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteRoutineServer, [id]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteRoutine(int? id) =>
|
||||
_i8.Future<_i3.Day> addDayServer(_i3.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteRoutine, [id]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i4.Day> addDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addDay, [day]),
|
||||
returnValue: _i13.Future<_i4.Day>.value(
|
||||
_FakeDay_2(this, Invocation.method(#addDay, [day])),
|
||||
Invocation.method(#addDayServer, [day]),
|
||||
returnValue: _i8.Future<_i3.Day>.value(
|
||||
_FakeDay_1(this, Invocation.method(#addDayServer, [day])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i4.Day>);
|
||||
as _i8.Future<_i3.Day>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDay(_i4.Day? day) =>
|
||||
_i8.Future<void> editDayServer(_i3.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDay, [day]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#editDayServer, [day]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDays(List<_i4.Day>? days) =>
|
||||
_i8.Future<void> deleteDayServer(int? dayId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDays, [days]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteDayServer, [dayId]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteDay(int? dayId) =>
|
||||
_i8.Future<_i4.Slot> addSlotServer(_i4.Slot? slot) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteDay, [dayId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i5.Slot> addSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<_i5.Slot>.value(
|
||||
_FakeSlot_3(this, Invocation.method(#addSlot, [slot, routineId])),
|
||||
Invocation.method(#addSlotServer, [slot]),
|
||||
returnValue: _i8.Future<_i4.Slot>.value(
|
||||
_FakeSlot_2(this, Invocation.method(#addSlotServer, [slot])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i5.Slot>);
|
||||
as _i8.Future<_i4.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId, int? routineId) =>
|
||||
_i8.Future<void> deleteSlotServer(int? slotId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlot, [slotId, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteSlotServer, [slotId]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i5.Slot? slot, int? routineId) =>
|
||||
_i8.Future<void> editSlotServer(_i4.Slot? slot) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#editSlotServer, [slot]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlots(List<_i5.Slot>? slots, int? routineId) =>
|
||||
_i8.Future<_i5.SlotEntry> addSlotEntryServer(_i5.SlotEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlots, [slots, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#addSlotEntryServer, [entry]),
|
||||
returnValue: _i8.Future<_i5.SlotEntry>.value(
|
||||
_FakeSlotEntry_3(
|
||||
this,
|
||||
Invocation.method(#addSlotEntryServer, [entry]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<_i5.SlotEntry>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i6.SlotEntry> addSlotEntry(
|
||||
_i6.SlotEntry? entry,
|
||||
int? routineId,
|
||||
_i8.Future<void> deleteSlotEntryServer(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntryServer, [id]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<void> editSlotEntryServer(_i5.SlotEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntryServer, [entry]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i6.BaseConfig> editConfigServer(
|
||||
_i6.BaseConfig? config,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<_i6.SlotEntry>.value(
|
||||
_FakeSlotEntry_4(
|
||||
Invocation.method(#editConfigServer, [config, type]),
|
||||
returnValue: _i8.Future<_i6.BaseConfig>.value(
|
||||
_FakeBaseConfig_4(
|
||||
this,
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
Invocation.method(#editConfigServer, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i6.SlotEntry>);
|
||||
as _i8.Future<_i6.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntry, [id, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlotEntry(_i6.SlotEntry? entry, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
returnValue: _i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
),
|
||||
)
|
||||
as String);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> editConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
_i8.Future<_i6.BaseConfig> addConfigServer(
|
||||
_i6.BaseConfig? config,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
Invocation.method(#addConfigServer, [config, type]),
|
||||
returnValue: _i8.Future<_i6.BaseConfig>.value(
|
||||
_FakeBaseConfig_4(
|
||||
this,
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
Invocation.method(#addConfigServer, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
as _i8.Future<_i6.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> addConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
_i8.Future<void> deleteConfigServer(int? id, _i5.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
Invocation.method(#deleteConfigServer, [id, type]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteConfig(int? id, _i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteConfig, [id, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> handleConfig(
|
||||
_i6.SlotEntry? entry,
|
||||
_i8.Future<void> handleConfigServer(
|
||||
_i5.SlotEntry? entry,
|
||||
num? value,
|
||||
_i6.ConfigType? type,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#handleConfig, [entry, value, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#handleConfigServer, [entry, value, type]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#addListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#removeListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(#dispose, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(#notifyListeners, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
as _i8.Future<void>);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart' as riverpod;
|
||||
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:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
@@ -43,23 +41,17 @@ import 'package:wger/widgets/routines/gym_mode/timer.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
import 'gym_mode_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RoutinesProvider])
|
||||
void main() {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
final mockRoutinesProvider = MockRoutinesProvider();
|
||||
|
||||
setUp(() {
|
||||
when(mockRoutinesProvider.findById(any)).thenReturn(getTestRoutine());
|
||||
SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty();
|
||||
});
|
||||
|
||||
Widget renderGymMode({locale = 'en'}) {
|
||||
return ProviderScope(
|
||||
final container = ProviderContainer.test(
|
||||
overrides: [
|
||||
routinesChangeProvider.overrideWithValue(mockRoutinesProvider),
|
||||
exercisesProvider.overrideWithValue(riverpod.AsyncValue.data(getTestExercises())),
|
||||
exerciseEquipmentProvider.overrideWithValue(
|
||||
const riverpod.AsyncValue.data(<Equipment>[]),
|
||||
@@ -74,6 +66,14 @@ void main() {
|
||||
const riverpod.AsyncValue.data(testWeightUnits),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
container.read(routinesRiverpodProvider.notifier).state = RoutinesState(
|
||||
routines: [getTestRoutine()],
|
||||
);
|
||||
|
||||
return UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
|
||||
@@ -1,466 +0,0 @@
|
||||
// Mocks generated by Mockito 5.4.6 from annotations
|
||||
// in wger/test/routine/gym_mode_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i13;
|
||||
import 'dart:ui' as _i16;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i12;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i7;
|
||||
import 'package:wger/models/workouts/day.dart' as _i4;
|
||||
import 'package:wger/models/workouts/day_data.dart' as _i14;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i11;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i3;
|
||||
import 'package:wger/models/workouts/session.dart' as _i10;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i5;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i6;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i9;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/routines.dart' as _i8;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: must_be_immutable
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
// ignore_for_file: unnecessary_parenthesis
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
|
||||
: super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeRoutine_1 extends _i1.SmartFake implements _i3.Routine {
|
||||
_FakeRoutine_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeDay_2 extends _i1.SmartFake implements _i4.Day {
|
||||
_FakeDay_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlot_3 extends _i1.SmartFake implements _i5.Slot {
|
||||
_FakeSlot_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlotEntry_4 extends _i1.SmartFake implements _i6.SlotEntry {
|
||||
_FakeSlotEntry_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeBaseConfig_5 extends _i1.SmartFake implements _i7.BaseConfig {
|
||||
_FakeBaseConfig_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [RoutinesProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockRoutinesProvider extends _i1.Mock implements _i8.RoutinesProvider {
|
||||
MockRoutinesProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.WgerBaseProvider get baseProvider =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(
|
||||
this,
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
)
|
||||
as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
List<_i9.WeightUnit> get weightUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#weightUnits),
|
||||
returnValue: <_i9.WeightUnit>[],
|
||||
)
|
||||
as List<_i9.WeightUnit>);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> get sessions =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#sessions),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> get routines =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#routines),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
List<_i11.RepetitionUnit> get repetitionUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#repetitionUnits),
|
||||
returnValue: <_i11.RepetitionUnit>[],
|
||||
)
|
||||
as List<_i11.RepetitionUnit>);
|
||||
|
||||
@override
|
||||
set activeRoutine(_i3.Routine? _activeRoutine) => super.noSuchMethod(
|
||||
Invocation.setter(#activeRoutine, _activeRoutine),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set exercises(List<_i12.Exercise>? exercises) => super.noSuchMethod(
|
||||
Invocation.setter(#exercises, exercises),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set repetitionUnits(List<_i11.RepetitionUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#repetitionUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set weightUnits(List<_i9.WeightUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#weightUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set sessions(List<_i10.WorkoutSession>? sessions) => super.noSuchMethod(
|
||||
Invocation.setter(#sessions, sessions),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners =>
|
||||
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> getSessionsForRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getSessionsForRoutine, [id]),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(#clear, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> getPlans() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getPlans, []),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i3.Routine findById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findById, [id]),
|
||||
returnValue: _FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#findById, [id]),
|
||||
),
|
||||
)
|
||||
as _i3.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findIndexById, [id]),
|
||||
returnValue: 0,
|
||||
)
|
||||
as int);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesFull() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesFull, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesSparse() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesSparse, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> setExercisesAndUnits(List<_i14.DayData>? entries) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#setExercisesAndUnits, [entries]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineSparse(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineFull(int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> addRoutine(_i3.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addRoutine, [routine]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(this, Invocation.method(#addRoutine, [routine])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editRoutine(_i3.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editRoutine, [routine]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteRoutine, [id]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i4.Day> addDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addDay, [day]),
|
||||
returnValue: _i13.Future<_i4.Day>.value(
|
||||
_FakeDay_2(this, Invocation.method(#addDay, [day])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i4.Day>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDay, [day]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDays(List<_i4.Day>? days) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDays, [days]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteDay(int? dayId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteDay, [dayId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i5.Slot> addSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<_i5.Slot>.value(
|
||||
_FakeSlot_3(this, Invocation.method(#addSlot, [slot, routineId])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i5.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlot, [slotId, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlots(List<_i5.Slot>? slots, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlots, [slots, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i6.SlotEntry> addSlotEntry(
|
||||
_i6.SlotEntry? entry,
|
||||
int? routineId,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<_i6.SlotEntry>.value(
|
||||
_FakeSlotEntry_4(
|
||||
this,
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i6.SlotEntry>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntry, [id, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlotEntry(_i6.SlotEntry? entry, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
returnValue: _i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
),
|
||||
)
|
||||
as String);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> editConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> addConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteConfig(int? id, _i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteConfig, [id, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> handleConfig(
|
||||
_i6.SlotEntry? entry,
|
||||
num? value,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#handleConfig, [entry, value, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#addListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#removeListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(#dispose, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(#notifyListeners, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
}
|
||||
@@ -19,31 +19,25 @@
|
||||
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:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/providers/routines.dart';
|
||||
import 'package:wger/screens/routine_edit_screen.dart';
|
||||
|
||||
import '../../test_data/routines.dart';
|
||||
import 'routine_edit_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RoutinesProvider])
|
||||
void main() {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
testWidgets('RoutineEditScreen smoke test', (WidgetTester tester) async {
|
||||
// Create a mock RoutinesProvider
|
||||
final mockRoutinesProvider = MockRoutinesProvider();
|
||||
when(mockRoutinesProvider.fetchAndSetRoutineFull(1)).thenAnswer((_) async => getTestRoutine());
|
||||
when(mockRoutinesProvider.findById(1)).thenReturn(getTestRoutine());
|
||||
final container = ProviderContainer.test();
|
||||
|
||||
container.read(routinesRiverpodProvider.notifier).state = RoutinesState(
|
||||
routines: [getTestRoutine()],
|
||||
);
|
||||
|
||||
// Build the RoutineEditScreen widget with the correct arguments
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
routinesChangeProvider.overrideWithValue(mockRoutinesProvider),
|
||||
],
|
||||
UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -68,7 +62,6 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify the title is correct
|
||||
verify(mockRoutinesProvider.findById(1));
|
||||
expect(find.text('3 day workout'), findsNWidgets(2));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,466 +0,0 @@
|
||||
// Mocks generated by Mockito 5.4.6 from annotations
|
||||
// in wger/test/routine/routine_edit_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i13;
|
||||
import 'dart:ui' as _i16;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i12;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i7;
|
||||
import 'package:wger/models/workouts/day.dart' as _i4;
|
||||
import 'package:wger/models/workouts/day_data.dart' as _i14;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i11;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i3;
|
||||
import 'package:wger/models/workouts/session.dart' as _i10;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i5;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i6;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i9;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/routines.dart' as _i8;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: must_be_immutable
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
// ignore_for_file: unnecessary_parenthesis
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
|
||||
: super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeRoutine_1 extends _i1.SmartFake implements _i3.Routine {
|
||||
_FakeRoutine_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeDay_2 extends _i1.SmartFake implements _i4.Day {
|
||||
_FakeDay_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlot_3 extends _i1.SmartFake implements _i5.Slot {
|
||||
_FakeSlot_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlotEntry_4 extends _i1.SmartFake implements _i6.SlotEntry {
|
||||
_FakeSlotEntry_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeBaseConfig_5 extends _i1.SmartFake implements _i7.BaseConfig {
|
||||
_FakeBaseConfig_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [RoutinesProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockRoutinesProvider extends _i1.Mock implements _i8.RoutinesProvider {
|
||||
MockRoutinesProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.WgerBaseProvider get baseProvider =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(
|
||||
this,
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
)
|
||||
as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
List<_i9.WeightUnit> get weightUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#weightUnits),
|
||||
returnValue: <_i9.WeightUnit>[],
|
||||
)
|
||||
as List<_i9.WeightUnit>);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> get sessions =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#sessions),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> get routines =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#routines),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
List<_i11.RepetitionUnit> get repetitionUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#repetitionUnits),
|
||||
returnValue: <_i11.RepetitionUnit>[],
|
||||
)
|
||||
as List<_i11.RepetitionUnit>);
|
||||
|
||||
@override
|
||||
set activeRoutine(_i3.Routine? _activeRoutine) => super.noSuchMethod(
|
||||
Invocation.setter(#activeRoutine, _activeRoutine),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set exercises(List<_i12.Exercise>? exercises) => super.noSuchMethod(
|
||||
Invocation.setter(#exercises, exercises),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set repetitionUnits(List<_i11.RepetitionUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#repetitionUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set weightUnits(List<_i9.WeightUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#weightUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set sessions(List<_i10.WorkoutSession>? sessions) => super.noSuchMethod(
|
||||
Invocation.setter(#sessions, sessions),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners =>
|
||||
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> getSessionsForRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getSessionsForRoutine, [id]),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(#clear, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> getPlans() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getPlans, []),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i3.Routine findById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findById, [id]),
|
||||
returnValue: _FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#findById, [id]),
|
||||
),
|
||||
)
|
||||
as _i3.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findIndexById, [id]),
|
||||
returnValue: 0,
|
||||
)
|
||||
as int);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesFull() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesFull, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesSparse() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesSparse, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> setExercisesAndUnits(List<_i14.DayData>? entries) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#setExercisesAndUnits, [entries]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineSparse(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineFull(int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> addRoutine(_i3.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addRoutine, [routine]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(this, Invocation.method(#addRoutine, [routine])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editRoutine(_i3.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editRoutine, [routine]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteRoutine, [id]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i4.Day> addDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addDay, [day]),
|
||||
returnValue: _i13.Future<_i4.Day>.value(
|
||||
_FakeDay_2(this, Invocation.method(#addDay, [day])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i4.Day>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDay, [day]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDays(List<_i4.Day>? days) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDays, [days]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteDay(int? dayId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteDay, [dayId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i5.Slot> addSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<_i5.Slot>.value(
|
||||
_FakeSlot_3(this, Invocation.method(#addSlot, [slot, routineId])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i5.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlot, [slotId, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlots(List<_i5.Slot>? slots, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlots, [slots, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i6.SlotEntry> addSlotEntry(
|
||||
_i6.SlotEntry? entry,
|
||||
int? routineId,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<_i6.SlotEntry>.value(
|
||||
_FakeSlotEntry_4(
|
||||
this,
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i6.SlotEntry>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntry, [id, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlotEntry(_i6.SlotEntry? entry, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
returnValue: _i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
),
|
||||
)
|
||||
as String);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> editConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> addConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteConfig(int? id, _i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteConfig, [id, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> handleConfig(
|
||||
_i6.SlotEntry? entry,
|
||||
num? value,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#handleConfig, [entry, value, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#addListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#removeListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(#dispose, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(#notifyListeners, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
}
|
||||
@@ -29,13 +29,15 @@ import 'package:wger/widgets/routines/routine_edit.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
import 'routine_edit_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RoutinesProvider])
|
||||
@GenerateMocks([RoutinesRepository])
|
||||
void main() {
|
||||
late MockRoutinesProvider mockRoutinesProvider;
|
||||
late MockRoutinesRepository mockRoutinesRepository;
|
||||
|
||||
setUp(() {
|
||||
mockRoutinesProvider = MockRoutinesProvider();
|
||||
when(mockRoutinesProvider.fetchAndSetRoutineFull(1)).thenAnswer((_) async => getTestRoutine());
|
||||
mockRoutinesRepository = MockRoutinesRepository();
|
||||
when(
|
||||
mockRoutinesRepository.fetchAndSetRoutineFullServer(any),
|
||||
).thenAnswer((_) => Future.value(getTestRoutine()));
|
||||
});
|
||||
|
||||
testWidgets('RoutineEditScreen smoke test', (WidgetTester tester) async {
|
||||
@@ -43,7 +45,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
routinesChangeProvider.overrideWithValue(mockRoutinesProvider),
|
||||
routinesRepositoryProvider.overrideWithValue(mockRoutinesRepository),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
|
||||
@@ -3,23 +3,15 @@
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i13;
|
||||
import 'dart:ui' as _i16;
|
||||
import 'dart:async' as _i8;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i12;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i7;
|
||||
import 'package:wger/models/workouts/day.dart' as _i4;
|
||||
import 'package:wger/models/workouts/day_data.dart' as _i14;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i11;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i3;
|
||||
import 'package:wger/models/workouts/session.dart' as _i10;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i5;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i6;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i9;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/routines.dart' as _i8;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i6;
|
||||
import 'package:wger/models/workouts/day.dart' as _i3;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i2;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i4;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i5;
|
||||
import 'package:wger/providers/routines.dart' as _i7;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -35,432 +27,228 @@ import 'package:wger/providers/routines.dart' as _i8;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
|
||||
: super(parent, parentInvocation);
|
||||
class _FakeRoutine_0 extends _i1.SmartFake implements _i2.Routine {
|
||||
_FakeRoutine_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeRoutine_1 extends _i1.SmartFake implements _i3.Routine {
|
||||
_FakeRoutine_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeDay_1 extends _i1.SmartFake implements _i3.Day {
|
||||
_FakeDay_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeDay_2 extends _i1.SmartFake implements _i4.Day {
|
||||
_FakeDay_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeSlot_2 extends _i1.SmartFake implements _i4.Slot {
|
||||
_FakeSlot_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlot_3 extends _i1.SmartFake implements _i5.Slot {
|
||||
_FakeSlot_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeSlotEntry_3 extends _i1.SmartFake implements _i5.SlotEntry {
|
||||
_FakeSlotEntry_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlotEntry_4 extends _i1.SmartFake implements _i6.SlotEntry {
|
||||
_FakeSlotEntry_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeBaseConfig_4 extends _i1.SmartFake implements _i6.BaseConfig {
|
||||
_FakeBaseConfig_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeBaseConfig_5 extends _i1.SmartFake implements _i7.BaseConfig {
|
||||
_FakeBaseConfig_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [RoutinesProvider].
|
||||
/// A class which mocks [RoutinesRepository].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockRoutinesProvider extends _i1.Mock implements _i8.RoutinesProvider {
|
||||
MockRoutinesProvider() {
|
||||
class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository {
|
||||
MockRoutinesRepository() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.WgerBaseProvider get baseProvider =>
|
||||
_i8.Future<List<_i2.Routine>> fetchAllRoutinesSparseServer() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(
|
||||
this,
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
Invocation.method(#fetchAllRoutinesSparseServer, []),
|
||||
returnValue: _i8.Future<List<_i2.Routine>>.value(<_i2.Routine>[]),
|
||||
)
|
||||
as _i2.WgerBaseProvider);
|
||||
as _i8.Future<List<_i2.Routine>>);
|
||||
|
||||
@override
|
||||
List<_i9.WeightUnit> get weightUnits =>
|
||||
_i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#weightUnits),
|
||||
returnValue: <_i9.WeightUnit>[],
|
||||
)
|
||||
as List<_i9.WeightUnit>);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> get sessions =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#sessions),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> get routines =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#routines),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
List<_i11.RepetitionUnit> get repetitionUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#repetitionUnits),
|
||||
returnValue: <_i11.RepetitionUnit>[],
|
||||
)
|
||||
as List<_i11.RepetitionUnit>);
|
||||
|
||||
@override
|
||||
set activeRoutine(_i3.Routine? _activeRoutine) => super.noSuchMethod(
|
||||
Invocation.setter(#activeRoutine, _activeRoutine),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set exercises(List<_i12.Exercise>? exercises) => super.noSuchMethod(
|
||||
Invocation.setter(#exercises, exercises),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set repetitionUnits(List<_i11.RepetitionUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#repetitionUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set weightUnits(List<_i9.WeightUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#weightUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set sessions(List<_i10.WorkoutSession>? sessions) => super.noSuchMethod(
|
||||
Invocation.setter(#sessions, sessions),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners =>
|
||||
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> getSessionsForRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getSessionsForRoutine, [id]),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(#clear, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> getPlans() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getPlans, []),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i3.Routine findById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findById, [id]),
|
||||
returnValue: _FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#findById, [id]),
|
||||
),
|
||||
)
|
||||
as _i3.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findIndexById, [id]),
|
||||
returnValue: 0,
|
||||
)
|
||||
as int);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesFull() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesFull, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesSparse() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesSparse, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> setExercisesAndUnits(List<_i14.DayData>? entries) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#setExercisesAndUnits, [entries]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineSparse(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
Invocation.method(#fetchAndSetRoutineFullServer, [routineId]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
Invocation.method(#fetchAndSetRoutineFullServer, [routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineFull(int? routineId) =>
|
||||
_i8.Future<_i2.Routine> addRoutineServer(_i2.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
Invocation.method(#addRoutineServer, [routine]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
Invocation.method(#addRoutineServer, [routine]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> addRoutine(_i3.Routine? routine) =>
|
||||
_i8.Future<_i2.Routine> editRoutineServer(_i2.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addRoutine, [routine]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(this, Invocation.method(#addRoutine, [routine])),
|
||||
Invocation.method(#editRoutineServer, [routine]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#editRoutineServer, [routine]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editRoutine(_i3.Routine? routine) =>
|
||||
_i8.Future<void> deleteRoutineServer(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editRoutine, [routine]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteRoutineServer, [id]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteRoutine(int? id) =>
|
||||
_i8.Future<_i3.Day> addDayServer(_i3.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteRoutine, [id]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i4.Day> addDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addDay, [day]),
|
||||
returnValue: _i13.Future<_i4.Day>.value(
|
||||
_FakeDay_2(this, Invocation.method(#addDay, [day])),
|
||||
Invocation.method(#addDayServer, [day]),
|
||||
returnValue: _i8.Future<_i3.Day>.value(
|
||||
_FakeDay_1(this, Invocation.method(#addDayServer, [day])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i4.Day>);
|
||||
as _i8.Future<_i3.Day>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDay(_i4.Day? day) =>
|
||||
_i8.Future<void> editDayServer(_i3.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDay, [day]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#editDayServer, [day]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDays(List<_i4.Day>? days) =>
|
||||
_i8.Future<void> deleteDayServer(int? dayId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDays, [days]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteDayServer, [dayId]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteDay(int? dayId) =>
|
||||
_i8.Future<_i4.Slot> addSlotServer(_i4.Slot? slot) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteDay, [dayId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i5.Slot> addSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<_i5.Slot>.value(
|
||||
_FakeSlot_3(this, Invocation.method(#addSlot, [slot, routineId])),
|
||||
Invocation.method(#addSlotServer, [slot]),
|
||||
returnValue: _i8.Future<_i4.Slot>.value(
|
||||
_FakeSlot_2(this, Invocation.method(#addSlotServer, [slot])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i5.Slot>);
|
||||
as _i8.Future<_i4.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId, int? routineId) =>
|
||||
_i8.Future<void> deleteSlotServer(int? slotId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlot, [slotId, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteSlotServer, [slotId]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i5.Slot? slot, int? routineId) =>
|
||||
_i8.Future<void> editSlotServer(_i4.Slot? slot) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#editSlotServer, [slot]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlots(List<_i5.Slot>? slots, int? routineId) =>
|
||||
_i8.Future<_i5.SlotEntry> addSlotEntryServer(_i5.SlotEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlots, [slots, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#addSlotEntryServer, [entry]),
|
||||
returnValue: _i8.Future<_i5.SlotEntry>.value(
|
||||
_FakeSlotEntry_3(
|
||||
this,
|
||||
Invocation.method(#addSlotEntryServer, [entry]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<_i5.SlotEntry>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i6.SlotEntry> addSlotEntry(
|
||||
_i6.SlotEntry? entry,
|
||||
int? routineId,
|
||||
_i8.Future<void> deleteSlotEntryServer(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntryServer, [id]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<void> editSlotEntryServer(_i5.SlotEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntryServer, [entry]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i6.BaseConfig> editConfigServer(
|
||||
_i6.BaseConfig? config,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<_i6.SlotEntry>.value(
|
||||
_FakeSlotEntry_4(
|
||||
Invocation.method(#editConfigServer, [config, type]),
|
||||
returnValue: _i8.Future<_i6.BaseConfig>.value(
|
||||
_FakeBaseConfig_4(
|
||||
this,
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
Invocation.method(#editConfigServer, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i6.SlotEntry>);
|
||||
as _i8.Future<_i6.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntry, [id, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlotEntry(_i6.SlotEntry? entry, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
returnValue: _i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
),
|
||||
)
|
||||
as String);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> editConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
_i8.Future<_i6.BaseConfig> addConfigServer(
|
||||
_i6.BaseConfig? config,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
Invocation.method(#addConfigServer, [config, type]),
|
||||
returnValue: _i8.Future<_i6.BaseConfig>.value(
|
||||
_FakeBaseConfig_4(
|
||||
this,
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
Invocation.method(#addConfigServer, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
as _i8.Future<_i6.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> addConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
_i8.Future<void> deleteConfigServer(int? id, _i5.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
Invocation.method(#deleteConfigServer, [id, type]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteConfig(int? id, _i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteConfig, [id, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> handleConfig(
|
||||
_i6.SlotEntry? entry,
|
||||
_i8.Future<void> handleConfigServer(
|
||||
_i5.SlotEntry? entry,
|
||||
num? value,
|
||||
_i6.ConfigType? type,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#handleConfig, [entry, value, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#handleConfigServer, [entry, value, type]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#addListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#removeListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(#dispose, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(#notifyListeners, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
as _i8.Future<void>);
|
||||
}
|
||||
|
||||
@@ -30,31 +30,34 @@ import 'package:wger/screens/routine_edit_screen.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
import 'package:wger/widgets/routines/forms/routine.dart';
|
||||
|
||||
import '../../test_data/routines.dart';
|
||||
import './routine_form_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RoutinesProvider])
|
||||
@GenerateMocks([RoutinesRepository])
|
||||
void main() {
|
||||
var mockRoutinesProvider = MockRoutinesProvider();
|
||||
|
||||
final existingRoutine = Routine(
|
||||
id: 1,
|
||||
created: DateTime(2021, 1, 1),
|
||||
start: DateTime(2024, 11, 1),
|
||||
end: DateTime(2024, 12, 1),
|
||||
name: 'test 1',
|
||||
description: 'description 1',
|
||||
fitInWeek: false,
|
||||
);
|
||||
var newRoutine = Routine.empty();
|
||||
late MockRoutinesRepository mockRoutinesRepository;
|
||||
late Routine existingRoutine;
|
||||
late Routine newRoutine;
|
||||
|
||||
setUp(() {
|
||||
newRoutine = Routine.empty();
|
||||
mockRoutinesProvider = MockRoutinesProvider();
|
||||
when(mockRoutinesProvider.findById(any)).thenAnswer((_) => existingRoutine);
|
||||
when(mockRoutinesProvider.editRoutine(any)).thenAnswer((_) => Future.value(existingRoutine));
|
||||
existingRoutine = Routine(
|
||||
id: 1,
|
||||
created: DateTime(2021, 1, 1),
|
||||
start: DateTime(2024, 11, 1),
|
||||
end: DateTime(2024, 12, 1),
|
||||
name: 'test 1',
|
||||
description: 'description 1',
|
||||
fitInWeek: false,
|
||||
);
|
||||
|
||||
mockRoutinesRepository = MockRoutinesRepository();
|
||||
when(
|
||||
mockRoutinesProvider.fetchAndSetRoutineFull(any),
|
||||
).thenAnswer((_) => Future.value(existingRoutine));
|
||||
mockRoutinesRepository.fetchAndSetRoutineFullServer(any),
|
||||
).thenAnswer((_) async => getTestRoutine());
|
||||
when(
|
||||
mockRoutinesRepository.editRoutineServer(any),
|
||||
).thenAnswer((_) async => existingRoutine);
|
||||
});
|
||||
|
||||
Widget renderWidget(Routine routine, {locale = 'en'}) {
|
||||
@@ -62,7 +65,7 @@ void main() {
|
||||
|
||||
return ProviderScope(
|
||||
overrides: [
|
||||
routinesChangeProvider.overrideWithValue(mockRoutinesProvider),
|
||||
routinesRepositoryProvider.overrideWithValue(mockRoutinesRepository),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
@@ -104,8 +107,8 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
// Correct method was called
|
||||
verify(mockRoutinesProvider.editRoutine(any));
|
||||
verifyNever(mockRoutinesProvider.addRoutine(any));
|
||||
verify(mockRoutinesRepository.editRoutineServer(any));
|
||||
verifyNever(mockRoutinesRepository.addRoutineServer(any));
|
||||
|
||||
// TODO(x): edit calls Navigator.pop(), since the form can only be reached from the
|
||||
// detail page. The test needs to add the detail page to the stack so that
|
||||
@@ -118,7 +121,7 @@ void main() {
|
||||
|
||||
testWidgets('Test editing an existing routine - server error', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
when(mockRoutinesProvider.editRoutine(any)).thenThrow(
|
||||
when(mockRoutinesRepository.editRoutineServer(any)).thenThrow(
|
||||
WgerHttpException.fromMap({
|
||||
'name': ['The name is not valid'],
|
||||
}),
|
||||
@@ -142,8 +145,7 @@ void main() {
|
||||
name: 'New cool routine',
|
||||
);
|
||||
|
||||
when(mockRoutinesProvider.addRoutine(any)).thenAnswer((_) => Future.value(editRoutine));
|
||||
when(mockRoutinesProvider.findById(any)).thenAnswer((_) => editRoutine);
|
||||
when(mockRoutinesRepository.addRoutineServer(any)).thenAnswer((_) => Future.value(editRoutine));
|
||||
|
||||
await tester.pumpWidget(renderWidget(newRoutine));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -152,8 +154,8 @@ void main() {
|
||||
await tester.enterText(find.byKey(const Key('field-name')), editRoutine.name);
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
verifyNever(mockRoutinesProvider.editRoutine(any));
|
||||
verify(mockRoutinesProvider.addRoutine(any));
|
||||
verifyNever(mockRoutinesRepository.editRoutineServer(any));
|
||||
verify(mockRoutinesRepository.addRoutineServer(any));
|
||||
|
||||
// Detail page
|
||||
await tester.pumpAndSettle();
|
||||
@@ -169,8 +171,7 @@ void main() {
|
||||
name: 'My routine',
|
||||
description: 'Get yuuuge',
|
||||
);
|
||||
when(mockRoutinesProvider.addRoutine(any)).thenAnswer((_) => Future.value(editRoutine));
|
||||
when(mockRoutinesProvider.findById(any)).thenAnswer((_) => editRoutine);
|
||||
when(mockRoutinesRepository.addRoutineServer(any)).thenAnswer((_) => Future.value(editRoutine));
|
||||
|
||||
await tester.pumpWidget(renderWidget(newRoutine));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -180,8 +181,8 @@ void main() {
|
||||
await tester.enterText(find.byKey(const Key('field-description')), editRoutine.description);
|
||||
await tester.tap(find.byKey(const Key(SUBMIT_BUTTON_KEY_NAME)));
|
||||
|
||||
verifyNever(mockRoutinesProvider.editRoutine(any));
|
||||
verify(mockRoutinesProvider.addRoutine(any));
|
||||
verifyNever(mockRoutinesRepository.editRoutineServer(any));
|
||||
verify(mockRoutinesRepository.addRoutineServer(any));
|
||||
|
||||
// Detail page
|
||||
await tester.pumpAndSettle();
|
||||
@@ -190,7 +191,7 @@ void main() {
|
||||
|
||||
testWidgets('Test creating a new routine - server error', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
when(mockRoutinesProvider.addRoutine(any)).thenThrow(
|
||||
when(mockRoutinesRepository.addRoutineServer(any)).thenThrow(
|
||||
WgerHttpException.fromMap({
|
||||
'name': ['The name is not valid'],
|
||||
}),
|
||||
|
||||
@@ -3,23 +3,15 @@
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i13;
|
||||
import 'dart:ui' as _i16;
|
||||
import 'dart:async' as _i8;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i12;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i7;
|
||||
import 'package:wger/models/workouts/day.dart' as _i4;
|
||||
import 'package:wger/models/workouts/day_data.dart' as _i14;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i11;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i3;
|
||||
import 'package:wger/models/workouts/session.dart' as _i10;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i5;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i6;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i9;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/routines.dart' as _i8;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i6;
|
||||
import 'package:wger/models/workouts/day.dart' as _i3;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i2;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i4;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i5;
|
||||
import 'package:wger/providers/routines.dart' as _i7;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -35,432 +27,228 @@ import 'package:wger/providers/routines.dart' as _i8;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
|
||||
: super(parent, parentInvocation);
|
||||
class _FakeRoutine_0 extends _i1.SmartFake implements _i2.Routine {
|
||||
_FakeRoutine_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeRoutine_1 extends _i1.SmartFake implements _i3.Routine {
|
||||
_FakeRoutine_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeDay_1 extends _i1.SmartFake implements _i3.Day {
|
||||
_FakeDay_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeDay_2 extends _i1.SmartFake implements _i4.Day {
|
||||
_FakeDay_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeSlot_2 extends _i1.SmartFake implements _i4.Slot {
|
||||
_FakeSlot_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlot_3 extends _i1.SmartFake implements _i5.Slot {
|
||||
_FakeSlot_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeSlotEntry_3 extends _i1.SmartFake implements _i5.SlotEntry {
|
||||
_FakeSlotEntry_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlotEntry_4 extends _i1.SmartFake implements _i6.SlotEntry {
|
||||
_FakeSlotEntry_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeBaseConfig_4 extends _i1.SmartFake implements _i6.BaseConfig {
|
||||
_FakeBaseConfig_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeBaseConfig_5 extends _i1.SmartFake implements _i7.BaseConfig {
|
||||
_FakeBaseConfig_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [RoutinesProvider].
|
||||
/// A class which mocks [RoutinesRepository].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockRoutinesProvider extends _i1.Mock implements _i8.RoutinesProvider {
|
||||
MockRoutinesProvider() {
|
||||
class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository {
|
||||
MockRoutinesRepository() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.WgerBaseProvider get baseProvider =>
|
||||
_i8.Future<List<_i2.Routine>> fetchAllRoutinesSparseServer() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(
|
||||
this,
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
Invocation.method(#fetchAllRoutinesSparseServer, []),
|
||||
returnValue: _i8.Future<List<_i2.Routine>>.value(<_i2.Routine>[]),
|
||||
)
|
||||
as _i2.WgerBaseProvider);
|
||||
as _i8.Future<List<_i2.Routine>>);
|
||||
|
||||
@override
|
||||
List<_i9.WeightUnit> get weightUnits =>
|
||||
_i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#weightUnits),
|
||||
returnValue: <_i9.WeightUnit>[],
|
||||
)
|
||||
as List<_i9.WeightUnit>);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> get sessions =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#sessions),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> get routines =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#routines),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
List<_i11.RepetitionUnit> get repetitionUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#repetitionUnits),
|
||||
returnValue: <_i11.RepetitionUnit>[],
|
||||
)
|
||||
as List<_i11.RepetitionUnit>);
|
||||
|
||||
@override
|
||||
set activeRoutine(_i3.Routine? _activeRoutine) => super.noSuchMethod(
|
||||
Invocation.setter(#activeRoutine, _activeRoutine),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set exercises(List<_i12.Exercise>? exercises) => super.noSuchMethod(
|
||||
Invocation.setter(#exercises, exercises),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set repetitionUnits(List<_i11.RepetitionUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#repetitionUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set weightUnits(List<_i9.WeightUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#weightUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set sessions(List<_i10.WorkoutSession>? sessions) => super.noSuchMethod(
|
||||
Invocation.setter(#sessions, sessions),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners =>
|
||||
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> getSessionsForRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getSessionsForRoutine, [id]),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(#clear, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> getPlans() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getPlans, []),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i3.Routine findById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findById, [id]),
|
||||
returnValue: _FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#findById, [id]),
|
||||
),
|
||||
)
|
||||
as _i3.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findIndexById, [id]),
|
||||
returnValue: 0,
|
||||
)
|
||||
as int);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesFull() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesFull, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesSparse() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesSparse, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> setExercisesAndUnits(List<_i14.DayData>? entries) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#setExercisesAndUnits, [entries]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineSparse(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
Invocation.method(#fetchAndSetRoutineFullServer, [routineId]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
Invocation.method(#fetchAndSetRoutineFullServer, [routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineFull(int? routineId) =>
|
||||
_i8.Future<_i2.Routine> addRoutineServer(_i2.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
Invocation.method(#addRoutineServer, [routine]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
Invocation.method(#addRoutineServer, [routine]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> addRoutine(_i3.Routine? routine) =>
|
||||
_i8.Future<_i2.Routine> editRoutineServer(_i2.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addRoutine, [routine]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(this, Invocation.method(#addRoutine, [routine])),
|
||||
Invocation.method(#editRoutineServer, [routine]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#editRoutineServer, [routine]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editRoutine(_i3.Routine? routine) =>
|
||||
_i8.Future<void> deleteRoutineServer(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editRoutine, [routine]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteRoutineServer, [id]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteRoutine(int? id) =>
|
||||
_i8.Future<_i3.Day> addDayServer(_i3.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteRoutine, [id]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i4.Day> addDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addDay, [day]),
|
||||
returnValue: _i13.Future<_i4.Day>.value(
|
||||
_FakeDay_2(this, Invocation.method(#addDay, [day])),
|
||||
Invocation.method(#addDayServer, [day]),
|
||||
returnValue: _i8.Future<_i3.Day>.value(
|
||||
_FakeDay_1(this, Invocation.method(#addDayServer, [day])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i4.Day>);
|
||||
as _i8.Future<_i3.Day>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDay(_i4.Day? day) =>
|
||||
_i8.Future<void> editDayServer(_i3.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDay, [day]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#editDayServer, [day]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDays(List<_i4.Day>? days) =>
|
||||
_i8.Future<void> deleteDayServer(int? dayId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDays, [days]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteDayServer, [dayId]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteDay(int? dayId) =>
|
||||
_i8.Future<_i4.Slot> addSlotServer(_i4.Slot? slot) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteDay, [dayId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i5.Slot> addSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<_i5.Slot>.value(
|
||||
_FakeSlot_3(this, Invocation.method(#addSlot, [slot, routineId])),
|
||||
Invocation.method(#addSlotServer, [slot]),
|
||||
returnValue: _i8.Future<_i4.Slot>.value(
|
||||
_FakeSlot_2(this, Invocation.method(#addSlotServer, [slot])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i5.Slot>);
|
||||
as _i8.Future<_i4.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId, int? routineId) =>
|
||||
_i8.Future<void> deleteSlotServer(int? slotId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlot, [slotId, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteSlotServer, [slotId]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i5.Slot? slot, int? routineId) =>
|
||||
_i8.Future<void> editSlotServer(_i4.Slot? slot) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#editSlotServer, [slot]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlots(List<_i5.Slot>? slots, int? routineId) =>
|
||||
_i8.Future<_i5.SlotEntry> addSlotEntryServer(_i5.SlotEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlots, [slots, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#addSlotEntryServer, [entry]),
|
||||
returnValue: _i8.Future<_i5.SlotEntry>.value(
|
||||
_FakeSlotEntry_3(
|
||||
this,
|
||||
Invocation.method(#addSlotEntryServer, [entry]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<_i5.SlotEntry>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i6.SlotEntry> addSlotEntry(
|
||||
_i6.SlotEntry? entry,
|
||||
int? routineId,
|
||||
_i8.Future<void> deleteSlotEntryServer(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntryServer, [id]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<void> editSlotEntryServer(_i5.SlotEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntryServer, [entry]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i6.BaseConfig> editConfigServer(
|
||||
_i6.BaseConfig? config,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<_i6.SlotEntry>.value(
|
||||
_FakeSlotEntry_4(
|
||||
Invocation.method(#editConfigServer, [config, type]),
|
||||
returnValue: _i8.Future<_i6.BaseConfig>.value(
|
||||
_FakeBaseConfig_4(
|
||||
this,
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
Invocation.method(#editConfigServer, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i6.SlotEntry>);
|
||||
as _i8.Future<_i6.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntry, [id, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlotEntry(_i6.SlotEntry? entry, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
returnValue: _i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
),
|
||||
)
|
||||
as String);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> editConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
_i8.Future<_i6.BaseConfig> addConfigServer(
|
||||
_i6.BaseConfig? config,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
Invocation.method(#addConfigServer, [config, type]),
|
||||
returnValue: _i8.Future<_i6.BaseConfig>.value(
|
||||
_FakeBaseConfig_4(
|
||||
this,
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
Invocation.method(#addConfigServer, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
as _i8.Future<_i6.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> addConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
_i8.Future<void> deleteConfigServer(int? id, _i5.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
Invocation.method(#deleteConfigServer, [id, type]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteConfig(int? id, _i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteConfig, [id, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> handleConfig(
|
||||
_i6.SlotEntry? entry,
|
||||
_i8.Future<void> handleConfigServer(
|
||||
_i5.SlotEntry? entry,
|
||||
num? value,
|
||||
_i6.ConfigType? type,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#handleConfig, [entry, value, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#handleConfigServer, [entry, value, type]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#addListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#removeListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(#dispose, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(#notifyListeners, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
as _i8.Future<void>);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 wger Team
|
||||
* Copyright (C) 2020, 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
|
||||
@@ -36,29 +36,32 @@ import 'package:wger/widgets/routines/workout_logs.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
import 'routine_logs_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RoutinesProvider, WorkoutLogRepository])
|
||||
@GenerateMocks([WorkoutLogRepository])
|
||||
void main() {
|
||||
late Routine routine;
|
||||
final mockRoutinesProvider = MockRoutinesProvider();
|
||||
final mockWorkoutLogRepository = MockWorkoutLogRepository();
|
||||
|
||||
setUp(() {
|
||||
routine = getTestRoutine();
|
||||
routine.sessions[0].date = DateTime(2025, 3, 29);
|
||||
|
||||
when(mockRoutinesProvider.findById(any)).thenAnswer((_) => routine);
|
||||
when(mockWorkoutLogRepository.deleteLocalDrift(any)).thenAnswer((_) async => Future.value());
|
||||
});
|
||||
|
||||
Widget renderWidget({locale = 'en', isOnline = true}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
return ProviderScope(
|
||||
final container = ProviderContainer.test(
|
||||
overrides: [
|
||||
networkStatusProvider.overrideWithValue(isOnline),
|
||||
workoutLogRepositoryProvider.overrideWithValue(mockWorkoutLogRepository),
|
||||
routinesChangeProvider.overrideWithValue(mockRoutinesProvider),
|
||||
],
|
||||
);
|
||||
|
||||
container.read(routinesRiverpodProvider.notifier).state = RoutinesState(routines: [routine]);
|
||||
|
||||
return UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
|
||||
@@ -3,25 +3,11 @@
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i13;
|
||||
import 'dart:ui' as _i16;
|
||||
import 'dart:async' as _i3;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i12;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i7;
|
||||
import 'package:wger/models/workouts/day.dart' as _i4;
|
||||
import 'package:wger/models/workouts/day_data.dart' as _i14;
|
||||
import 'package:wger/models/workouts/log.dart' as _i18;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i11;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i3;
|
||||
import 'package:wger/models/workouts/session.dart' as _i10;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i5;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i6;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i9;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/routines.dart' as _i8;
|
||||
import 'package:wger/providers/workout_log_repository.dart' as _i17;
|
||||
import 'package:wger/models/workouts/log.dart' as _i4;
|
||||
import 'package:wger/providers/workout_log_repository.dart' as _i2;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -37,476 +23,46 @@ import 'package:wger/providers/workout_log_repository.dart' as _i17;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
|
||||
: super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeRoutine_1 extends _i1.SmartFake implements _i3.Routine {
|
||||
_FakeRoutine_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeDay_2 extends _i1.SmartFake implements _i4.Day {
|
||||
_FakeDay_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlot_3 extends _i1.SmartFake implements _i5.Slot {
|
||||
_FakeSlot_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlotEntry_4 extends _i1.SmartFake implements _i6.SlotEntry {
|
||||
_FakeSlotEntry_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeBaseConfig_5 extends _i1.SmartFake implements _i7.BaseConfig {
|
||||
_FakeBaseConfig_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [RoutinesProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockRoutinesProvider extends _i1.Mock implements _i8.RoutinesProvider {
|
||||
MockRoutinesProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.WgerBaseProvider get baseProvider =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(
|
||||
this,
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
)
|
||||
as _i2.WgerBaseProvider);
|
||||
|
||||
@override
|
||||
List<_i9.WeightUnit> get weightUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#weightUnits),
|
||||
returnValue: <_i9.WeightUnit>[],
|
||||
)
|
||||
as List<_i9.WeightUnit>);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> get sessions =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#sessions),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> get routines =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#routines),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
List<_i11.RepetitionUnit> get repetitionUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#repetitionUnits),
|
||||
returnValue: <_i11.RepetitionUnit>[],
|
||||
)
|
||||
as List<_i11.RepetitionUnit>);
|
||||
|
||||
@override
|
||||
set activeRoutine(_i3.Routine? _activeRoutine) => super.noSuchMethod(
|
||||
Invocation.setter(#activeRoutine, _activeRoutine),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set exercises(List<_i12.Exercise>? exercises) => super.noSuchMethod(
|
||||
Invocation.setter(#exercises, exercises),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set repetitionUnits(List<_i11.RepetitionUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#repetitionUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set weightUnits(List<_i9.WeightUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#weightUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set sessions(List<_i10.WorkoutSession>? sessions) => super.noSuchMethod(
|
||||
Invocation.setter(#sessions, sessions),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners =>
|
||||
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> getSessionsForRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getSessionsForRoutine, [id]),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(#clear, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> getPlans() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getPlans, []),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i3.Routine findById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findById, [id]),
|
||||
returnValue: _FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#findById, [id]),
|
||||
),
|
||||
)
|
||||
as _i3.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findIndexById, [id]),
|
||||
returnValue: 0,
|
||||
)
|
||||
as int);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesFull() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesFull, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesSparse() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesSparse, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> setExercisesAndUnits(List<_i14.DayData>? entries) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#setExercisesAndUnits, [entries]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineSparse(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineFull(int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> addRoutine(_i3.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addRoutine, [routine]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(this, Invocation.method(#addRoutine, [routine])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editRoutine(_i3.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editRoutine, [routine]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteRoutine, [id]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i4.Day> addDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addDay, [day]),
|
||||
returnValue: _i13.Future<_i4.Day>.value(
|
||||
_FakeDay_2(this, Invocation.method(#addDay, [day])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i4.Day>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDay, [day]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDays(List<_i4.Day>? days) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDays, [days]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteDay(int? dayId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteDay, [dayId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i5.Slot> addSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<_i5.Slot>.value(
|
||||
_FakeSlot_3(this, Invocation.method(#addSlot, [slot, routineId])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i5.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlot, [slotId, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlots(List<_i5.Slot>? slots, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlots, [slots, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i6.SlotEntry> addSlotEntry(
|
||||
_i6.SlotEntry? entry,
|
||||
int? routineId,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<_i6.SlotEntry>.value(
|
||||
_FakeSlotEntry_4(
|
||||
this,
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i6.SlotEntry>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntry, [id, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlotEntry(_i6.SlotEntry? entry, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
returnValue: _i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
),
|
||||
)
|
||||
as String);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> editConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> addConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteConfig(int? id, _i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteConfig, [id, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> handleConfig(
|
||||
_i6.SlotEntry? entry,
|
||||
num? value,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#handleConfig, [entry, value, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#addListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#removeListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(#dispose, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(#notifyListeners, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
}
|
||||
|
||||
/// A class which mocks [WorkoutLogRepository].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockWorkoutLogRepository extends _i1.Mock implements _i17.WorkoutLogRepository {
|
||||
class MockWorkoutLogRepository extends _i1.Mock implements _i2.WorkoutLogRepository {
|
||||
MockWorkoutLogRepository() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i13.Stream<List<_i18.Log>> watchAllDrift() =>
|
||||
_i3.Stream<List<_i4.Log>> watchAllDrift() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#watchAllDrift, []),
|
||||
returnValue: _i13.Stream<List<_i18.Log>>.empty(),
|
||||
returnValue: _i3.Stream<List<_i4.Log>>.empty(),
|
||||
)
|
||||
as _i13.Stream<List<_i18.Log>>);
|
||||
as _i3.Stream<List<_i4.Log>>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteLocalDrift(String? id) =>
|
||||
_i3.Future<void> deleteLocalDrift(String? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteLocalDrift, [id]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
returnValue: _i3.Future<void>.value(),
|
||||
returnValueForMissingStub: _i3.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i3.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> updateLocalDrift(_i18.Log? log) =>
|
||||
_i3.Future<void> updateLocalDrift(_i4.Log? log) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#updateLocalDrift, [log]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
returnValue: _i3.Future<void>.value(),
|
||||
returnValueForMissingStub: _i3.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i3.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> addLocalDrift(_i18.Log? log) =>
|
||||
_i3.Future<void> addLocalDrift(_i4.Log? log) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addLocalDrift, [log]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
returnValue: _i3.Future<void>.value(),
|
||||
returnValueForMissingStub: _i3.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i3.Future<void>);
|
||||
}
|
||||
|
||||
@@ -19,53 +19,40 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart' as riverpod;
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/routines.dart';
|
||||
import 'package:wger/screens/routine_screen.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
import 'routine_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([WgerBaseProvider])
|
||||
void main() {
|
||||
final mockBaseProvider = MockWgerBaseProvider();
|
||||
|
||||
Widget renderWidget({locale = 'en'}) {
|
||||
final key = GlobalKey<NavigatorState>();
|
||||
|
||||
return riverpod.ProviderScope(
|
||||
child: ProviderScope(
|
||||
overrides: [
|
||||
routinesChangeProvider.overrideWithValue(
|
||||
RoutinesProvider(
|
||||
mockBaseProvider,
|
||||
entries: [getTestRoutine()],
|
||||
exercises: getTestExercises(),
|
||||
final container = ProviderContainer.test();
|
||||
container.read(routinesRiverpodProvider.notifier).state = RoutinesState(
|
||||
routines: [getTestRoutine()],
|
||||
);
|
||||
|
||||
return UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
navigatorKey: key,
|
||||
home: TextButton(
|
||||
onPressed: () => key.currentState!.push(
|
||||
MaterialPageRoute<void>(
|
||||
settings: const RouteSettings(arguments: 1),
|
||||
builder: (_) => const RoutineScreen(),
|
||||
),
|
||||
),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
navigatorKey: key,
|
||||
home: TextButton(
|
||||
onPressed: () => key.currentState!.push(
|
||||
MaterialPageRoute<void>(
|
||||
settings: const RouteSettings(arguments: 1),
|
||||
builder: (_) => const RoutineScreen(),
|
||||
),
|
||||
),
|
||||
child: const SizedBox(),
|
||||
),
|
||||
routes: {RoutineScreen.routeName: (ctx) => const RoutineScreen()},
|
||||
child: const SizedBox(),
|
||||
),
|
||||
routes: {RoutineScreen.routeName: (ctx) => const RoutineScreen()},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
// Mocks generated by Mockito 5.4.6 from annotations
|
||||
// in wger/test/routine/routine_screen_test.dart.
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i5;
|
||||
|
||||
import 'package:http/http.dart' as _i3;
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:wger/providers/auth.dart' as _i2;
|
||||
import 'package:wger/providers/base_provider.dart' as _i4;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
// ignore_for_file: avoid_setters_without_getters
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: deprecated_member_use
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||
// ignore_for_file: must_be_immutable
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
// ignore_for_file: unnecessary_parenthesis
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeAuthProvider_0 extends _i1.SmartFake implements _i2.AuthProvider {
|
||||
_FakeAuthProvider_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeClient_1 extends _i1.SmartFake implements _i3.Client {
|
||||
_FakeClient_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeUri_2 extends _i1.SmartFake implements Uri {
|
||||
_FakeUri_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeResponse_3 extends _i1.SmartFake implements _i3.Response {
|
||||
_FakeResponse_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [WgerBaseProvider].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockWgerBaseProvider extends _i1.Mock implements _i4.WgerBaseProvider {
|
||||
MockWgerBaseProvider() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.AuthProvider get auth =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#auth),
|
||||
returnValue: _FakeAuthProvider_0(this, Invocation.getter(#auth)),
|
||||
)
|
||||
as _i2.AuthProvider);
|
||||
|
||||
@override
|
||||
_i3.Client get client =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#client),
|
||||
returnValue: _FakeClient_1(this, Invocation.getter(#client)),
|
||||
)
|
||||
as _i3.Client);
|
||||
|
||||
@override
|
||||
set auth(_i2.AuthProvider? _auth) => super.noSuchMethod(
|
||||
Invocation.setter(#auth, _auth),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set client(_i3.Client? _client) => super.noSuchMethod(
|
||||
Invocation.setter(#client, _client),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, String> getDefaultHeaders({bool? includeAuth = false}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getDefaultHeaders, [], {
|
||||
#includeAuth: includeAuth,
|
||||
}),
|
||||
returnValue: <String, String>{},
|
||||
)
|
||||
as Map<String, String>);
|
||||
|
||||
@override
|
||||
Uri makeUrl(
|
||||
String? path, {
|
||||
int? id,
|
||||
String? objectMethod,
|
||||
Map<String, dynamic>? query,
|
||||
}) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{#id: id, #objectMethod: objectMethod, #query: query},
|
||||
),
|
||||
returnValue: _FakeUri_2(
|
||||
this,
|
||||
Invocation.method(
|
||||
#makeUrl,
|
||||
[path],
|
||||
{#id: id, #objectMethod: objectMethod, #query: query},
|
||||
),
|
||||
),
|
||||
)
|
||||
as Uri);
|
||||
|
||||
@override
|
||||
_i5.Future<dynamic> fetch(Uri? uri) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetch, [uri]),
|
||||
returnValue: _i5.Future<dynamic>.value(),
|
||||
)
|
||||
as _i5.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<dynamic>> fetchPaginated(Uri? uri) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchPaginated, [uri]),
|
||||
returnValue: _i5.Future<List<dynamic>>.value(<dynamic>[]),
|
||||
)
|
||||
as _i5.Future<List<dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> post(Map<String, dynamic>? data, Uri? uri) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#post, [data, uri]),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(
|
||||
<String, dynamic>{},
|
||||
),
|
||||
)
|
||||
as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, dynamic>> patch(
|
||||
Map<String, dynamic>? data,
|
||||
Uri? uri,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#patch, [data, uri]),
|
||||
returnValue: _i5.Future<Map<String, dynamic>>.value(
|
||||
<String, dynamic>{},
|
||||
),
|
||||
)
|
||||
as _i5.Future<Map<String, dynamic>>);
|
||||
|
||||
@override
|
||||
_i5.Future<_i3.Response> deleteRequest(String? url, int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteRequest, [url, id]),
|
||||
returnValue: _i5.Future<_i3.Response>.value(
|
||||
_FakeResponse_3(
|
||||
this,
|
||||
Invocation.method(#deleteRequest, [url, id]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i5.Future<_i3.Response>);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 wger Team
|
||||
* Copyright (C) 2020, 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
|
||||
@@ -22,16 +22,10 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
import 'package:wger/core/locator.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/models/workouts/routine.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
import 'package:wger/providers/routines.dart';
|
||||
|
||||
import '../../test_data/exercises.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
import '../fixtures/fixture_reader.dart';
|
||||
import 'routines_provider_test.mocks.dart';
|
||||
|
||||
@@ -39,21 +33,15 @@ import 'routines_provider_test.mocks.dart';
|
||||
void main() {
|
||||
final mockBaseProvider = MockWgerBaseProvider();
|
||||
|
||||
/// Replacement for SharedPreferences.setMockInitialValues()
|
||||
SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty();
|
||||
|
||||
setUpAll(() async {
|
||||
// Needs to be configured here, setUp runs on every test, setUpAll only once
|
||||
await ServiceLocator().configure();
|
||||
});
|
||||
|
||||
group('test the workout routine provider', () {
|
||||
test('Test fetching and setting a routine', () async {
|
||||
final uri = Uri.https('localhost', 'api/v2/routine/325397/');
|
||||
group('test the routine provider repository', () {
|
||||
test('Test creating a new routine', () async {
|
||||
// Arrange
|
||||
final repo = RoutinesRepository(mockBaseProvider);
|
||||
final uri = Uri.https('localhost', 'api/v2/routine/');
|
||||
when(
|
||||
mockBaseProvider.makeUrl('routine', id: 325397, query: {'limit': API_MAX_PAGE_SIZE}),
|
||||
mockBaseProvider.makeUrl('routine'),
|
||||
).thenReturn(uri);
|
||||
when(mockBaseProvider.fetch(uri)).thenAnswer(
|
||||
when(mockBaseProvider.post(any, uri)).thenAnswer(
|
||||
(_) async => Future.value({
|
||||
'id': 325397,
|
||||
'created': '2022-10-10',
|
||||
@@ -65,43 +53,34 @@ void main() {
|
||||
}),
|
||||
);
|
||||
|
||||
// Load the entries
|
||||
final provider = RoutinesProvider(mockBaseProvider, exercises: getTestExercises());
|
||||
final plan = await provider.fetchAndSetRoutineSparse(325397);
|
||||
final plans = provider.getPlans();
|
||||
// Act
|
||||
final plan = await repo.addRoutineServer(
|
||||
Routine(
|
||||
id: 325397,
|
||||
name: 'Test workout',
|
||||
description: 'Test workout abcd',
|
||||
),
|
||||
);
|
||||
|
||||
// Check that everything is ok
|
||||
// Assert
|
||||
expect(plan, isA<Routine>());
|
||||
expect(plan.id, 325397);
|
||||
expect(plan.description, 'Test workout abcd');
|
||||
expect(plans.length, 1);
|
||||
});
|
||||
|
||||
test('Test deleting a workout plan', () async {
|
||||
final uri = Uri.https('localhost', 'api/v2/workout/325397/');
|
||||
when(mockBaseProvider.makeUrl('workout', id: 325397)).thenReturn(uri);
|
||||
when(mockBaseProvider.fetch(uri)).thenAnswer(
|
||||
(_) async => Future.value({
|
||||
'id': 325397,
|
||||
'name': 'Test workout',
|
||||
'creation_date': '2022-10-10',
|
||||
'description': 'Test workout abcd',
|
||||
}),
|
||||
);
|
||||
// Arrange
|
||||
when(mockBaseProvider.deleteRequest('routine', 325397)).thenAnswer(
|
||||
(_) => Future.value(Response('', 204)),
|
||||
);
|
||||
|
||||
// Load the entries
|
||||
final provider = RoutinesProvider(mockBaseProvider, exercises: getTestExercises());
|
||||
|
||||
await provider.fetchAndSetRoutineSparse(325397);
|
||||
await provider.deleteRoutine(325397);
|
||||
final plans = provider.getPlans();
|
||||
expect(plans.length, 0);
|
||||
// Act
|
||||
final repo = RoutinesRepository(mockBaseProvider);
|
||||
await repo.deleteRoutineServer(325397);
|
||||
verify(mockBaseProvider.deleteRequest('routine', 325397)).called(1);
|
||||
});
|
||||
|
||||
test('Smoke test fetchAndSetRoutineFull', () async {
|
||||
test('Smoke test fetchAndSetRoutineFullServer', () async {
|
||||
//Arrange
|
||||
final structureUri = Uri.https('localhost', 'api/v2/routine/101/structure/');
|
||||
when(
|
||||
@@ -136,23 +115,10 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final logsUri = Uri.https('localhost', 'api/v2/routine/101/logs/');
|
||||
when(mockBaseProvider.makeUrl('routine', objectMethod: 'logs', id: 101)).thenReturn(logsUri);
|
||||
when(mockBaseProvider.fetch(logsUri)).thenAnswer(
|
||||
(_) async => Future.value(
|
||||
jsonDecode(fixture('routines/routine_logs.json')),
|
||||
),
|
||||
);
|
||||
|
||||
final provider = RoutinesProvider(
|
||||
mockBaseProvider,
|
||||
exercises: getTestExercises(),
|
||||
repetitionUnits: testRepetitionUnits,
|
||||
weightUnits: testWeightUnits,
|
||||
);
|
||||
final repo = RoutinesRepository(mockBaseProvider);
|
||||
|
||||
// Act
|
||||
final result = await provider.fetchAndSetRoutineFull(101);
|
||||
final result = await repo.fetchAndSetRoutineFullServer(101);
|
||||
|
||||
// Assert
|
||||
expect(result, isA<Routine>());
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart' as riverpod;
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
@@ -33,9 +33,9 @@ import 'package:wger/widgets/routines/forms/routine.dart';
|
||||
|
||||
import 'routines_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RoutinesProvider])
|
||||
@GenerateMocks([RoutinesRepository])
|
||||
void main() {
|
||||
MockRoutinesProvider mockRoutinesProvider = MockRoutinesProvider();
|
||||
late MockRoutinesRepository mockRoutinesRepository;
|
||||
|
||||
final routine1 = Routine(
|
||||
id: 1,
|
||||
@@ -56,24 +56,23 @@ void main() {
|
||||
);
|
||||
|
||||
setUp(() {
|
||||
mockRoutinesProvider = MockRoutinesProvider();
|
||||
mockRoutinesRepository = MockRoutinesRepository();
|
||||
when(mockRoutinesRepository.editDayServer(any)).thenAnswer((_) async => {});
|
||||
});
|
||||
|
||||
Widget renderWidget({locale = 'en', isOnline = true}) {
|
||||
when(mockRoutinesProvider.fetchAndSetRoutineFull(any)).thenAnswer(
|
||||
(_) async => routine1,
|
||||
);
|
||||
when(mockRoutinesProvider.routines).thenReturn([
|
||||
routine1,
|
||||
routine2,
|
||||
]);
|
||||
when(mockRoutinesProvider.findById(1)).thenReturn(routine1);
|
||||
|
||||
return riverpod.ProviderScope(
|
||||
final container = ProviderContainer.test(
|
||||
overrides: [
|
||||
networkStatusProvider.overrideWithValue(isOnline),
|
||||
routinesChangeProvider.overrideWithValue(mockRoutinesProvider),
|
||||
routinesRepositoryProvider.overrideWithValue(mockRoutinesRepository),
|
||||
],
|
||||
);
|
||||
container.read(routinesRiverpodProvider.notifier).state = RoutinesState(
|
||||
routines: [routine1, routine2],
|
||||
);
|
||||
|
||||
return UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -109,17 +108,17 @@ void main() {
|
||||
// Confirm
|
||||
await tester.tap(find.text('Delete'));
|
||||
await tester.pumpAndSettle();
|
||||
verify(mockRoutinesProvider.deleteRoutine(1)).called(1);
|
||||
verify(mockRoutinesRepository.deleteRoutineServer(1)).called(1);
|
||||
});
|
||||
|
||||
testWidgets('Handle offline status', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(renderWidget(isOnline: false));
|
||||
await tester.tap(find.byIcon(Icons.delete).first);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// No confirmation dialog (button is disabled)
|
||||
expect(find.byType(AlertDialog), findsNothing);
|
||||
verifyNever(mockRoutinesProvider.deleteRoutine(1));
|
||||
final deleteButton = tester.widget<IconButton>(
|
||||
find.widgetWithIcon(IconButton, Icons.delete).first,
|
||||
);
|
||||
expect(deleteButton.onPressed, isNull);
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -128,7 +127,7 @@ void main() {
|
||||
await tester.fling(find.byKey(const Key('1')), const Offset(0, 300), 1000);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
//verify(mockRoutinesProvider.fetchAndSetAllPlansSparse());
|
||||
//verify(mockRoutinesRepository.fetchAndSetAllPlansSparse());
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
@@ -3,23 +3,15 @@
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i13;
|
||||
import 'dart:ui' as _i16;
|
||||
import 'dart:async' as _i8;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i12;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i7;
|
||||
import 'package:wger/models/workouts/day.dart' as _i4;
|
||||
import 'package:wger/models/workouts/day_data.dart' as _i14;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i11;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i3;
|
||||
import 'package:wger/models/workouts/session.dart' as _i10;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i5;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i6;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i9;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/routines.dart' as _i8;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i6;
|
||||
import 'package:wger/models/workouts/day.dart' as _i3;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i2;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i4;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i5;
|
||||
import 'package:wger/providers/routines.dart' as _i7;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -35,432 +27,228 @@ import 'package:wger/providers/routines.dart' as _i8;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
|
||||
: super(parent, parentInvocation);
|
||||
class _FakeRoutine_0 extends _i1.SmartFake implements _i2.Routine {
|
||||
_FakeRoutine_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeRoutine_1 extends _i1.SmartFake implements _i3.Routine {
|
||||
_FakeRoutine_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeDay_1 extends _i1.SmartFake implements _i3.Day {
|
||||
_FakeDay_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeDay_2 extends _i1.SmartFake implements _i4.Day {
|
||||
_FakeDay_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeSlot_2 extends _i1.SmartFake implements _i4.Slot {
|
||||
_FakeSlot_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlot_3 extends _i1.SmartFake implements _i5.Slot {
|
||||
_FakeSlot_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeSlotEntry_3 extends _i1.SmartFake implements _i5.SlotEntry {
|
||||
_FakeSlotEntry_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlotEntry_4 extends _i1.SmartFake implements _i6.SlotEntry {
|
||||
_FakeSlotEntry_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeBaseConfig_4 extends _i1.SmartFake implements _i6.BaseConfig {
|
||||
_FakeBaseConfig_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeBaseConfig_5 extends _i1.SmartFake implements _i7.BaseConfig {
|
||||
_FakeBaseConfig_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [RoutinesProvider].
|
||||
/// A class which mocks [RoutinesRepository].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockRoutinesProvider extends _i1.Mock implements _i8.RoutinesProvider {
|
||||
MockRoutinesProvider() {
|
||||
class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository {
|
||||
MockRoutinesRepository() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.WgerBaseProvider get baseProvider =>
|
||||
_i8.Future<List<_i2.Routine>> fetchAllRoutinesSparseServer() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(
|
||||
this,
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
Invocation.method(#fetchAllRoutinesSparseServer, []),
|
||||
returnValue: _i8.Future<List<_i2.Routine>>.value(<_i2.Routine>[]),
|
||||
)
|
||||
as _i2.WgerBaseProvider);
|
||||
as _i8.Future<List<_i2.Routine>>);
|
||||
|
||||
@override
|
||||
List<_i9.WeightUnit> get weightUnits =>
|
||||
_i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#weightUnits),
|
||||
returnValue: <_i9.WeightUnit>[],
|
||||
)
|
||||
as List<_i9.WeightUnit>);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> get sessions =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#sessions),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> get routines =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#routines),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
List<_i11.RepetitionUnit> get repetitionUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#repetitionUnits),
|
||||
returnValue: <_i11.RepetitionUnit>[],
|
||||
)
|
||||
as List<_i11.RepetitionUnit>);
|
||||
|
||||
@override
|
||||
set activeRoutine(_i3.Routine? _activeRoutine) => super.noSuchMethod(
|
||||
Invocation.setter(#activeRoutine, _activeRoutine),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set exercises(List<_i12.Exercise>? exercises) => super.noSuchMethod(
|
||||
Invocation.setter(#exercises, exercises),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set repetitionUnits(List<_i11.RepetitionUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#repetitionUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set weightUnits(List<_i9.WeightUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#weightUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set sessions(List<_i10.WorkoutSession>? sessions) => super.noSuchMethod(
|
||||
Invocation.setter(#sessions, sessions),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners =>
|
||||
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> getSessionsForRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getSessionsForRoutine, [id]),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(#clear, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> getPlans() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getPlans, []),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i3.Routine findById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findById, [id]),
|
||||
returnValue: _FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#findById, [id]),
|
||||
),
|
||||
)
|
||||
as _i3.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findIndexById, [id]),
|
||||
returnValue: 0,
|
||||
)
|
||||
as int);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesFull() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesFull, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesSparse() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesSparse, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> setExercisesAndUnits(List<_i14.DayData>? entries) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#setExercisesAndUnits, [entries]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineSparse(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
Invocation.method(#fetchAndSetRoutineFullServer, [routineId]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
Invocation.method(#fetchAndSetRoutineFullServer, [routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineFull(int? routineId) =>
|
||||
_i8.Future<_i2.Routine> addRoutineServer(_i2.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
Invocation.method(#addRoutineServer, [routine]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
Invocation.method(#addRoutineServer, [routine]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> addRoutine(_i3.Routine? routine) =>
|
||||
_i8.Future<_i2.Routine> editRoutineServer(_i2.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addRoutine, [routine]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(this, Invocation.method(#addRoutine, [routine])),
|
||||
Invocation.method(#editRoutineServer, [routine]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#editRoutineServer, [routine]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editRoutine(_i3.Routine? routine) =>
|
||||
_i8.Future<void> deleteRoutineServer(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editRoutine, [routine]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteRoutineServer, [id]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteRoutine(int? id) =>
|
||||
_i8.Future<_i3.Day> addDayServer(_i3.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteRoutine, [id]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i4.Day> addDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addDay, [day]),
|
||||
returnValue: _i13.Future<_i4.Day>.value(
|
||||
_FakeDay_2(this, Invocation.method(#addDay, [day])),
|
||||
Invocation.method(#addDayServer, [day]),
|
||||
returnValue: _i8.Future<_i3.Day>.value(
|
||||
_FakeDay_1(this, Invocation.method(#addDayServer, [day])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i4.Day>);
|
||||
as _i8.Future<_i3.Day>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDay(_i4.Day? day) =>
|
||||
_i8.Future<void> editDayServer(_i3.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDay, [day]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#editDayServer, [day]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDays(List<_i4.Day>? days) =>
|
||||
_i8.Future<void> deleteDayServer(int? dayId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDays, [days]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteDayServer, [dayId]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteDay(int? dayId) =>
|
||||
_i8.Future<_i4.Slot> addSlotServer(_i4.Slot? slot) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteDay, [dayId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i5.Slot> addSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<_i5.Slot>.value(
|
||||
_FakeSlot_3(this, Invocation.method(#addSlot, [slot, routineId])),
|
||||
Invocation.method(#addSlotServer, [slot]),
|
||||
returnValue: _i8.Future<_i4.Slot>.value(
|
||||
_FakeSlot_2(this, Invocation.method(#addSlotServer, [slot])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i5.Slot>);
|
||||
as _i8.Future<_i4.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId, int? routineId) =>
|
||||
_i8.Future<void> deleteSlotServer(int? slotId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlot, [slotId, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteSlotServer, [slotId]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i5.Slot? slot, int? routineId) =>
|
||||
_i8.Future<void> editSlotServer(_i4.Slot? slot) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#editSlotServer, [slot]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlots(List<_i5.Slot>? slots, int? routineId) =>
|
||||
_i8.Future<_i5.SlotEntry> addSlotEntryServer(_i5.SlotEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlots, [slots, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#addSlotEntryServer, [entry]),
|
||||
returnValue: _i8.Future<_i5.SlotEntry>.value(
|
||||
_FakeSlotEntry_3(
|
||||
this,
|
||||
Invocation.method(#addSlotEntryServer, [entry]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<_i5.SlotEntry>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i6.SlotEntry> addSlotEntry(
|
||||
_i6.SlotEntry? entry,
|
||||
int? routineId,
|
||||
_i8.Future<void> deleteSlotEntryServer(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntryServer, [id]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<void> editSlotEntryServer(_i5.SlotEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntryServer, [entry]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i6.BaseConfig> editConfigServer(
|
||||
_i6.BaseConfig? config,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<_i6.SlotEntry>.value(
|
||||
_FakeSlotEntry_4(
|
||||
Invocation.method(#editConfigServer, [config, type]),
|
||||
returnValue: _i8.Future<_i6.BaseConfig>.value(
|
||||
_FakeBaseConfig_4(
|
||||
this,
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
Invocation.method(#editConfigServer, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i6.SlotEntry>);
|
||||
as _i8.Future<_i6.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntry, [id, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlotEntry(_i6.SlotEntry? entry, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
returnValue: _i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
),
|
||||
)
|
||||
as String);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> editConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
_i8.Future<_i6.BaseConfig> addConfigServer(
|
||||
_i6.BaseConfig? config,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
Invocation.method(#addConfigServer, [config, type]),
|
||||
returnValue: _i8.Future<_i6.BaseConfig>.value(
|
||||
_FakeBaseConfig_4(
|
||||
this,
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
Invocation.method(#addConfigServer, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
as _i8.Future<_i6.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> addConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
_i8.Future<void> deleteConfigServer(int? id, _i5.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
Invocation.method(#deleteConfigServer, [id, type]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteConfig(int? id, _i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteConfig, [id, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> handleConfig(
|
||||
_i6.SlotEntry? entry,
|
||||
_i8.Future<void> handleConfigServer(
|
||||
_i5.SlotEntry? entry,
|
||||
num? value,
|
||||
_i6.ConfigType? type,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#handleConfig, [entry, value, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#handleConfigServer, [entry, value, type]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#addListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#removeListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(#dispose, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(#notifyListeners, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
as _i8.Future<void>);
|
||||
}
|
||||
|
||||
@@ -33,14 +33,18 @@ import 'package:wger/widgets/routines/forms/weight_unit.dart';
|
||||
import '../../test_data/routines.dart';
|
||||
import './slot_entry_form_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RoutinesProvider])
|
||||
@GenerateMocks([RoutinesRepository])
|
||||
void main() {
|
||||
var mockRoutinesProvider = MockRoutinesProvider();
|
||||
|
||||
final slotEntry = getTestRoutine().days[0].slots[0].entries[0];
|
||||
late MockRoutinesRepository mockRoutinesRepository;
|
||||
late SlotEntry slotEntry;
|
||||
|
||||
setUp(() {
|
||||
mockRoutinesProvider = MockRoutinesProvider();
|
||||
slotEntry = getTestRoutine().days[0].slots[0].entries[0];
|
||||
|
||||
mockRoutinesRepository = MockRoutinesRepository();
|
||||
when(
|
||||
mockRoutinesRepository.fetchAndSetRoutineFullServer(any),
|
||||
).thenAnswer((_) => Future.value(getTestRoutine()));
|
||||
});
|
||||
|
||||
Widget renderWidget({simpleMode = true, locale = 'en'}) {
|
||||
@@ -54,7 +58,7 @@ void main() {
|
||||
routineRepetitionUnitProvider.overrideWithValue(
|
||||
const AsyncValue.data(testRepetitionUnits),
|
||||
),
|
||||
routinesChangeProvider.overrideWithValue(mockRoutinesProvider),
|
||||
routinesRepositoryProvider.overrideWithValue(mockRoutinesRepository),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: Locale(locale),
|
||||
@@ -125,7 +129,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
verify(
|
||||
mockRoutinesProvider.editSlotEntry(
|
||||
mockRoutinesRepository.editSlotEntryServer(
|
||||
argThat(
|
||||
isA<SlotEntry>()
|
||||
.having((d) => d.id, 'id', null)
|
||||
@@ -133,12 +137,11 @@ void main() {
|
||||
.having((d) => d.order, 'order', 1)
|
||||
.having((d) => d.type, 'type', SlotEntryType.myo),
|
||||
),
|
||||
1,
|
||||
),
|
||||
);
|
||||
|
||||
final verification = verify(
|
||||
mockRoutinesProvider.handleConfig(captureAny, captureAny, captureAny),
|
||||
mockRoutinesRepository.handleConfigServer(captureAny, captureAny, captureAny),
|
||||
);
|
||||
final capturedArgs = verification.captured; // List with 8*3 arguments (3 per call)
|
||||
|
||||
|
||||
@@ -3,23 +3,15 @@
|
||||
// Do not manually edit this file.
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'dart:async' as _i13;
|
||||
import 'dart:ui' as _i16;
|
||||
import 'dart:async' as _i8;
|
||||
|
||||
import 'package:mockito/mockito.dart' as _i1;
|
||||
import 'package:mockito/src/dummies.dart' as _i15;
|
||||
import 'package:wger/models/exercises/exercise.dart' as _i12;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i7;
|
||||
import 'package:wger/models/workouts/day.dart' as _i4;
|
||||
import 'package:wger/models/workouts/day_data.dart' as _i14;
|
||||
import 'package:wger/models/workouts/repetition_unit.dart' as _i11;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i3;
|
||||
import 'package:wger/models/workouts/session.dart' as _i10;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i5;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i6;
|
||||
import 'package:wger/models/workouts/weight_unit.dart' as _i9;
|
||||
import 'package:wger/providers/base_provider.dart' as _i2;
|
||||
import 'package:wger/providers/routines.dart' as _i8;
|
||||
import 'package:wger/models/workouts/base_config.dart' as _i6;
|
||||
import 'package:wger/models/workouts/day.dart' as _i3;
|
||||
import 'package:wger/models/workouts/routine.dart' as _i2;
|
||||
import 'package:wger/models/workouts/slot.dart' as _i4;
|
||||
import 'package:wger/models/workouts/slot_entry.dart' as _i5;
|
||||
import 'package:wger/providers/routines.dart' as _i7;
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
@@ -35,432 +27,228 @@ import 'package:wger/providers/routines.dart' as _i8;
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: subtype_of_sealed_class
|
||||
|
||||
class _FakeWgerBaseProvider_0 extends _i1.SmartFake implements _i2.WgerBaseProvider {
|
||||
_FakeWgerBaseProvider_0(Object parent, Invocation parentInvocation)
|
||||
: super(parent, parentInvocation);
|
||||
class _FakeRoutine_0 extends _i1.SmartFake implements _i2.Routine {
|
||||
_FakeRoutine_0(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeRoutine_1 extends _i1.SmartFake implements _i3.Routine {
|
||||
_FakeRoutine_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeDay_1 extends _i1.SmartFake implements _i3.Day {
|
||||
_FakeDay_1(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeDay_2 extends _i1.SmartFake implements _i4.Day {
|
||||
_FakeDay_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeSlot_2 extends _i1.SmartFake implements _i4.Slot {
|
||||
_FakeSlot_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlot_3 extends _i1.SmartFake implements _i5.Slot {
|
||||
_FakeSlot_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeSlotEntry_3 extends _i1.SmartFake implements _i5.SlotEntry {
|
||||
_FakeSlotEntry_3(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeSlotEntry_4 extends _i1.SmartFake implements _i6.SlotEntry {
|
||||
_FakeSlotEntry_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
class _FakeBaseConfig_4 extends _i1.SmartFake implements _i6.BaseConfig {
|
||||
_FakeBaseConfig_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
class _FakeBaseConfig_5 extends _i1.SmartFake implements _i7.BaseConfig {
|
||||
_FakeBaseConfig_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation);
|
||||
}
|
||||
|
||||
/// A class which mocks [RoutinesProvider].
|
||||
/// A class which mocks [RoutinesRepository].
|
||||
///
|
||||
/// See the documentation for Mockito's code generation for more information.
|
||||
class MockRoutinesProvider extends _i1.Mock implements _i8.RoutinesProvider {
|
||||
MockRoutinesProvider() {
|
||||
class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository {
|
||||
MockRoutinesRepository() {
|
||||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i2.WgerBaseProvider get baseProvider =>
|
||||
_i8.Future<List<_i2.Routine>> fetchAllRoutinesSparseServer() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#baseProvider),
|
||||
returnValue: _FakeWgerBaseProvider_0(
|
||||
this,
|
||||
Invocation.getter(#baseProvider),
|
||||
),
|
||||
Invocation.method(#fetchAllRoutinesSparseServer, []),
|
||||
returnValue: _i8.Future<List<_i2.Routine>>.value(<_i2.Routine>[]),
|
||||
)
|
||||
as _i2.WgerBaseProvider);
|
||||
as _i8.Future<List<_i2.Routine>>);
|
||||
|
||||
@override
|
||||
List<_i9.WeightUnit> get weightUnits =>
|
||||
_i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#weightUnits),
|
||||
returnValue: <_i9.WeightUnit>[],
|
||||
)
|
||||
as List<_i9.WeightUnit>);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> get sessions =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#sessions),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> get routines =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#routines),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
List<_i11.RepetitionUnit> get repetitionUnits =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.getter(#repetitionUnits),
|
||||
returnValue: <_i11.RepetitionUnit>[],
|
||||
)
|
||||
as List<_i11.RepetitionUnit>);
|
||||
|
||||
@override
|
||||
set activeRoutine(_i3.Routine? _activeRoutine) => super.noSuchMethod(
|
||||
Invocation.setter(#activeRoutine, _activeRoutine),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set exercises(List<_i12.Exercise>? exercises) => super.noSuchMethod(
|
||||
Invocation.setter(#exercises, exercises),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set repetitionUnits(List<_i11.RepetitionUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#repetitionUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set weightUnits(List<_i9.WeightUnit>? units) => super.noSuchMethod(
|
||||
Invocation.setter(#weightUnits, units),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
set sessions(List<_i10.WorkoutSession>? sessions) => super.noSuchMethod(
|
||||
Invocation.setter(#sessions, sessions),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get hasListeners =>
|
||||
(super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool);
|
||||
|
||||
@override
|
||||
List<_i10.WorkoutSession> getSessionsForRoutine(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getSessionsForRoutine, [id]),
|
||||
returnValue: <_i10.WorkoutSession>[],
|
||||
)
|
||||
as List<_i10.WorkoutSession>);
|
||||
|
||||
@override
|
||||
void clear() => super.noSuchMethod(
|
||||
Invocation.method(#clear, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<_i3.Routine> getPlans() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getPlans, []),
|
||||
returnValue: <_i3.Routine>[],
|
||||
)
|
||||
as List<_i3.Routine>);
|
||||
|
||||
@override
|
||||
_i3.Routine findById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findById, [id]),
|
||||
returnValue: _FakeRoutine_1(
|
||||
this,
|
||||
Invocation.method(#findById, [id]),
|
||||
),
|
||||
)
|
||||
as _i3.Routine);
|
||||
|
||||
@override
|
||||
int findIndexById(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#findIndexById, [id]),
|
||||
returnValue: 0,
|
||||
)
|
||||
as int);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesFull() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesFull, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchAndSetAllRoutinesSparse() =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetAllRoutinesSparse, []),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> setExercisesAndUnits(List<_i14.DayData>? entries) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#setExercisesAndUnits, [entries]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineSparse(int? planId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
Invocation.method(#fetchAndSetRoutineFullServer, [routineId]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineSparse, [planId]),
|
||||
Invocation.method(#fetchAndSetRoutineFullServer, [routineId]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> fetchAndSetRoutineFull(int? routineId) =>
|
||||
_i8.Future<_i2.Routine> addRoutineServer(_i2.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(
|
||||
Invocation.method(#addRoutineServer, [routine]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#fetchAndSetRoutineFull, [routineId]),
|
||||
Invocation.method(#addRoutineServer, [routine]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i3.Routine> addRoutine(_i3.Routine? routine) =>
|
||||
_i8.Future<_i2.Routine> editRoutineServer(_i2.Routine? routine) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addRoutine, [routine]),
|
||||
returnValue: _i13.Future<_i3.Routine>.value(
|
||||
_FakeRoutine_1(this, Invocation.method(#addRoutine, [routine])),
|
||||
Invocation.method(#editRoutineServer, [routine]),
|
||||
returnValue: _i8.Future<_i2.Routine>.value(
|
||||
_FakeRoutine_0(
|
||||
this,
|
||||
Invocation.method(#editRoutineServer, [routine]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i3.Routine>);
|
||||
as _i8.Future<_i2.Routine>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editRoutine(_i3.Routine? routine) =>
|
||||
_i8.Future<void> deleteRoutineServer(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editRoutine, [routine]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteRoutineServer, [id]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteRoutine(int? id) =>
|
||||
_i8.Future<_i3.Day> addDayServer(_i3.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteRoutine, [id]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i4.Day> addDay(_i4.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addDay, [day]),
|
||||
returnValue: _i13.Future<_i4.Day>.value(
|
||||
_FakeDay_2(this, Invocation.method(#addDay, [day])),
|
||||
Invocation.method(#addDayServer, [day]),
|
||||
returnValue: _i8.Future<_i3.Day>.value(
|
||||
_FakeDay_1(this, Invocation.method(#addDayServer, [day])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i4.Day>);
|
||||
as _i8.Future<_i3.Day>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDay(_i4.Day? day) =>
|
||||
_i8.Future<void> editDayServer(_i3.Day? day) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDay, [day]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#editDayServer, [day]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editDays(List<_i4.Day>? days) =>
|
||||
_i8.Future<void> deleteDayServer(int? dayId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editDays, [days]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteDayServer, [dayId]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteDay(int? dayId) =>
|
||||
_i8.Future<_i4.Slot> addSlotServer(_i4.Slot? slot) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteDay, [dayId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i5.Slot> addSlot(_i5.Slot? slot, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<_i5.Slot>.value(
|
||||
_FakeSlot_3(this, Invocation.method(#addSlot, [slot, routineId])),
|
||||
Invocation.method(#addSlotServer, [slot]),
|
||||
returnValue: _i8.Future<_i4.Slot>.value(
|
||||
_FakeSlot_2(this, Invocation.method(#addSlotServer, [slot])),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i5.Slot>);
|
||||
as _i8.Future<_i4.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId, int? routineId) =>
|
||||
_i8.Future<void> deleteSlotServer(int? slotId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlot, [slotId, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#deleteSlotServer, [slotId]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i5.Slot? slot, int? routineId) =>
|
||||
_i8.Future<void> editSlotServer(_i4.Slot? slot) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlot, [slot, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#editSlotServer, [slot]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlots(List<_i5.Slot>? slots, int? routineId) =>
|
||||
_i8.Future<_i5.SlotEntry> addSlotEntryServer(_i5.SlotEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlots, [slots, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#addSlotEntryServer, [entry]),
|
||||
returnValue: _i8.Future<_i5.SlotEntry>.value(
|
||||
_FakeSlotEntry_3(
|
||||
this,
|
||||
Invocation.method(#addSlotEntryServer, [entry]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
as _i8.Future<_i5.SlotEntry>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i6.SlotEntry> addSlotEntry(
|
||||
_i6.SlotEntry? entry,
|
||||
int? routineId,
|
||||
_i8.Future<void> deleteSlotEntryServer(int? id) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntryServer, [id]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<void> editSlotEntryServer(_i5.SlotEntry? entry) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntryServer, [entry]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i8.Future<_i6.BaseConfig> editConfigServer(
|
||||
_i6.BaseConfig? config,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<_i6.SlotEntry>.value(
|
||||
_FakeSlotEntry_4(
|
||||
Invocation.method(#editConfigServer, [config, type]),
|
||||
returnValue: _i8.Future<_i6.BaseConfig>.value(
|
||||
_FakeBaseConfig_4(
|
||||
this,
|
||||
Invocation.method(#addSlotEntry, [entry, routineId]),
|
||||
Invocation.method(#editConfigServer, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i6.SlotEntry>);
|
||||
as _i8.Future<_i6.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteSlotEntry, [id, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlotEntry(_i6.SlotEntry? entry, int? routineId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editSlotEntry, [entry, routineId]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
returnValue: _i15.dummyValue<String>(
|
||||
this,
|
||||
Invocation.method(#getConfigUrl, [type]),
|
||||
),
|
||||
)
|
||||
as String);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> editConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
_i8.Future<_i6.BaseConfig> addConfigServer(
|
||||
_i6.BaseConfig? config,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
Invocation.method(#addConfigServer, [config, type]),
|
||||
returnValue: _i8.Future<_i6.BaseConfig>.value(
|
||||
_FakeBaseConfig_4(
|
||||
this,
|
||||
Invocation.method(#editConfig, [config, type]),
|
||||
Invocation.method(#addConfigServer, [config, type]),
|
||||
),
|
||||
),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
as _i8.Future<_i6.BaseConfig>);
|
||||
|
||||
@override
|
||||
_i13.Future<_i7.BaseConfig> addConfig(
|
||||
_i7.BaseConfig? config,
|
||||
_i6.ConfigType? type,
|
||||
) =>
|
||||
_i8.Future<void> deleteConfigServer(int? id, _i5.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
returnValue: _i13.Future<_i7.BaseConfig>.value(
|
||||
_FakeBaseConfig_5(
|
||||
this,
|
||||
Invocation.method(#addConfig, [config, type]),
|
||||
),
|
||||
),
|
||||
Invocation.method(#deleteConfigServer, [id, type]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<_i7.BaseConfig>);
|
||||
as _i8.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteConfig(int? id, _i6.ConfigType? type) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#deleteConfig, [id, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> handleConfig(
|
||||
_i6.SlotEntry? entry,
|
||||
_i8.Future<void> handleConfigServer(
|
||||
_i5.SlotEntry? entry,
|
||||
num? value,
|
||||
_i6.ConfigType? type,
|
||||
_i5.ConfigType? type,
|
||||
) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#handleConfig, [entry, value, type]),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
Invocation.method(#handleConfigServer, [entry, value, type]),
|
||||
returnValue: _i8.Future<void>.value(),
|
||||
returnValueForMissingStub: _i8.Future<void>.value(),
|
||||
)
|
||||
as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
void addListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#addListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(#removeListener, [listener]),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() => super.noSuchMethod(
|
||||
Invocation.method(#dispose, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
|
||||
@override
|
||||
void notifyListeners() => super.noSuchMethod(
|
||||
Invocation.method(#notifyListeners, []),
|
||||
returnValueForMissingStub: null,
|
||||
);
|
||||
as _i8.Future<void>);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user