Add tests

This commit is contained in:
Roland Geider
2025-12-18 11:13:02 +01:00
parent d187324a25
commit 40837ad1b3
5 changed files with 129 additions and 18 deletions

View File

@@ -1,13 +1,13 @@
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* wger Workout Manager is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
@@ -29,7 +29,7 @@ class RepetitionUnitInputWidget extends StatefulWidget {
late int? selectedRepetitionUnit;
final ValueChanged<int?> onChanged;
RepetitionUnitInputWidget(initialValue, {required this.onChanged}) {
RepetitionUnitInputWidget(int? initialValue, {super.key, required this.onChanged}) {
selectedRepetitionUnit = initialValue;
}
@@ -47,7 +47,7 @@ class _RepetitionUnitInputWidgetState extends State<RepetitionUnitInputWidget> {
: null;
return DropdownButtonFormField(
value: selectedWeightUnit,
initialValue: selectedWeightUnit,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).repetitionUnit,
),

View File

@@ -1,13 +1,13 @@
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* wger Workout Manager is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
@@ -30,7 +30,7 @@ class RiRInputWidget extends StatefulWidget {
static const SLIDER_START = -0.5;
RiRInputWidget(this._initialValue, {required this.onChanged}) {
RiRInputWidget(this._initialValue, {super.key, required this.onChanged}) {
_logger.finer('Initializing with initial value: $_initialValue');
}

View File

@@ -1,13 +1,13 @@
/*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* wger Workout Manager is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
@@ -29,7 +29,7 @@ class WeightUnitInputWidget extends StatefulWidget {
late int? selectedWeightUnit;
final ValueChanged<int?> onChanged;
WeightUnitInputWidget(int? initialValue, {required this.onChanged}) {
WeightUnitInputWidget(int? initialValue, {super.key, required this.onChanged}) {
selectedWeightUnit = initialValue;
}
@@ -47,7 +47,7 @@ class _WeightUnitInputWidgetState extends State<WeightUnitInputWidget> {
: null;
return DropdownButtonFormField(
value: selectedWeightUnit,
initialValue: selectedWeightUnit,
decoration: InputDecoration(labelText: AppLocalizations.of(context).weightUnit),
onChanged: (WeightUnit? newValue) {
setState(() {

View File

@@ -1,13 +1,13 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (C) 2020, 2025 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* wger Workout Manager is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
@@ -661,6 +661,7 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
children: [
Flexible(
child: LogsRepsWidget(
key: const ValueKey('logs-reps-widget'),
controller: _repetitionsController,
configData: widget.configData,
focusNode: widget.focusNode,
@@ -673,6 +674,7 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
const SizedBox(width: 8),
Flexible(
child: LogsWeightWidget(
key: const ValueKey('logs-weight-widget'),
controller: _weightController,
configData: widget.configData,
focusNode: widget.focusNode,
@@ -690,6 +692,7 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
children: [
Flexible(
child: LogsRepsWidget(
key: const ValueKey('logs-reps-widget'),
controller: _repetitionsController,
configData: widget.configData,
focusNode: widget.focusNode,
@@ -702,6 +705,7 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
const SizedBox(width: 8),
Flexible(
child: RepetitionUnitInputWidget(
key: const ValueKey('repetition-unit-input-widget'),
_log.repetitionsUnitId,
onChanged: (v) => {},
),
@@ -715,6 +719,7 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
children: [
Flexible(
child: LogsWeightWidget(
key: const ValueKey('logs-weight-widget'),
controller: _weightController,
configData: widget.configData,
focusNode: widget.focusNode,
@@ -726,13 +731,18 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
),
const SizedBox(width: 8),
Flexible(
child: WeightUnitInputWidget(_log.weightUnitId, onChanged: (v) => {}),
child: WeightUnitInputWidget(
_log.weightUnitId,
onChanged: (v) => {},
key: const ValueKey('weight-unit-input-widget'),
),
),
const SizedBox(width: 8),
],
),
if (_detailed)
RiRInputWidget(
key: const ValueKey('rir-input-widget'),
_log.rir,
onChanged: (value) {
if (value == '') {
@@ -743,6 +753,7 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
},
),
SwitchListTile(
key: const ValueKey('units-switch'),
dense: true,
title: Text(i18n.setUnitsAndRir),
value: _detailed,
@@ -753,6 +764,7 @@ class _LogFormWidgetState extends ConsumerState<LogFormWidget> {
},
),
FilledButton(
key: const ValueKey('save-log-button'),
onPressed: _isSaving
? null
: () async {