Skip to content

Commit b53b766

Browse files
committed
mark ut amplitude offline
1 parent f487aa9 commit b53b766

5 files changed

Lines changed: 33 additions & 29 deletions

File tree

Tests/AmplitudeTests/AmplitudeSessionTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class AmplitudeSessionTests: XCTestCase {
1919
storageProvider: storageMem,
2020
identifyStorageProvider: interceptStorageMem,
2121
minTimeBetweenSessionsMillis: 100,
22+
offline: NetworkConnectivityCheckerPlugin.Disabled,
2223
enableAutoCaptureRemoteConfig: false
2324
)
2425
}
@@ -133,6 +134,7 @@ final class AmplitudeSessionTests: XCTestCase {
133134
identifyStorageProvider: interceptStorageMem,
134135
minTimeBetweenSessionsMillis: 100,
135136
autocapture: [],
137+
offline: NetworkConnectivityCheckerPlugin.Disabled,
136138
enableAutoCaptureRemoteConfig: false
137139
)
138140
let amplitude = Amplitude(configuration: customCongiguration)

Tests/AmplitudeTests/AmplitudeTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ final class AmplitudeTests: XCTestCase {
4141
storageProvider: storageMem,
4242
identifyStorageProvider: interceptStorageMem,
4343
autocapture: [],
44+
offline: NetworkConnectivityCheckerPlugin.Disabled,
4445
enableAutoCaptureRemoteConfig: false
4546
)
4647
}

Tests/AmplitudeTests/AutocaptureRemoteConfigTests.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
6969
let sessions = amplitude.sessions
7070
XCTAssertFalse(sessions.trackSessionEvents, "Sessions should be off by default")
7171

72-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
72+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
7373

7474
XCTAssertTrue(sessions.trackSessionEvents, "Sessions should be on from remote config")
7575
}
@@ -91,7 +91,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
9191
let sessions = amplitude.sessions
9292
XCTAssertTrue(sessions.trackSessionEvents, "Sessions should be on by default")
9393

94-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
94+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
9595

9696
XCTAssertFalse(sessions.trackSessionEvents, "Sessions should be off from remote config")
9797
}
@@ -126,7 +126,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
126126

127127
XCTAssertFalse(iosLifecycleMonitor.trackingState.screenViews, "Screen views should be off by default")
128128

129-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
129+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
130130

131131
XCTAssertTrue(iosLifecycleMonitor.trackingState.screenViews, "Screen views should be on from remote config")
132132
}
@@ -159,7 +159,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
159159

160160
XCTAssertTrue(iosLifecycleMonitor.trackingState.screenViews, "Screen views should be on by default")
161161

162-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
162+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
163163

164164
XCTAssertFalse(iosLifecycleMonitor.trackingState.screenViews, "Screen views should be off from remote config")
165165
}
@@ -192,7 +192,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
192192

193193
XCTAssertFalse(iosLifecycleMonitor.trackingState.elementInteractions, "Element interactions should be off by default")
194194

195-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
195+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
196196

197197
XCTAssertTrue(iosLifecycleMonitor.trackingState.elementInteractions, "Element interactions should be on from remote config")
198198
}
@@ -225,7 +225,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
225225

226226
XCTAssertTrue(iosLifecycleMonitor.trackingState.elementInteractions, "Element interactions should be on by default")
227227

228-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
228+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
229229

230230
XCTAssertFalse(iosLifecycleMonitor.trackingState.elementInteractions, "Element interactions should be off from remote config")
231231
}
@@ -276,7 +276,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
276276
XCTAssertFalse(iosLifecycleMonitor.trackingState.rageClick, "Rage click should be off by default")
277277
XCTAssertFalse(iosLifecycleMonitor.trackingState.deadClick, "Dead click should be off by default")
278278

279-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
279+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
280280

281281
XCTAssertTrue(iosLifecycleMonitor.trackingState.frustrationInteractions, "Frustration interactions should be on from remote config")
282282
XCTAssertTrue(iosLifecycleMonitor.trackingState.rageClick, "Rage click should be on from remote config")
@@ -323,7 +323,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
323323
XCTAssertTrue(iosLifecycleMonitor.trackingState.rageClick, "Rage click should be on by default")
324324
XCTAssertTrue(iosLifecycleMonitor.trackingState.deadClick, "Dead click should be on by default")
325325

