Display used and reserved limits capacity

This commit is contained in:
Stephan D committed 2026-09-12 10:05:20 +02:00
1 parent ec43d34b4b
commit 2e81c43091
14 files changed
+287 -5

No files matched your search

+86
View File
@@ -0,0 +1,86 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:provider/provider.dart';
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
import 'package:sxchnge_theme/sxchnge_theme.dart';
import 'package:sxchnge_app/kyc/limits.dart';
import 'package:sxchnge_app/generated/i18n/app_localizations.dart';
class Service implements LimitsService {
Service(this.row);
final VisibleLimit row;
@override
Future<Limits> fetch() async =>
Limits(tier: AccountTier.basic, rows: [row], simulated: true);
}
void main() {
for (final locale in ['en', 'ru']) {
testWidgets(
'usage and authoritative available capacity fit narrow $locale layout',
(tester) async {
tester.view.physicalSize = const Size(320, 1800);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = 1.6;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
final provider = LimitsProvider(
Service(
const VisibleLimit(
period: LimitPeriod.day,
currency: 'EUR',
basicMinor: 10000,
verifiedMinor: 250000,
currentMinor: 10000,
remainingMinor: 5500,
usedMinor: 3000,
reservedMinor: 1000,
),
),
);
addTearDown(provider.dispose);
await provider.refresh();
await tester.pumpWidget(
ChangeNotifierProvider.value(
value: provider,
child: MaterialApp(
theme: SxchngeTheme.light(),
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: const Scaffold(
body: SingleChildScrollView(child: LimitsPanel()),
),
),
),
);
await tester.pumpAndSettle();
expect(
find.text(locale == 'en' ? 'Used' : 'Использовано'),
findsOneWidget,
);
expect(
find.text(locale == 'en' ? 'Reserved' : 'Зарезервировано'),
findsOneWidget,
);
expect(
tester
.widget<LinearProgressIndicator>(
find.byKey(const ValueKey('usage-day')),
)
.value,
0.4,
);
expect(find.textContaining('55'), findsOneWidget);
expect(tester.takeException(), null);
},
);
}
}