From 7e8478cc7dca5df42bd9c9761f3090a1e7bd122e Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 6 Mar 2024 13:30:42 +0100 Subject: [PATCH] fix test --- .../src/navigation/sentry_navigator_observer.dart | 1 - flutter/test/sentry_navigator_observer_test.dart | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/flutter/lib/src/navigation/sentry_navigator_observer.dart b/flutter/lib/src/navigation/sentry_navigator_observer.dart index f71f8def9f..a9b91f0ce1 100644 --- a/flutter/lib/src/navigation/sentry_navigator_observer.dart +++ b/flutter/lib/src/navigation/sentry_navigator_observer.dart @@ -277,7 +277,6 @@ class SentryNavigatorObserver extends RouteObserver> { Future _startTimeToDisplayTracking(Route? route) async { _completedDisplayTracking = Completer(); String? routeName = _currentRouteName; - if (routeName == null) return; DateTime startTimestamp = _hub.options.clock(); diff --git a/flutter/test/sentry_navigator_observer_test.dart b/flutter/test/sentry_navigator_observer_test.dart index 2e54fed326..5a7528d904 100644 --- a/flutter/test/sentry_navigator_observer_test.dart +++ b/flutter/test/sentry_navigator_observer_test.dart @@ -5,6 +5,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; +import 'package:sentry_flutter/src/integrations/integrations.dart'; import 'package:sentry_flutter/src/native/sentry_native.dart'; import 'package:sentry/src/sentry_tracer.dart'; import 'package:sentry_flutter/src/navigation/time_to_display_tracker.dart'; @@ -383,8 +384,15 @@ void main() { verify(span.setData('route_settings_arguments', arguments)); }); - test('flutter root name is replaced', () { + test('flutter root name is replaced', () async { final rootRoute = route(RouteSettings(name: '/')); + NativeAppStartIntegration.setAppStartInfo( + AppStartInfo( + AppStartType.cold, + start: DateTime.now().add(const Duration(seconds: 1)), + end: DateTime.now().add(const Duration(seconds: 2)), + ), + ); final hub = _MockHub(); final span = getMockSentryTracer(name: '/'); @@ -401,6 +409,8 @@ void main() { sut.didPush(rootRoute, null); + await Future.delayed(const Duration(milliseconds: 100)); + final context = verify(hub.startTransactionWithContext( captureAny, waitForChildren: true,