diff --git a/test/goldens/screens/home/home_golden_test.dart b/test/goldens/screens/home/home_golden_test.dart index aa7ae0c1..5febdba2 100644 --- a/test/goldens/screens/home/home_golden_test.dart +++ b/test/goldens/screens/home/home_golden_test.dart @@ -1,3 +1,5 @@ +import 'package:alchemist/alchemist.dart' + show AlchemistConfig, PlatformGoldensConfig; import 'package:bloc_test/bloc_test.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -51,96 +53,112 @@ void main() { // the DashboardView with the live price + chart, not the software-terms // intro of HomePage. We render DashboardView here to match the handbook // ground truth while keeping the gap's `home_page_loaded` filename. - goldenTest( - 'loaded state with price data', - fileName: 'home_page_loaded', - constraints: const BoxConstraints.tightFor(width: 390, height: 844), - builder: () { - final dashboardBloc = _MockDashboardBloc(); - final balanceCubit = _MockBalanceCubit(); - final pendingTxCubit = _MockPendingTransactionsCubit(); - final settingsBloc = MockSettingsBloc(); + // + // Scoped 0.5% diff threshold: the price chart's stroked path renders + // with sub-pixel anti-aliasing whose exact coverage values jitter + // across runs even on the locked dfx01 renderer (chart-line drift was + // regenerated twice within five days under bot commit 044852b and the + // d25c61d follow-up, both touching only the curve region). Other + // goldens have no such drift surface and remain at the 0.0 default. + AlchemistConfig.runWithConfig( + config: AlchemistConfig.current().merge( + const AlchemistConfig( + platformGoldensConfig: PlatformGoldensConfig(diffThreshold: 0.005), + ), + ), + run: () => goldenTest( + 'loaded state with price data', + fileName: 'home_page_loaded', + constraints: const BoxConstraints.tightFor(width: 390, height: 844), + builder: () { + final dashboardBloc = _MockDashboardBloc(); + final balanceCubit = _MockBalanceCubit(); + final pendingTxCubit = _MockPendingTransactionsCubit(); + final settingsBloc = MockSettingsBloc(); - // ~30 price points climbing from 1.10 to 1.43 with a small dip near - // the middle, then a brief sideways stretch — produces a recognizable - // upward chart curve matching the handbook visual. - final now = DateTime(2026, 5, 23); - final priceChartValues = [ - 110, - 112, - 114, - 113, - 115, - 117, - 119, - 118, - 120, - 122, - 121, - 119, - 117, - 115, - 113, - 116, - 120, - 124, - 128, - 131, - 134, - 136, - 138, - 139, - 140, - 141, - 142, - 143, - 143, - 143, - ]; - final priceChart = [ - for (var i = 0; i < priceChartValues.length; i++) - PricePoint( - asset: realUnitAsset, - price: BigInt.from(priceChartValues[i]), - time: now.subtract( - Duration(days: priceChartValues.length - 1 - i), + // ~30 price points climbing from 1.10 to 1.43 with a small dip near + // the middle, then a brief sideways stretch — produces a recognizable + // upward chart curve matching the handbook visual. + final now = DateTime(2026, 5, 23); + final priceChartValues = [ + 110, + 112, + 114, + 113, + 115, + 117, + 119, + 118, + 120, + 122, + 121, + 119, + 117, + 115, + 113, + 116, + 120, + 124, + 128, + 131, + 134, + 136, + 138, + 139, + 140, + 141, + 142, + 143, + 143, + 143, + ]; + final priceChart = [ + for (var i = 0; i < priceChartValues.length; i++) + PricePoint( + asset: realUnitAsset, + price: BigInt.from(priceChartValues[i]), + time: now.subtract( + Duration(days: priceChartValues.length - 1 - i), + ), ), - ), - ]; + ]; - when(() => dashboardBloc.state).thenReturn( - DashboardState( - price: BigInt.from(143), - priceChart: priceChart, - portfolioHistory: const [], - currency: Currency.chf, - ), - ); - when(() => balanceCubit.state).thenReturn( - Balance( - chainId: realUnitAsset.chainId, - contractAddress: realUnitAsset.address, - walletAddress: '0x0', - balance: BigInt.zero, - asset: realUnitAsset, - ), - ); - when(() => balanceCubit.asset).thenReturn(realUnitAsset); - when(() => pendingTxCubit.state).thenReturn(const []); - when(() => settingsBloc.state).thenReturn(const SettingsState()); + when(() => dashboardBloc.state).thenReturn( + DashboardState( + price: BigInt.from(143), + priceChart: priceChart, + portfolioHistory: const [], + currency: Currency.chf, + ), + ); + when(() => balanceCubit.state).thenReturn( + Balance( + chainId: realUnitAsset.chainId, + contractAddress: realUnitAsset.address, + walletAddress: '0x0', + balance: BigInt.zero, + asset: realUnitAsset, + ), + ); + when(() => balanceCubit.asset).thenReturn(realUnitAsset); + when(() => pendingTxCubit.state).thenReturn(const []); + when(() => settingsBloc.state).thenReturn(const SettingsState()); - return wrapForGolden( - MultiBlocProvider( - providers: [ - BlocProvider.value(value: settingsBloc), - BlocProvider.value(value: dashboardBloc), - BlocProvider.value(value: balanceCubit), - BlocProvider.value(value: pendingTxCubit), - ], - child: const DashboardView(), - ), - ); - }, + return wrapForGolden( + MultiBlocProvider( + providers: [ + BlocProvider.value(value: settingsBloc), + BlocProvider.value(value: dashboardBloc), + BlocProvider.value(value: balanceCubit), + BlocProvider.value( + value: pendingTxCubit, + ), + ], + child: const DashboardView(), + ), + ); + }, + ), ); }); }