feat: add Finder, ranking reset, and quit actions
This commit is contained in:
@@ -109,6 +109,32 @@ func typedSearchUsesHistoryOnlyForEqualTextRanks() {
|
||||
])
|
||||
}
|
||||
|
||||
@Test @MainActor
|
||||
func resetRankingClearsOnlySelectedIdentityAndPersistsAcrossRelaunch() {
|
||||
let suite = "ConjureHistoryTests.\(UUID().uuidString)"
|
||||
let defaults = UserDefaults(suiteName: suite)!
|
||||
defer { defaults.removePersistentDomain(forName: suite) }
|
||||
let instant = Date(timeIntervalSinceReferenceDate: 6_000)
|
||||
let history = LaunchHistory(defaults: defaults, now: { instant })
|
||||
let alpha = historyApplication("Editor Alpha")
|
||||
let first = Application(url: URL(fileURLWithPath: "/First/Editor.app"), name: "Editor")
|
||||
let second = Application(url: URL(fileURLWithPath: "/Second/Editor.app"), name: "Editor")
|
||||
let apps = [alpha, first, second]
|
||||
history.recordLaunch(of: second)
|
||||
history.recordLaunch(of: first)
|
||||
history.recordLaunch(of: first)
|
||||
#expect(history.suggestions(in: apps).map(\.id) == [first.id, second.id, alpha.id])
|
||||
|
||||
history.resetRanking(of: first)
|
||||
history.resetRanking(of: first)
|
||||
#expect(history.suggestions(in: apps).map(\.id) == [second.id, first.id, alpha.id])
|
||||
#expect(history.results(for: "editor", in: apps).map(\.id) == [second.id, first.id, alpha.id])
|
||||
let reloaded = LaunchHistory(defaults: UserDefaults(suiteName: suite)!, now: { instant })
|
||||
#expect(reloaded.suggestions(in: apps).map(\.id) == [second.id, first.id, alpha.id])
|
||||
reloaded.recordLaunch(of: first)
|
||||
#expect(reloaded.suggestions(in: apps).map(\.id) == [first.id, second.id, alpha.id])
|
||||
}
|
||||
|
||||
private func historyApplication(_ name: String) -> Application {
|
||||
Application(url: URL(fileURLWithPath: "/Applications/HistoryTests/\(name).app"), name: name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user