Доходы, ребалансировка, налоги, импорт, цели, здоровье данных, правила, транзакции, категории, cashflow, pending: новые виджеты и токены темы, dart format. Тесты подстроены под новые модели.
92 lines
3.0 KiB
Dart
92 lines
3.0 KiB
Dart
import 'package:fintracker_api/fintracker_api.dart';
|
|
import 'package:fintracker_app/core/cache/cached.dart';
|
|
import 'package:fintracker_app/features/health/health_page.dart';
|
|
import 'package:fintracker_app/features/home/providers.dart'
|
|
show dataQualityProvider;
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
SourceStatus _source(String name) => SourceStatus(
|
|
source_: name,
|
|
lastRunStatus: RunStatus.ok,
|
|
lastRunAt: DateTime(2026, 9, 18, 10),
|
|
lastSuccessAt: DateTime(2026, 9, 18, 10),
|
|
cursor: null,
|
|
queued: false,
|
|
);
|
|
|
|
DataQualityRow _issue() => DataQualityRow(
|
|
id: 1,
|
|
ref: null,
|
|
severity: 'warn',
|
|
checkName: 'missing_fx',
|
|
count: 3,
|
|
detail: 'Курс не найден для 3 операций.',
|
|
computedAt: DateTime(2026, 9, 18, 10),
|
|
);
|
|
|
|
void main() {
|
|
testWidgets('shows sources on the first tab and findings on the second', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [
|
|
syncStatusProvider.overrideWith((ref) async => [_source('zenmoney')]),
|
|
syncRunsProvider.overrideWith((ref) async => const []),
|
|
dataQualityProvider.overrideWith((ref) => Cached([_issue()])),
|
|
],
|
|
child: const MaterialApp(home: HealthPage()),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
// Starts on «Источники»: the source card is visible, the findings text isn't.
|
|
expect(find.text('zenmoney'), findsOneWidget);
|
|
expect(find.textContaining('missing_fx'), findsNothing);
|
|
|
|
await tester.tap(find.text('Качество данных (1)'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.textContaining('missing_fx'), findsOneWidget);
|
|
expect(find.text('Курс не найден для 3 операций.'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('opens directly on the findings tab when initialTab is 1', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [
|
|
syncStatusProvider.overrideWith((ref) async => const []),
|
|
syncRunsProvider.overrideWith((ref) async => const []),
|
|
dataQualityProvider.overrideWith((ref) => Cached([_issue()])),
|
|
],
|
|
child: const MaterialApp(home: HealthPage(initialTab: 1)),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.textContaining('missing_fx'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('empty findings show the no-issues empty state', (tester) async {
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [
|
|
syncStatusProvider.overrideWith((ref) async => const []),
|
|
syncRunsProvider.overrideWith((ref) async => const []),
|
|
dataQualityProvider.overrideWith(
|
|
(ref) => const Cached(<DataQualityRow>[]),
|
|
),
|
|
],
|
|
child: const MaterialApp(home: HealthPage(initialTab: 1)),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Проблем не найдено.'), findsOneWidget);
|
|
});
|
|
}
|