326-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
326+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
327327

328328
XCTAssertFalse(iosLifecycleMonitor.trackingState.frustrationInteractions, "Frustration interactions should be off from remote config")
329329
XCTAssertTrue(iosLifecycleMonitor.trackingState.rageClick, "Rage click should still be on from local config")
@@ -375,7 +375,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
375375
XCTAssertTrue(iosLifecycleMonitor.trackingState.rageClick, "Rage click should be on by default")
376376
XCTAssertTrue(iosLifecycleMonitor.trackingState.deadClick, "Dead click should be on by default")
377377

378-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
378+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
379379

380380
XCTAssertTrue(iosLifecycleMonitor.trackingState.frustrationInteractions, "Frustration interactions should be on by default")
381381
XCTAssertFalse(iosLifecycleMonitor.trackingState.rageClick, "Rage click should be off from remote config")
@@ -413,7 +413,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
413413

414414
XCTAssertTrue(networkTrackingPlugin.optOut, "Network tracking should be off by default")
415415

416-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
416+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
417417

418418
XCTAssertFalse(networkTrackingPlugin.optOut, "Network tracking should be on from remote config")
419419
}
@@ -448,7 +448,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
448448

449449
XCTAssertFalse(networkTrackingPlugin.optOut, "Network tracking should be off by default")
450450

451-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
451+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
452452

453453
XCTAssertTrue(networkTrackingPlugin.optOut, "Network tracking should be on from remote config")
454454
}
@@ -508,7 +508,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
508508
return
509509
}
510510

511-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 1)
511+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
512512

513513
// Verify the plugin is enabled
514514
XCTAssertFalse(networkTrackingPlugin.optOut)
@@ -592,7 +592,7 @@ class AutocaptureRemoteConfigTests: XCTestCase {
592592
return
593593
}
594594

595-
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 2)
595+
wait(for: [amplitude.amplitudeContext.remoteConfigClient.didFetchRemoteExpectation], timeout: 15)
596596

597597
// Verify the plugin is enabled from remote config
598598
XCTAssertFalse(networkTrackingPlugin.optOut)

