feat(app): refactoring of sentry using, feat(become_consultant): fixed possible infinite loading, feat(push_notifications): fixed push navigation from paid plan push

This commit is contained in:
misha
2026-04-07 10:05:11 +03:00
parent b6b13b1db5
commit aac085def4
133 changed files with 2344 additions and 2456 deletions

View File

@@ -24,74 +24,54 @@ void main() {
test('getProductByBarcode - возвращает успешный результат (200)', () async {
const barcode = '1234567890123';
final productData = {'GTIN': barcode, 'Описание (ru)': 'Test Product'};
final response = Response(
final response = Response<Map<String, dynamic>>(
data: productData,
statusCode: 200,
requestOptions: RequestOptions(path: '/api/gsone/barcode/$barcode'),
);
when(mockDio.get('/api/gsone/barcode/$barcode')).thenAnswer((_) async => response);
when(mockDio.get<Map<String, dynamic>>(any, options: anyNamed('options'))).thenAnswer((_) async => response);
final result = await repository.getProductByBarcode(barcode);
expect(result.type, BarcodeResultType.success);
expect(result.product, isNotNull);
expect(result.product!.description, 'Test Product');
verify(mockDio.get('/api/gsone/barcode/$barcode')).called(1);
verify(mockDio.get<Map<String, dynamic>>(any, options: anyNamed('options'))).called(1);
});
test('getProductByBarcode - возвращает статус обработки (202)', () async {
const barcode = '1234567890123';
final taskData = {'task_id': 'task-123', 'status': 'processing'};
final response = Response(
final response = Response<Map<String, dynamic>>(
data: taskData,
statusCode: 202,
requestOptions: RequestOptions(path: '/api/gsone/barcode/$barcode'),
);
when(mockDio.get('/api/gsone/barcode/$barcode')).thenAnswer((_) async => response);
when(mockDio.get<Map<String, dynamic>>(any, options: anyNamed('options'))).thenAnswer((_) async => response);
final result = await repository.getProductByBarcode(barcode);
expect(result.type, BarcodeResultType.processing);
expect(result.taskId, equals('task-123'));
verify(mockDio.get('/api/gsone/barcode/$barcode')).called(1);
verify(mockDio.get<Map<String, dynamic>>(any, options: anyNamed('options'))).called(1);
});
test('getProductByBarcode - обрабатывает DioException с 202 статусом', () async {
test('getProductByBarcode - пробрасывает DioException при нестандартном ответе', () async {
const barcode = '1234567890123';
final taskData = {'task_id': 'task-456', 'status': 'processing'};
final dioException = DioException(
final response = Response<Map<String, dynamic>>(
data: {'error': 'Not found'},
statusCode: 404,
requestOptions: RequestOptions(path: '/api/gsone/barcode/$barcode'),
response: Response(
data: taskData,
statusCode: 202,
requestOptions: RequestOptions(path: '/api/gsone/barcode/$barcode'),
),
);
when(mockDio.get('/api/gsone/barcode/$barcode')).thenThrow(dioException);
when(mockDio.get<Map<String, dynamic>>(any, options: anyNamed('options'))).thenAnswer((_) async => response);
final result = await repository.getProductByBarcode(barcode);
expect(result.type, BarcodeResultType.processing);
expect(result.taskId, equals('task-456'));
});
test('getProductByBarcode - пробрасывает исключение при другой ошибке', () async {
const barcode = '1234567890123';
final dioException = DioException(
requestOptions: RequestOptions(path: '/api/gsone/barcode/$barcode'),
response: Response(
data: {'error': 'Not found'},
statusCode: 404,
requestOptions: RequestOptions(path: '/api/gsone/barcode/$barcode'),
),
await expectLater(
repository.getProductByBarcode(barcode),
throwsA(isA<DioException>()),
);
when(mockDio.get('/api/gsone/barcode/$barcode')).thenThrow(dioException);
expect(() => repository.getProductByBarcode(barcode), throwsException);
});
test('getTaskStatus - возвращает completed статус', () async {