-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
82 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,6 @@ import 'package:sentry/src/sentry_envelope_header.dart'; | |
import 'package:sentry/src/sentry_envelope_item_header.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
import 'package:sentry_flutter/src/replay/replay_config.dart'; | ||
import 'package:sentry_flutter/src/web/script_loader/sentry_script_loader.dart'; | ||
import 'package:sentry_flutter/src/web/sentry_js_binding.dart'; | ||
import 'package:sentry_flutter/src/web/sentry_js_bundle.dart'; | ||
import 'package:sentry_flutter/src/web/sentry_web.dart'; | ||
|
||
import '../mocks.dart'; | ||
|
@@ -27,81 +24,83 @@ void main() { | |
options = defaultTestOptions(); | ||
}); | ||
|
||
group('with real binding', () { | ||
late SentryWeb sut; | ||
late SentryJsBinding binding; | ||
|
||
setUp(() async { | ||
final loader = SentryScriptLoader(options: options); | ||
await loader.loadWebSdk(debugScripts); | ||
binding = createJsBinding(); | ||
sut = SentryWeb(binding, options); | ||
}); | ||
|
||
tearDown(() async { | ||
await sut.close(); | ||
}); | ||
|
||
test('init: options mapped to JS SDK', () async { | ||
const expectedDsn = 'https://[email protected]/1234567'; | ||
const expectedRelease = 'my-random-release'; | ||
const expectedSampleRate = 0.2; | ||
const expectedEnv = 'my-random-env'; | ||
const expectedDist = '999'; | ||
const expectedAttachStacktrace = false; | ||
const expectedMaxBreadcrumbs = 1000; | ||
const expectedDebug = true; | ||
|
||
options.dsn = expectedDsn; | ||
options.release = expectedRelease; | ||
options.sampleRate = expectedSampleRate; | ||
options.environment = expectedEnv; | ||
options.dist = expectedDist; | ||
options.attachStacktrace = expectedAttachStacktrace; | ||
options.maxBreadcrumbs = expectedMaxBreadcrumbs; | ||
options.debug = expectedDebug; | ||
|
||
// quick check that Sentry is not initialized first | ||
expect(() => binding.getJsOptions()['dsn'], throwsA(anything)); | ||
|
||
await sut.init(hub); | ||
|
||
final jsOptions = binding.getJsOptions(); | ||
expect(jsOptions['dsn'], expectedDsn); | ||
expect(jsOptions['release'], expectedRelease); | ||
expect(jsOptions['sampleRate'], expectedSampleRate); | ||
expect(jsOptions['environment'], expectedEnv); | ||
expect(jsOptions['dist'], expectedDist); | ||
expect(jsOptions['attachStacktrace'], expectedAttachStacktrace); | ||
expect(jsOptions['maxBreadcrumbs'], expectedMaxBreadcrumbs); | ||
expect(jsOptions['debug'], expectedDebug); | ||
expect(jsOptions['defaultIntegrations'].length, 2); | ||
expect(jsOptions['defaultIntegrations'][0].toString(), | ||
contains('name: GlobalHandlers')); | ||
expect(jsOptions['defaultIntegrations'][1].toString(), | ||
contains('name: Dedupe')); | ||
}); | ||
|
||
test('options getter returns the original options', () { | ||
expect(sut.options, same(options)); | ||
}); | ||
|
||
test('native features are not supported', () { | ||
expect(sut.supportsLoadContexts, isFalse); | ||
expect(sut.supportsReplay, isFalse); | ||
}); | ||
|
||
test('capturing envelope is supported', () { | ||
expect(sut.supportsCaptureEnvelope, isTrue); | ||
}); | ||
|
||
test('can send envelope without throwing', () async { | ||
await sut.init(hub); | ||
|
||
await sut.captureStructuredEnvelope(SentryEnvelope.fromEvent( | ||
SentryEvent(), SdkVersion(name: 'test', version: '0'))); | ||
}); | ||
}); | ||
// TODO: re-enable in V9 | ||
// group('with real binding', () { | ||
// late SentryWeb sut; | ||
// late SentryJsBinding binding; | ||
// | ||
// setUp(() async { | ||
// final loader = SentryScriptLoader(options: options); | ||
// await loader.loadWebSdk(debugScripts); | ||
// binding = createJsBinding(); | ||
// sut = SentryWeb(binding, options); | ||
// }); | ||
// | ||
// tearDown(() async { | ||
// await sut.close(); | ||
// }); | ||
// | ||
// test('init: options mapped to JS SDK', () async { | ||
// const expectedDsn = 'https://[email protected]/1234567'; | ||
// const expectedRelease = 'my-random-release'; | ||
// const expectedSampleRate = 0.2; | ||
// const expectedEnv = 'my-random-env'; | ||
// const expectedDist = '999'; | ||
// const expectedAttachStacktrace = false; | ||
// const expectedMaxBreadcrumbs = 1000; | ||
// const expectedDebug = true; | ||
// | ||
// options.dsn = expectedDsn; | ||
// options.release = expectedRelease; | ||
// options.sampleRate = expectedSampleRate; | ||
// options.environment = expectedEnv; | ||
// options.dist = expectedDist; | ||
// options.attachStacktrace = expectedAttachStacktrace; | ||
// options.maxBreadcrumbs = expectedMaxBreadcrumbs; | ||
// options.debug = expectedDebug; | ||
// | ||
// // quick check that Sentry is not initialized first | ||
// expect(() => binding.getJsOptions()['dsn'], throwsA(anything)); | ||
// | ||
// await sut.init(hub); | ||
// | ||
// final jsOptions = binding.getJsOptions(); | ||
// | ||
// expect(jsOptions['dsn'], expectedDsn); | ||
// expect(jsOptions['release'], expectedRelease); | ||
// expect(jsOptions['sampleRate'], expectedSampleRate); | ||
// expect(jsOptions['environment'], expectedEnv); | ||
// expect(jsOptions['dist'], expectedDist); | ||
// expect(jsOptions['attachStacktrace'], expectedAttachStacktrace); | ||
// expect(jsOptions['maxBreadcrumbs'], expectedMaxBreadcrumbs); | ||
// expect(jsOptions['debug'], expectedDebug); | ||
// expect(jsOptions['defaultIntegrations'].length, 2); | ||
// expect(jsOptions['defaultIntegrations'][0].toString(), | ||
// contains('name: GlobalHandlers')); | ||
// expect(jsOptions['defaultIntegrations'][1].toString(), | ||
// contains('name: Dedupe')); | ||
// }); | ||
// | ||
// test('options getter returns the original options', () { | ||
// expect(sut.options, same(options)); | ||
// }); | ||
// | ||
// test('native features are not supported', () { | ||
// expect(sut.supportsLoadContexts, isFalse); | ||
// expect(sut.supportsReplay, isFalse); | ||
// }); | ||
// | ||
// test('capturing envelope is supported', () { | ||
// expect(sut.supportsCaptureEnvelope, isTrue); | ||
// }); | ||
// | ||
// test('can send envelope without throwing', () async { | ||
// await sut.init(hub); | ||
// | ||
// await sut.captureStructuredEnvelope(SentryEnvelope.fromEvent( | ||
// SentryEvent(), SdkVersion(name: 'test', version: '0'))); | ||
// }); | ||
// }); | ||
|
||
group('with mock binding', () { | ||
late MockSentryJsBinding mockBinding; | ||
|