import CottonKit import XCTest @testable import CottonUI /// The phone reports its own hitches (fanperf, owner 15 Oct 2026: "the /// animations must never make the app heavy; prove it, keep it proven"): a /// MetricKit payload's four figures go to the core as the device's usage and /// land on its row, and nothing else of the payload is written anywhere. final class UsageReporterTests: XCTestCase { /// A core that keeps every request it was asked. private final class Told: CottonCalling, @unchecked Sendable { var asked: [(method: String, body: String)] = [] func callRaw(_ method: String, requestJSON: String) async throws -> String { asked.append((method, requestJSON)) return #"{"ok":true,"data":{"said":true}}"# } func subscribe(_ handler: @escaping @Sendable (CottonEvent) -> Void) {} func close() {} } /// RULE: Nothing of a MetricKit payload is logged or written outside the device's row — the reporter has no log, print, file write or payload dump of its own, so the owner's usage lives only as the four numbers the definition shows. func testNothingOfThePayloadIsLogged() throws { let source = SourceSweep.withoutComments( try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/Diagnostics/UsageReporter.swift", ownedBy: "fanperf")) for spoken in ["Logger", "print(", "NSLog", "os_log", "Log.", "debugPrint", "dump(", "jsonRepresentation", "dictionaryRepresentation", ".write(", "FileManager"] { XCTAssertFalse(source.contains(spoken), "UsageReporter writes `\(spoken)` — a payload goes only to diagnostics.say") } } }