Files
OSGKeyboard/OSGKeyboardTests/AnalyticsAttributionTests.swift
T
Rocky e5a83843db Expand onboarding and adaptive keyboard intelligence
Add resilient usage analytics, OOBE gateway flows, clipboard semantic ranking, purchase recovery, style learning, and managed current-information search.
2026-08-22 16:33:18 +08:00

45 lines
1.3 KiB
Swift

// AnalyticsAttributionTests.swift
// OSGKeyboardTests
//
// FIRST_OPEN attribution accepts only trusted, structured launch signals.
import Foundation
@testable import OSGKeyboard
import OSGKeyboardShared
import XCTest
final class AnalyticsAttributionTests: XCTestCase {
private let validCode = "Abcdefghij_1234567890-"
func testOrdinaryColdLaunchIsAppStoreOrganic() {
XCTAssertEqual(
AnalyticsFirstOpenAttribution.ordinaryLaunch,
.appStoreOrganic
)
}
func testTrustedReferralColdLaunchIsReferral() {
let url = URL(string: "https://osglab.com/i/\(validCode)")!
XCTAssertEqual(
AnalyticsFirstOpenAttribution.trustedChannel(for: url),
.referral
)
}
func testUntrustedQueryCannotCreateSocialAttribution() {
let untrusted = URL(
string: "https://osglab.com/campaign?source=SOCIAL_CONTENT"
)!
let referralWithFreeText = URL(
string: "https://osglab.com/i/\(validCode)?source=anything"
)!
XCTAssertNil(AnalyticsFirstOpenAttribution.trustedChannel(for: untrusted))
XCTAssertEqual(
AnalyticsFirstOpenAttribution.trustedChannel(for: referralWithFreeText),
.referral
)
}
}