Tests/AmplitudeTests/IdentityTests.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class IdentityTests: XCTestCase {
2424

2525
func testUpdateWithSameValues() throws {
2626
let storage = try makeStorage()
27-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
27+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
2828
let sendExpectation = XCTestExpectation(description: "It should not send identify")
2929
sendExpectation.isInverted = true
3030
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in
@@ -53,7 +53,7 @@ class IdentityTests: XCTestCase {
5353

5454
func testUpdateWithIdentity() throws {
5555
let storage = try makeStorage()
56-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
56+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
5757
let sendExpectation = XCTestExpectation(description: "It should send identify")
5858
sendExpectation.assertForOverFulfill = true
5959
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in
@@ -74,7 +74,7 @@ class IdentityTests: XCTestCase {
7474

7575
func testUpdateWithUserId() throws {
7676
let storage = try makeStorage()
77-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
77+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
7878
let sendExpectation = XCTestExpectation(description: "It should not send identify")
7979
sendExpectation.isInverted = true
8080
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in
@@ -93,7 +93,7 @@ class IdentityTests: XCTestCase {
9393

9494
func testUpdateWithDeviceId() throws {
9595
let storage = try makeStorage()
96-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
96+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
9797
let sendExpectation = XCTestExpectation(description: "It should not send identify")
9898
sendExpectation.isInverted = true
9999
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in
@@ -112,7 +112,7 @@ class IdentityTests: XCTestCase {
112112

113113
func testUpdateWithUserProperties() throws {
114114
let storage = try makeStorage()
115-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
115+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
116116
let sendExpectation = XCTestExpectation(description: "It should send identify")
117117
sendExpectation.assertForOverFulfill = true
118118
amplitude.add(plugin: IdentifyInterceptPlugin(block: { event in
@@ -134,7 +134,7 @@ class IdentityTests: XCTestCase {
134134

135135
func testSetUserId() throws {
136136
let storage = try makeStorage()
137-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
137+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
138138
let sendExpectation = XCTestExpectation(description: "It should not send identify")
139139
sendExpectation.isInverted = true
140140
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in
@@ -153,7 +153,7 @@ class IdentityTests: XCTestCase {
153153

154154
func testSetDeviceId() throws {
155155
let storage = try makeStorage()
156-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
156+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
157157
let sendExpectation = XCTestExpectation(description: "It should not send identify")
158158
sendExpectation.isInverted = true
159159
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in
@@ -174,7 +174,7 @@ class IdentityTests: XCTestCase {
174174

175175
func testIdentifySet() throws {
176176
let storage = try makeStorage()
177-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
177+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
178178
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in }))
179179

180180
let identify = Identify()
@@ -189,7 +189,7 @@ class IdentityTests: XCTestCase {
189189

190190
func testIdentifyUnset() throws {
191191
let storage = try makeStorage()
192-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
192+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
193193
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in }))
194194
amplitude.identity.userProperties = updatedIdentity.userProperties
195195

@@ -207,7 +207,7 @@ class IdentityTests: XCTestCase {
207207

208208
func testIdentifyClearAll() throws {
209209
let storage = try makeStorage()
210-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
210+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
211211
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in }))
212212

213213
let identify = Identify()
@@ -219,7 +219,7 @@ class IdentityTests: XCTestCase {
219219

220220
func testIdentifyUpdate() throws {
221221
let storage = try makeStorage()
222-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
222+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
223223
let ignorePlugin = IdentifyInterceptPlugin { _ in }
224224
amplitude.add(plugin: ignorePlugin)
225225
amplitude.identity.userProperties = updatedIdentity.userProperties
@@ -247,7 +247,7 @@ class IdentityTests: XCTestCase {
247247

248248
func testIdentifyNoOps() throws {
249249
let storage = try makeStorage()
250-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
250+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
251251
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in }))
252252

253253
let identify = Identify()
@@ -265,7 +265,7 @@ class IdentityTests: XCTestCase {
265265

266266
func testIdentifyOrder() throws {
267267
let storage = try makeStorage()
268-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
268+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
269269
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in }))
270270

271271
let existingProperties = ["foo": 1, "bar": 2]
@@ -285,7 +285,7 @@ class IdentityTests: XCTestCase {
285285

286286
func testIdentifyNonOpProperties() throws {
287287
let storage = try makeStorage()
288-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
288+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
289289
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in }))
290290

291291
let identify = IdentifyEvent()
@@ -300,7 +300,7 @@ class IdentityTests: XCTestCase {
300300

301301
func testIdentifyEventOptionsSetsUserAndDeviceId() throws {
302302
let storage = try makeStorage()
303-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
303+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
304304
amplitude.add(plugin: IdentifyInterceptPlugin(block: { _ in }))
305305

306306
amplitude.identify(userProperties: [:], options: EventOptions(userId: updatedIdentity.userId,
@@ -317,7 +317,7 @@ class IdentityTests: XCTestCase {
317317

318318
func testReset() throws {
319319
let storage = try makeStorage()
320-
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage))
320+
let amplitude = Amplitude(configuration: Configuration(apiKey: "", storageProvider: storage, offline: NetworkConnectivityCheckerPlugin.Disabled))
321321
amplitude.reset()
322322

323323
XCTAssertEqual(amplitude.identity.userProperties as NSDictionary, NSDictionary())

Tests/AmplitudeTests/Plugins/NetworkTrackingPluginTest.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ final class NetworkTrackingPluginTest: XCTestCase {
5858
storageProvider: storageMem,
5959
flushMaxRetries: 0,
6060
autocapture: .networkTracking,
61+
offline: NetworkConnectivityCheckerPlugin.Disabled,
6162
networkTrackingOptions: options,
6263
enableAutoCaptureRemoteConfig: false)
6364
amplitude = Amplitude(configuration: configuration)

0 commit comments

Comments
 (0)