Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/screens/buy/buy_payment_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PortfolioChartCubit extends Cubit<PortfolioChartState> {
PortfolioChartCubit(this._prices)
: super(
const PortfolioChartState(
selectedPeriod: TimePeriod.threeMonths,
selectedPeriod: TimePeriod.all,
visibleSpots: [],
minX: 0,
maxX: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PriceChartCubit extends Cubit<PriceChartState> {
PriceChartCubit(this._prices)
: super(
const PriceChartState(
selectedPeriod: TimePeriod.threeMonths,
selectedPeriod: TimePeriod.all,
visibleSpots: [],
minX: 0,
maxX: 0,
Expand Down
Binary file modified test/goldens/screens/dashboard/goldens/macos/dashboard_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/screens/home/goldens/macos/home_page_loaded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions test/screens/buy/buy_payment_details_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
});
});
}
25 changes: 17 additions & 8 deletions test/screens/dashboard/portfolio_chart_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 []);
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
17 changes: 14 additions & 3 deletions test/screens/dashboard/price_chart_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
Loading