Skip to content

Commit df70419

Browse files
committed
Remove test with assertions, replace instead by tests ensuring we set the context ID
1 parent af610bf commit df70419

File tree

3 files changed

+75
-33
lines changed

3 files changed

+75
-33
lines changed

firefox-ios/Client.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@
871871
8A1A93592B757C7C0069C190 /* landscape.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A1A93532B757C7B0069C190 /* landscape.json */; };
872872
8A1A935A2B757C7C0069C190 /* portrait.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A1A93542B757C7B0069C190 /* portrait.json */; };
873873
8A1A935B2B757C7C0069C190 /* wave.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A1A93552B757C7B0069C190 /* wave.json */; };
874+
8A1C0B8F2E723EDF0030DCC8 /* AppLaunchUtilTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A1C0B8E2E723EDC0030DCC8 /* AppLaunchUtilTests.swift */; };
874875
8A1CBB952BE017D3008BE4D4 /* MicrosurveyPromptAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A1CBB942BE017D3008BE4D4 /* MicrosurveyPromptAction.swift */; };
875876
8A1CBB972BE0182C008BE4D4 /* MicrosurveyPromptMiddleware.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A1CBB962BE0182C008BE4D4 /* MicrosurveyPromptMiddleware.swift */; };
876877
8A1CBB992BE01839008BE4D4 /* MicrosurveyPromptState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A1CBB982BE01839008BE4D4 /* MicrosurveyPromptState.swift */; };
@@ -8577,6 +8578,7 @@
85778578
8A1A93532B757C7B0069C190 /* landscape.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = landscape.json; sourceTree = "<group>"; };
85788579
8A1A93542B757C7B0069C190 /* portrait.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = portrait.json; sourceTree = "<group>"; };
85798580
8A1A93552B757C7B0069C190 /* wave.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = wave.json; sourceTree = "<group>"; };
8581+
8A1C0B8E2E723EDC0030DCC8 /* AppLaunchUtilTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLaunchUtilTests.swift; sourceTree = "<group>"; };
85808582
8A1CBB942BE017D3008BE4D4 /* MicrosurveyPromptAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrosurveyPromptAction.swift; sourceTree = "<group>"; };
85818583
8A1CBB962BE0182C008BE4D4 /* MicrosurveyPromptMiddleware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrosurveyPromptMiddleware.swift; sourceTree = "<group>"; };
85828584
8A1CBB982BE01839008BE4D4 /* MicrosurveyPromptState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrosurveyPromptState.swift; sourceTree = "<group>"; };
@@ -12715,6 +12717,7 @@
1271512717
8A171A6029F82AD90085770E /* Application */ = {
1271612718
isa = PBXGroup;
1271712719
children = (
12720+
8A1C0B8E2E723EDC0030DCC8 /* AppLaunchUtilTests.swift */,
1271812721
BC0723512E33D7A2005BAC05 /* AppleIntelligenceUtilTests.swift */,
1271912722
5AD3B67F2CF6674B00AFA1FE /* MockUIApplication.swift */,
1272012723
5AD3B6792CF653A200AFA1FE /* MockLocale.swift */,
@@ -19242,6 +19245,7 @@
1924219245
8AF3B15C2AF99C77009BB262 /* ReadingListPanelTests.swift in Sources */,
1924319246
8AF99B5429EF2AF100108DEC /* MockLogger.swift in Sources */,
1924419247
AB9CBC082C53B7CD00102610 /* TrackingProtectionStateTests.swift in Sources */,
19248+
8A1C0B8F2E723EDF0030DCC8 /* AppLaunchUtilTests.swift in Sources */,
1924519249
E1EAA5F12D49470900D3039C /* ToolbarStateTests.swift in Sources */,
1924619250
5A9A09D428B01D8700B6F51E /* MockTelemetryWrapper.swift in Sources */,
1924719251
C80C11F028B3C9150062922A /* MockUserDefaults.swift in Sources */,
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/
4+
5+
import Shared
6+
import XCTest
7+
8+
@testable import Client
9+
10+
@MainActor
11+
final class AppLaunchUtilTests: XCTestCase {
12+
var profile: MockProfile!
13+
14+
override func setUp() {
15+
super.setUp()
16+
DependencyHelperMock().bootstrapDependencies()
17+
TelemetryContextualIdentifier.clearUserDefaults()
18+
profile = MockProfile()
19+
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
20+
}
21+
22+
override func tearDown() {
23+
DependencyHelperMock().reset()
24+
TelemetryContextualIdentifier.clearUserDefaults()
25+
profile = nil
26+
super.tearDown()
27+
}
28+
29+
// MARK: Telemetry contextual identifier setup
30+
31+
func testGivenTosEnabled_WhenTosAccepted_ThenContextIdIsSet() {
32+
profile.prefs.setInt(1, forKey: PrefsKeys.TermsOfServiceAccepted)
33+
setupNimbusToSForTesting(isEnabled: true)
34+
let subject = createSubject()
35+
subject.setUpPreLaunchDependencies()
36+
37+
XCTAssertNotNil(TelemetryContextualIdentifier.contextId)
38+
}
39+
40+
func testGivenTosEnabled_WhenTosNotAccepted_ThenContextIdIsSet() {
41+
profile.prefs.setInt(0, forKey: PrefsKeys.TermsOfServiceAccepted)
42+
setupNimbusToSForTesting(isEnabled: true)
43+
let subject = createSubject()
44+
subject.setUpPreLaunchDependencies()
45+
46+
XCTAssertNotNil(TelemetryContextualIdentifier.contextId)
47+
}
48+
49+
func testGivenTosDisabled_ThenContextIdIsSet() {
50+
setupNimbusToSForTesting(isEnabled: false)
51+
let subject = createSubject()
52+
subject.setUpPreLaunchDependencies()
53+
54+
XCTAssertNotNil(TelemetryContextualIdentifier.contextId)
55+
}
56+
57+
// MARK: Helper methods
58+
59+
func createSubject() -> AppLaunchUtil {
60+
let subject = AppLaunchUtil(profile: profile)
61+
return subject
62+
}
63+
64+
private func setupNimbusToSForTesting(isEnabled: Bool) {
65+
FxNimbus.shared.features.tosFeature.with { _, _ in
66+
return TosFeature(
67+
status: isEnabled
68+
)
69+
}
70+
}
71+
}

firefox-ios/firefox-ios-tests/Tests/ClientTests/Telemetry/FxSuggestTelemetryTests.swift

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,6 @@ final class FxSuggestTelemetryTests: XCTestCase {
103103
wait(for: [expectation], timeout: 5.0)
104104
}
105105

106-
func testClickEventPing_givenNoContextId_thenPingNotSent() {
107-
let info = RustFirefoxSuggestionTelemetryInfo.amp(
108-
blockId: 1234,
109-
advertiser: "test-advertiser",
110-
iabCategory: "test-category",
111-
impressionReportingURL: URL(string: "https://test1.com"),
112-
clickReportingURL: URL(string: "https://test2.com")
113-
)
114-
115-
let subject = createSubject(gleanWrapper: gleanWrapper)
116-
subject.clickEvent(telemetryInfo: info, position: 0)
117-
118-
XCTAssertNil(gleanWrapper.savedPing)
119-
}
120-
121106
func testClickEventPing_givenContextId_thenPingSent() {
122107
TelemetryContextualIdentifier.setupContextId()
123108
let info = RustFirefoxSuggestionTelemetryInfo.amp(
@@ -210,24 +195,6 @@ final class FxSuggestTelemetryTests: XCTestCase {
210195
wait(for: [expectation], timeout: 5.0)
211196
}
212197

213-
func testImpressionEventPing_givenNoContextId_thenPingNotSent() {
214-
let info = RustFirefoxSuggestionTelemetryInfo.amp(
215-
blockId: 1234,
216-
advertiser: "test-advertiser",
217-
iabCategory: "test-category",
218-
impressionReportingURL: URL(string: "https://test1.com"),
219-
clickReportingURL: URL(string: "https://test2.com")
220-
)
221-
222-
let subject = createSubject(gleanWrapper: gleanWrapper)
223-
subject.impressionEvent(telemetryInfo: info,
224-
position: 1,
225-
didTap: true,
226-
didAbandonSearchSession: false)
227-
228-
XCTAssertNil(gleanWrapper.savedPing)
229-
}
230-
231198
func testImpressionEventPing_givenContextId_thenPingSent() {
232199
TelemetryContextualIdentifier.setupContextId()
233200
let info = RustFirefoxSuggestionTelemetryInfo.amp(

0 commit comments

Comments
 (0)