@@ -16,7 +16,10 @@ import im.vector.app.features.analytics.plan.MobileScreen
16
16
import im.vector.app.features.analytics.plan.PollEnd
17
17
import im.vector.app.features.analytics.plan.SuperProperties
18
18
import im.vector.app.features.analytics.plan.UserProperties
19
+ import io.element.android.libraries.sessionstorage.api.SessionStore
19
20
import io.element.android.libraries.sessionstorage.api.observer.SessionObserver
21
+ import io.element.android.libraries.sessionstorage.test.InMemorySessionStore
22
+ import io.element.android.libraries.sessionstorage.test.aSessionData
20
23
import io.element.android.libraries.sessionstorage.test.observer.NoOpSessionObserver
21
24
import io.element.android.services.analytics.impl.store.AnalyticsStore
22
25
import io.element.android.services.analytics.impl.store.FakeAnalyticsStore
@@ -167,7 +170,7 @@ class DefaultAnalyticsServiceTest {
167
170
}
168
171
169
172
@Test
170
- fun `when a session is deleted, the store is reset` () = runTest {
173
+ fun `when the last session is deleted, the store is reset` () = runTest {
171
174
val resetLambda = lambdaRecorder<Unit > { }
172
175
val store = FakeAnalyticsStore (
173
176
resetLambda = resetLambda,
@@ -180,6 +183,23 @@ class DefaultAnalyticsServiceTest {
180
183
resetLambda.assertions().isCalledOnce()
181
184
}
182
185
186
+ @Test
187
+ fun `when a session is deleted, the store is not reset` () = runTest {
188
+ val resetLambda = lambdaRecorder<Unit > { }
189
+ val store = FakeAnalyticsStore (
190
+ resetLambda = resetLambda,
191
+ )
192
+ val sut = createDefaultAnalyticsService(
193
+ coroutineScope = backgroundScope,
194
+ analyticsStore = store,
195
+ sessionStore = InMemorySessionStore (
196
+ initialList = listOf (aSessionData()),
197
+ )
198
+ )
199
+ sut.onSessionDeleted(" userId" )
200
+ resetLambda.assertions().isNeverCalled()
201
+ }
202
+
183
203
@Test
184
204
fun `when reset is invoked, the user consent is reset` () = runTest {
185
205
val store = FakeAnalyticsStore (
@@ -272,11 +292,13 @@ class DefaultAnalyticsServiceTest {
272
292
),
273
293
analyticsStore : AnalyticsStore = FakeAnalyticsStore (),
274
294
sessionObserver : SessionObserver = NoOpSessionObserver (),
295
+ sessionStore : SessionStore = InMemorySessionStore (),
275
296
) = DefaultAnalyticsService (
276
297
analyticsProviders = analyticsProviders,
277
298
analyticsStore = analyticsStore,
278
299
coroutineScope = coroutineScope,
279
300
sessionObserver = sessionObserver,
301
+ sessionStore = sessionStore,
280
302
).also {
281
303
// Wait for the service to be ready
282
304
delay(1 )
0 commit comments