Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 104 additions & 86 deletions test/goldens/screens/home/home_golden_test.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 = <int>[
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 = <PricePoint>[
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 = <int>[
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 = <PricePoint>[
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 <TransactionDto>[]);
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 <TransactionDto>[]);
when(() => settingsBloc.state).thenReturn(const SettingsState());

return wrapForGolden(
MultiBlocProvider(
providers: [
BlocProvider<SettingsBloc>.value(value: settingsBloc),
BlocProvider<DashboardBloc>.value(value: dashboardBloc),
BlocProvider<BalanceCubit>.value(value: balanceCubit),
BlocProvider<PendingTransactionsCubit>.value(value: pendingTxCubit),
],
child: const DashboardView(),
),
);
},
return wrapForGolden(
MultiBlocProvider(
providers: [
BlocProvider<SettingsBloc>.value(value: settingsBloc),
BlocProvider<DashboardBloc>.value(value: dashboardBloc),
BlocProvider<BalanceCubit>.value(value: balanceCubit),
BlocProvider<PendingTransactionsCubit>.value(
value: pendingTxCubit,
),
],
child: const DashboardView(),
),
);
},
),
);
});
}
Loading