Skip to content

Commit

Permalink
Fix SentryUserInteractionWidget throwing when Sentry is not enabled (#…
Browse files Browse the repository at this point in the history
…1363)

Co-authored-by: Manoel Aranda Neto <marandaneto@gmail.com>
  • Loading branch information
kuhnroyal and marandaneto authored Mar 28, 2023
1 parent 8ced2dc commit 8e133ad
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Fix `SentryUserInteractionWidget` throwing when Sentry is not enabled ([#1363](https://github.com/getsentry/sentry-dart/pull/1363))

## 7.3.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ class SentryUserInteractionWidget extends StatefulWidget {

SentryFlutterOptions? get _options =>
// ignore: invalid_use_of_internal_member
_hub.options as SentryFlutterOptions?;
_hub.options is SentryFlutterOptions
// ignore: invalid_use_of_internal_member
? _hub.options as SentryFlutterOptions
: null;

@override
StatefulElement createElement() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@TestOn('vm')

// ignore_for_file: invalid_use_of_internal_member

import 'dart:async';
Expand All @@ -14,13 +13,26 @@ import '../mocks.dart';
import '../mocks.mocks.dart';

void main() {
group('$SentryUserInteractionWidget crumbs', () {
late Fixture fixture;
setUp(() async {
fixture = Fixture();
TestWidgetsFlutterBinding.ensureInitialized();
});
late Fixture fixture;
setUp(() async {
fixture = Fixture();
TestWidgetsFlutterBinding.ensureInitialized();
});

testWidgets(
'$SentryUserInteractionWidget does not throw cast exception when Sentry is disabled',
(tester) async {
await tester.runAsync(() async {
await tester.pumpWidget(
SentryUserInteractionWidget(
child: MaterialApp(),
),
);
});
},
);

group('$SentryUserInteractionWidget crumbs', () {
testWidgets('Add crumb for MaterialButton', (tester) async {
await tester.runAsync(() async {
final sut = fixture.getSut();
Expand Down

0 comments on commit 8e133ad

Please sign in to comment.