From cd86b6ba4ec6c56571a96156f8eb46c76ac2c71b Mon Sep 17 00:00:00 2001 From: Marco Saia Date: Mon, 7 Oct 2024 14:41:02 +0200 Subject: [PATCH] Android: added unit tests for synthetics attributes --- .../datadog/reactnative/DdSdkImplementation.kt | 4 +--- .../kotlin/com/datadog/reactnative/DdSdkTest.kt | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt index 7220c6c76..8f5020080 100644 --- a/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +++ b/packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt @@ -164,9 +164,7 @@ class DdSdkImplementation( return } - val core = DatadogSDKWrapperStorage.getSdkCore() - val monitor = GlobalRumMonitor.get(core) - monitor._getInternal()?.setSyntheticsAttribute( + datadog.getRumMonitor()._getInternal()?.setSyntheticsAttribute( DdSdkSynthetics.testId, DdSdkSynthetics.resultId ) diff --git a/packages/core/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt b/packages/core/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt index 46bffe029..071b9ee7c 100644 --- a/packages/core/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +++ b/packages/core/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt @@ -2293,6 +2293,23 @@ internal class DdSdkTest { .hasFieldEqualTo("customEndpointUrl", customTraceEndpoint) } + @Test + fun `𝕄 initialize native SDK 𝕎 initialize() {synthethics attributes}`() { + // Given + fakeConfiguration = fakeConfiguration.copy(nativeCrashReportEnabled = false, site = null) + DdSdkSynthetics.testId = "unit-test-test-id" + DdSdkSynthetics.resultId = "unit-test-result-id" + + // When + testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise) + + // Then + verify(mockRumInternalProxy).setSyntheticsAttribute( + "unit-test-test-id", + "unit-test-result-id" + ) + } + @Test fun `𝕄 clear all data 𝕎 clearAllData()`() { // When