mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-29 01:18:35 +01:00
Remove validateLanguage, this wasn't used
This commit is contained in:
@@ -87,8 +87,4 @@ class AddExerciseNotifier extends _$AddExerciseNotifier {
|
||||
clear();
|
||||
return exerciseId;
|
||||
}
|
||||
|
||||
Future<bool> validateLanguage(String input, String languageCode) {
|
||||
return _repo.validateLanguage(input, languageCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ final class AddExerciseNotifierProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$addExerciseNotifierHash() => r'26f3eaffc36b6670d8e4069ef5813bfc71b9491e';
|
||||
String _$addExerciseNotifierHash() => r'0c9bebb400badb1bead88629e392037a1e06495d';
|
||||
|
||||
abstract class _$AddExerciseNotifier extends $Notifier<AddExerciseState> {
|
||||
AddExerciseState build();
|
||||
|
||||
@@ -34,7 +34,6 @@ final addExerciseRepositoryProvider = Provider<AddExerciseRepository>((ref) {
|
||||
class AddExerciseRepository {
|
||||
static const _exerciseSubmissionUrlPath = 'exercise-submission';
|
||||
static const _imagesUrlPath = 'exerciseimage';
|
||||
static const _checkLanguageUrlPath = 'check-language';
|
||||
|
||||
final _logger = Logger('AddExerciseRepository');
|
||||
final WgerBaseProvider _base;
|
||||
@@ -76,12 +75,4 @@ class AddExerciseRepository {
|
||||
throw Exception('Upload failed: ${streamedResponse.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> validateLanguage(String input, String languageCode) async {
|
||||
await _base.post({
|
||||
'input': input,
|
||||
'language_code': languageCode,
|
||||
}, _base.makeUrl(_checkLanguageUrlPath));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ final class GymLogNotifierProvider extends $NotifierProvider<GymLogNotifier, Log
|
||||
}
|
||||
}
|
||||
|
||||
String _$gymLogNotifierHash() => r'25aa3cab12922554aaae891192cb1fe354aae0fe';
|
||||
String _$gymLogNotifierHash() => r'5163fac0fee0c6f1210c52b1db02dc0a5b103daf';
|
||||
|
||||
abstract class _$GymLogNotifier extends $Notifier<Log?> {
|
||||
Log? build();
|
||||
|
||||
@@ -251,17 +251,4 @@ void main() {
|
||||
expect(captured.translations, hasLength(expected.translations.length));
|
||||
});
|
||||
});
|
||||
|
||||
group('validateLanguage', () {
|
||||
test('delegates to the repository with the same args', () async {
|
||||
when(mockRepo.validateLanguage(any, any)).thenAnswer((_) async => false);
|
||||
|
||||
final result = await container
|
||||
.read(addExerciseProvider.notifier)
|
||||
.validateLanguage('Bankdrücken', 'de');
|
||||
|
||||
expect(result, isFalse);
|
||||
verify(mockRepo.validateLanguage('Bankdrücken', 'de')).called(1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -57,12 +57,4 @@ class MockAddExerciseRepository extends _i1.Mock implements _i2.AddExerciseRepos
|
||||
returnValueForMissingStub: _i3.Future<void>.value(),
|
||||
)
|
||||
as _i3.Future<void>);
|
||||
|
||||
@override
|
||||
_i3.Future<bool> validateLanguage(String? input, String? languageCode) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#validateLanguage, [input, languageCode]),
|
||||
returnValue: _i3.Future<bool>.value(false),
|
||||
)
|
||||
as _i3.Future<bool>);
|
||||
}
|
||||
|
||||
@@ -57,39 +57,6 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('validateLanguage', () {
|
||||
test('POSTs {input, language_code} to the check-language endpoint', () async {
|
||||
final uri = Uri.https('localhost', 'api/v2/check-language/');
|
||||
when(mockBase.makeUrl('check-language')).thenReturn(uri);
|
||||
when(mockBase.post(any, uri)).thenAnswer((_) async => {});
|
||||
|
||||
await repo.validateLanguage('Bankdrücken', 'de');
|
||||
|
||||
verify(
|
||||
mockBase.post({'input': 'Bankdrücken', 'language_code': 'de'}, uri),
|
||||
).called(1);
|
||||
});
|
||||
|
||||
// KNOWN BUG (audit-memo): validateLanguage always returns false regardless
|
||||
// of the API response. The function discards the POST result. No widget
|
||||
// currently consumes the return value, so this hasn't surfaced as a UX
|
||||
// issue — but the contract is broken. This test pins the current behavior
|
||||
// so a fix is intentional, not accidental.
|
||||
test('always returns false (current buggy behavior)', () async {
|
||||
final uri = Uri.https('localhost', 'api/v2/check-language/');
|
||||
when(mockBase.makeUrl('check-language')).thenReturn(uri);
|
||||
|
||||
when(mockBase.post(any, uri)).thenAnswer((_) async => {'is_valid': true});
|
||||
expect(await repo.validateLanguage('hello', 'en'), isFalse);
|
||||
|
||||
when(mockBase.post(any, uri)).thenAnswer((_) async => {'is_valid': false});
|
||||
expect(await repo.validateLanguage('hello', 'en'), isFalse);
|
||||
|
||||
when(mockBase.post(any, uri)).thenAnswer((_) async => {});
|
||||
expect(await repo.validateLanguage('hello', 'en'), isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
// Note: uploadImage is not unit-tested here. It builds an http.MultipartRequest
|
||||
// and calls .send() directly without going through WgerBaseProvider, so a
|
||||
// proper test requires HTTP-level mocking (e.g. MockClient + dependency
|
||||
|
||||
@@ -57,12 +57,4 @@ class MockAddExerciseRepository extends _i1.Mock implements _i2.AddExerciseRepos
|
||||
returnValueForMissingStub: _i3.Future<void>.value(),
|
||||
)
|
||||
as _i3.Future<void>);
|
||||
|
||||
@override
|
||||
_i3.Future<bool> validateLanguage(String? input, String? languageCode) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#validateLanguage, [input, languageCode]),
|
||||
returnValue: _i3.Future<bool>.value(false),
|
||||
)
|
||||
as _i3.Future<bool>);
|
||||
}
|
||||
|
||||
@@ -69,14 +69,6 @@ class MockAddExerciseRepository extends _i1.Mock implements _i3.AddExerciseRepos
|
||||
returnValueForMissingStub: _i4.Future<void>.value(),
|
||||
)
|
||||
as _i4.Future<void>);
|
||||
|
||||
@override
|
||||
_i4.Future<bool> validateLanguage(String? input, String? languageCode) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#validateLanguage, [input, languageCode]),
|
||||
returnValue: _i4.Future<bool>.value(false),
|
||||
)
|
||||
as _i4.Future<bool>);
|
||||
}
|
||||
|
||||
/// A class which mocks [UserProfileRepository].
|
||||
|
||||
Reference in New Issue
Block a user