Refresh puter UI, power telemetry and demand-aware monitoring
Build and test / macos (push) Waiting to run
Signed release / release (push) Waiting to run

This commit is contained in:
2026-09-22 20:03:16 -04:00
parent 0da94715be
commit 4bfa239aa0
38 changed files with 1728 additions and 492 deletions
@@ -0,0 +1,66 @@
import XCTest
@testable import puter
final class SamplingDemandTests: XCTestCase {
func testNoConsumerMeansNoTimer() {
let demand = make(active: false)
XCTAssertNil(demand.interval)
XCTAssertFalse(demand.processInventory)
XCTAssertFalse(demand.hardware)
XCTAssertFalse(demand.services)
}
func testBackgroundMenuUsesLightweightCountersOnly() {
let demand = make(active: false, menu: true)
XCTAssertEqual(demand.interval, .seconds(10))
XCTAssertTrue(demand.telemetry)
XCTAssertFalse(demand.processInventory)
XCTAssertFalse(demand.services)
XCTAssertFalse(demand.hardware)
}
func testSettingsWithoutConsumersIsIdle() {
XCTAssertNil(make(section: .settings).interval)
}
func testServicesOnlyScansVisibleServices() {
let demand = make(section: .services)
XCTAssertTrue(demand.services)
XCTAssertFalse(demand.telemetry)
XCTAssertFalse(demand.processInventory)
XCTAssertEqual(demand.interval, .seconds(3))
}
func testRecordingKeepsBackgroundTelemetry() {
let demand = make(active: false, recording: true)
XCTAssertTrue(demand.processInventory)
XCTAssertTrue(demand.telemetry)
XCTAssertTrue(demand.hardware)
XCTAssertEqual(demand.interval, UpdateSpeed.normal.interval)
}
func testPauseStopsEvenRecordingTimer() {
XCTAssertNil(make(speed: .paused, recording: true, menu: true).interval)
}
func testPowerMenuOnlyNeedsHardware() {
let demand = make(active: false, menu: true, power: true)
XCTAssertTrue(demand.hardware)
XCTAssertFalse(demand.telemetry)
XCTAssertFalse(demand.processInventory)
}
func testAlertsRetainSystemSamplingWithoutProcessScan() {
let demand = make(active: false, alerts: true)
XCTAssertTrue(demand.telemetry)
XCTAssertFalse(demand.processInventory)
XCTAssertNotNil(demand.interval)
}
private func make(active: Bool = true, section: TaskSection = .processes,
speed: UpdateSpeed = .normal, recording: Bool = false,
alerts: Bool = false, menu: Bool = false, power: Bool = false) -> SamplingDemand {
SamplingDemand(active: active, section: section, speed: speed,
recording: recording, alerts: alerts, menuBar: menu, powerMenu: power)
}
}