diff options
| author | Christian Cleberg <[email protected]> | 2026-08-07 01:44:17 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-08-07 01:44:17 -0500 |
| commit | a0ed11a3c4ddb2f532fa70884dc2829a23a5eec8 (patch) | |
| tree | 6124f8e184a5ba3b648f173af597928caa5fcd84 /HutchTests/RecentActivityStoreTests.swift | |
| parent | 5e4e259d8bfd9b062aa39af793ec3a59b70ad7f0 (diff) | |
| download | hutch-a0ed11a3c4ddb2f532fa70884dc2829a23a5eec8.tar.gz hutch-a0ed11a3c4ddb2f532fa70884dc2829a23a5eec8.tar.bz2 hutch-a0ed11a3c4ddb2f532fa70884dc2829a23a5eec8.zip | |
Let users clear recent activity on Home (#11)
Add a Clear button in the Home Recent section header to drop all
entries, plus swipe-to-delete on each row to forget a single item
(gated on the existing swipe-actions setting). Back it with
RecentActivityStore.clear and remove(id:), with unit tests.
Diffstat (limited to 'HutchTests/RecentActivityStoreTests.swift')
| -rw-r--r-- | HutchTests/RecentActivityStoreTests.swift | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/HutchTests/RecentActivityStoreTests.swift b/HutchTests/RecentActivityStoreTests.swift new file mode 100644 index 0000000..e6fcc04 --- /dev/null +++ b/HutchTests/RecentActivityStoreTests.swift @@ -0,0 +1,38 @@ +import Foundation +import Testing +@testable import Hutch + +struct RecentActivityStoreTests { + @Test + func removeDropsMatchingEntryKeepingOthers() { + let defaults = UserDefaults(suiteName: #function)! + defaults.removePersistentDomain(forName: #function) + + RecentActivityStore.recordBuild(jobId: 1, title: "Build 1", defaults: defaults) + RecentActivityStore.recordBuild(jobId: 2, title: "Build 2", defaults: defaults) + + RecentActivityStore.remove(id: "build:1", defaults: defaults) + + let remaining = RecentActivityStore.load(defaults: defaults) + #expect(remaining.map(\.id) == ["build:2"]) + } + + @Test + func clearRemovesAllEntries() { + let defaults = UserDefaults(suiteName: #function)! + defaults.removePersistentDomain(forName: #function) + + RecentActivityStore.recordBuild(jobId: 1, title: "Build 1", defaults: defaults) + RecentActivityStore.recordTicket( + ownerUsername: "~alice", + trackerName: "hutch", + ticketId: 42, + title: "A ticket", + defaults: defaults + ) + + RecentActivityStore.clear(defaults: defaults) + + #expect(RecentActivityStore.load(defaults: defaults).isEmpty) + } +} |
