refactored data providers with centralized cache resolution, unified UI using custom dialogs and bottom sheets, and enhanced network error handling for Dio and TLS errors
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:marianum_mobile/api/api_error.dart';
|
||||
@@ -36,8 +37,9 @@ void main() {
|
||||
});
|
||||
|
||||
test('HandshakeException maps to a TLS-specific message', () {
|
||||
expect(errorToUserMessage(const HandshakeException('bad cert')),
|
||||
'Sichere Verbindung konnte nicht hergestellt werden.');
|
||||
final message = errorToUserMessage(const HandshakeException('bad cert'));
|
||||
expect(message, contains('sichere Verbindung'));
|
||||
expect(message, contains('Geräte-Uhrzeit'));
|
||||
});
|
||||
|
||||
test('FormatException maps to ParseException message', () {
|
||||
@@ -63,6 +65,34 @@ void main() {
|
||||
test('custom fallback overrides the default', () {
|
||||
expect(errorToUserMessage(null, fallback: 'meins'), 'meins');
|
||||
});
|
||||
|
||||
test('DioException connectionTimeout maps to timeout NetworkException', () {
|
||||
final ex = DioException(
|
||||
requestOptions: RequestOptions(path: '/x'),
|
||||
type: DioExceptionType.connectionTimeout,
|
||||
);
|
||||
expect(errorToUserMessage(ex), NetworkException.timeout().userMessage);
|
||||
});
|
||||
|
||||
test('DioException connectionError maps to NetworkException', () {
|
||||
final ex = DioException(
|
||||
requestOptions: RequestOptions(path: '/x'),
|
||||
type: DioExceptionType.connectionError,
|
||||
);
|
||||
expect(errorToUserMessage(ex), const NetworkException().userMessage);
|
||||
});
|
||||
|
||||
test('DioException badResponse maps to a server status message', () {
|
||||
final ex = DioException(
|
||||
requestOptions: RequestOptions(path: '/x'),
|
||||
type: DioExceptionType.badResponse,
|
||||
response: Response(
|
||||
requestOptions: RequestOptions(path: '/x'),
|
||||
statusCode: 503,
|
||||
),
|
||||
);
|
||||
expect(errorToUserMessage(ex), contains('503'));
|
||||
});
|
||||
});
|
||||
|
||||
group('errorToTechnicalDetails', () {
|
||||
|
||||
Reference in New Issue
Block a user