diff --git a/lib/screens/buy/buy_payment_details_page.dart b/lib/screens/buy/buy_payment_details_page.dart index e0cd00b8..89cda363 100644 --- a/lib/screens/buy/buy_payment_details_page.dart +++ b/lib/screens/buy/buy_payment_details_page.dart @@ -79,7 +79,7 @@ class BuyPaymentDetailsPage extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(vertical: 20.0), child: AppFilledButton( - onPressed: () => context.goNamed(AppRoutes.home), + onPressed: () => context.goNamed(AppRoutes.dashboard), label: S.of(context).buyBackToMain, ), ), diff --git a/lib/screens/dashboard/bloc/portfolio_chart/portfolio_chart_cubit.dart b/lib/screens/dashboard/bloc/portfolio_chart/portfolio_chart_cubit.dart index 3442a533..d64600b1 100644 --- a/lib/screens/dashboard/bloc/portfolio_chart/portfolio_chart_cubit.dart +++ b/lib/screens/dashboard/bloc/portfolio_chart/portfolio_chart_cubit.dart @@ -13,7 +13,7 @@ class PortfolioChartCubit extends Cubit { PortfolioChartCubit(this._prices) : super( const PortfolioChartState( - selectedPeriod: TimePeriod.threeMonths, + selectedPeriod: TimePeriod.all, visibleSpots: [], minX: 0, maxX: 0, diff --git a/lib/screens/dashboard/bloc/price_chart/price_chart_cubit.dart b/lib/screens/dashboard/bloc/price_chart/price_chart_cubit.dart index bcdd30fd..e305e30a 100644 --- a/lib/screens/dashboard/bloc/price_chart/price_chart_cubit.dart +++ b/lib/screens/dashboard/bloc/price_chart/price_chart_cubit.dart @@ -9,7 +9,7 @@ class PriceChartCubit extends Cubit { PriceChartCubit(this._prices) : super( const PriceChartState( - selectedPeriod: TimePeriod.threeMonths, + selectedPeriod: TimePeriod.all, visibleSpots: [], minX: 0, maxX: 0, diff --git a/test/goldens/screens/dashboard/goldens/macos/dashboard_empty.png b/test/goldens/screens/dashboard/goldens/macos/dashboard_empty.png index 03f14920..abdfa0f8 100644 Binary files a/test/goldens/screens/dashboard/goldens/macos/dashboard_empty.png and b/test/goldens/screens/dashboard/goldens/macos/dashboard_empty.png differ diff --git a/test/goldens/screens/dashboard/goldens/macos/dashboard_with_balance.png b/test/goldens/screens/dashboard/goldens/macos/dashboard_with_balance.png index 02631d18..4aed8b45 100644 Binary files a/test/goldens/screens/dashboard/goldens/macos/dashboard_with_balance.png and b/test/goldens/screens/dashboard/goldens/macos/dashboard_with_balance.png differ diff --git a/test/goldens/screens/home/goldens/macos/home_page_loaded.png b/test/goldens/screens/home/goldens/macos/home_page_loaded.png index 3cd3250c..10a1f428 100644 Binary files a/test/goldens/screens/home/goldens/macos/home_page_loaded.png and b/test/goldens/screens/home/goldens/macos/home_page_loaded.png differ diff --git a/test/screens/buy/buy_payment_details_page_test.dart b/test/screens/buy/buy_payment_details_page_test.dart index 34e8fa75..c219fded 100644 --- a/test/screens/buy/buy_payment_details_page_test.dart +++ b/test/screens/buy/buy_payment_details_page_test.dart @@ -97,14 +97,14 @@ void main() { expect(find.text(S.current.buyBackToMain), findsOneWidget); }); - testWidgets('back-to-main button navigates to home', (tester) async { + testWidgets('back-to-main button navigates to dashboard', (tester) async { final router = GoRouter( initialLocation: '/buyPaymentDetails', routes: [ GoRoute( - name: AppRoutes.home, - path: '/home', - builder: (_, _) => const Scaffold(body: Text('HOME-AREA')), + name: AppRoutes.dashboard, + path: '/dashboard', + builder: (_, _) => const Scaffold(body: Text('DASHBOARD-AREA')), ), GoRoute( name: AppRoutes.buyPaymentDetails, @@ -132,7 +132,7 @@ void main() { await tester.tap(find.text(S.current.buyBackToMain)); await tester.pumpAndSettle(); - expect(find.text('HOME-AREA'), findsOneWidget); + expect(find.text('DASHBOARD-AREA'), findsOneWidget); }); }); } diff --git a/test/screens/dashboard/portfolio_chart_cubit_test.dart b/test/screens/dashboard/portfolio_chart_cubit_test.dart index bb5f36a8..0fd01d7c 100644 --- a/test/screens/dashboard/portfolio_chart_cubit_test.dart +++ b/test/screens/dashboard/portfolio_chart_cubit_test.dart @@ -22,6 +22,17 @@ void main() { expect(cubit.state.horizontalLineValues, isEmpty); }); + test('initial state defaults to TimePeriod.all', () { + // Regression guard for the dashboard default: a freshly constructed + // cubit must select the full range, not a clipped window. + final cubit = PortfolioChartCubit([ + _pt(DateTime.utc(2026, 1, 1), 1000), + _pt(DateTime.utc(2026, 2, 1), 2000), + ]); + + expect(cubit.state.selectedPeriod, TimePeriod.all); + }); + test('empty input keeps zero-window after selectPeriod to oneMonth', () async { // Guards the empty-input early-return branch when period changes. final cubit = PortfolioChartCubit(const []); @@ -66,11 +77,9 @@ void main() { // `average * 0.05` so the chart still has a visible Y-range instead of // collapsing to a single horizontal line. // - // Dates are anchored to `DateTime.now()` because the cubit's default - // period (`TimePeriod.threeMonths`) clips the visible window relative - // to `DateTime.now()`; hardcoded calendar dates would silently fall - // outside the window once the calendar moves on and the test would - // start asserting on an empty series. + // Dates are anchored to `DateTime.now()` so the series stays realistic + // and robust against any future period-clipping; this test exercises the + // default period (`TimePeriod.all`), which keeps the full series visible. final now = DateTime.now(); final points = [ _pt(now.subtract(const Duration(days: 60)), 10000), @@ -208,9 +217,9 @@ void main() { test('non-empty prices but all outside the selected window yield an empty visible chart', () { // Regression: PortfolioChartCubit used to crash with `Bad state: No - // element` when every price fell outside the selected window. With the - // default switched to threeMonths, that's a realistic state for any - // user whose only data points are older than 90 days. + // element` when every price fell outside the selected window. That is a + // realistic state whenever the user narrows to a short period (here + // oneWeek) while their only data points are older than the window. final points = [ _pt(DateTime.utc(2020, 1, 1), 5000), _pt(DateTime.utc(2020, 2, 1), 6000), diff --git a/test/screens/dashboard/price_chart_cubit_test.dart b/test/screens/dashboard/price_chart_cubit_test.dart index 45c144ee..3fac8e78 100644 --- a/test/screens/dashboard/price_chart_cubit_test.dart +++ b/test/screens/dashboard/price_chart_cubit_test.dart @@ -20,6 +20,17 @@ void main() { expect(cubit.state.maxY, 1); }); + test('initial state defaults to TimePeriod.all', () { + // Regression guard for the dashboard default: a freshly constructed + // cubit must select the full range, not a clipped window. + final cubit = PriceChartCubit([ + _pp(DateTime.utc(2026, 1, 1), 1000), + _pp(DateTime.utc(2026, 2, 1), 2000), + ]); + + expect(cubit.state.selectedPeriod, TimePeriod.all); + }); + test('empty price list keeps zero-window after selectPeriod to oneWeek', () async { // Guards the early-return branch in _calculateChartData: even when the // selected period changes, an empty input must keep visibleSpots empty @@ -155,9 +166,9 @@ void main() { test('non-empty prices but all outside the selected window yield an empty visible chart', () { // Regression: PriceChartCubit used to crash with `Bad state: No - // element` when every price fell outside the selected window. With the - // default switched to threeMonths, that's a realistic state for any - // user whose only data points are older than 90 days. + // element` when every price fell outside the selected window. That is a + // realistic state whenever the user narrows to a short period (here + // oneWeek) while their only data points are older than the window. final cubit = PriceChartCubit([ _pp(DateTime.utc(2020, 1, 1), 1000), _pp(DateTime.utc(2020, 2, 1), 2000),