From ee9f2904aa319231b7047fca3cb069f0c07019cd Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Sun, 12 Apr 2026 23:19:20 -0500 Subject: feat: add multi-account support Implements: https://todo.sr.ht/~ccleberg/hutch/49 Implements: https://todo.sr.ht/~ccleberg/hutch/50 Implements: https://todo.sr.ht/~ccleberg/hutch/51 --- HutchTests/SystemStatusWidgetSnapshotTests.swift | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'HutchTests/SystemStatusWidgetSnapshotTests.swift') diff --git a/HutchTests/SystemStatusWidgetSnapshotTests.swift b/HutchTests/SystemStatusWidgetSnapshotTests.swift index ddb74b1..7121804 100644 --- a/HutchTests/SystemStatusWidgetSnapshotTests.swift +++ b/HutchTests/SystemStatusWidgetSnapshotTests.swift @@ -64,6 +64,37 @@ struct SystemStatusWidgetSnapshotTests { #expect(SystemStatusWidgetSnapshotStore.load(defaults: defaults) == nil) } + @Test + func snapshotsAreIsolatedPerAccount() { + let defaultsName = "SystemStatusWidgetSnapshotTests-isolation-\(UUID().uuidString)" + let defaults = UserDefaults(suiteName: defaultsName)! + defer { defaults.removePersistentDomain(forName: defaultsName) } + + let firstSnapshot = SystemStatusWidgetSnapshot( + services: [.init(id: "git", name: "git.sr.ht", status: "Operational", requiresAttention: false)], + hasDisruption: false, + overallStatusText: "All monitored services operational", + bannerSummary: "", + updatedAt: Date(timeIntervalSince1970: 100) + ) + let secondSnapshot = SystemStatusWidgetSnapshot( + services: [.init(id: "builds", name: "builds.sr.ht", status: "Degraded", requiresAttention: true)], + hasDisruption: true, + overallStatusText: "Experiencing disruptions", + bannerSummary: "builds.sr.ht disrupted", + updatedAt: Date(timeIntervalSince1970: 200) + ) + + SystemStatusWidgetSnapshotStore.save(firstSnapshot, accountID: "account-a", defaults: defaults) + SystemStatusWidgetSnapshotStore.save(secondSnapshot, accountID: "account-b", defaults: defaults) + + #expect(SystemStatusWidgetSnapshotStore.load(accountID: "account-a", defaults: defaults)?.services.first?.name == "git.sr.ht") + #expect(SystemStatusWidgetSnapshotStore.load(accountID: "account-b", defaults: defaults)?.services.first?.name == "builds.sr.ht") + + ActiveAccountContextStore.save("account-b", defaults: defaults) + #expect(SystemStatusWidgetSnapshotStore.load(defaults: defaults)?.bannerSummary == "builds.sr.ht disrupted") + } + @Test func unavailableSnapshotHasEmptyServices() { let snapshot = SystemStatusWidgetSnapshot.unavailable -- cgit v1.2.3