From 9050405b4f33b2b9b70458fcf3e43b80c940eef7 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Sun, 12 Apr 2026 00:55:42 -0500 Subject: add shortcuts widgets and power-user workflows --- HutchTests/DeepLinkTests.swift | 90 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 HutchTests/DeepLinkTests.swift (limited to 'HutchTests/DeepLinkTests.swift') diff --git a/HutchTests/DeepLinkTests.swift b/HutchTests/DeepLinkTests.swift new file mode 100644 index 0000000..12f759b --- /dev/null +++ b/HutchTests/DeepLinkTests.swift @@ -0,0 +1,90 @@ +import Foundation +import Testing +@testable import Hutch + +struct DeepLinkTests { + + @Test + func parsesHomeLink() { + let link = DeepLink(url: URL(string: "hutch://home")!) + #expect(link == .home) + } + + @Test + func parsesNilPathAsHome() { + let link = DeepLink(url: URL(string: "hutch://")!) + #expect(link == .home) + } + + @Test + func parsesRepositoryLink() { + let link = DeepLink(url: URL(string: "hutch://git/~user/repo")!) + #expect(link == .repository(owner: "~user", repo: "repo")) + } + + @Test + func parsesTicketLink() { + let link = DeepLink(url: URL(string: "hutch://todo/~owner/tracker/42")!) + #expect(link == .ticket(owner: "~owner", tracker: "tracker", ticketId: 42)) + } + + @Test + func parsesBuildJobLink() { + let link = DeepLink(url: URL(string: "hutch://builds/12345")!) + #expect(link == .build(jobId: 12345)) + } + + @Test + func parsesBuildsTabLink() { + let link = DeepLink(url: URL(string: "hutch://builds")!) + #expect(link == .buildsTab) + } + + @Test + func parsesRepositoriesTabLink() { + let link = DeepLink(url: URL(string: "hutch://repositories")!) + #expect(link == .repositoriesTab) + } + + @Test + func parsesTrackersTabLink() { + let link = DeepLink(url: URL(string: "hutch://trackers")!) + #expect(link == .trackersTab) + } + + @Test + func parsesSystemStatusLink() { + let link = DeepLink(url: URL(string: "hutch://status")!) + #expect(link == .systemStatus) + } + + @Test + func parsesLookupLink() { + let link = DeepLink(url: URL(string: "hutch://lookup")!) + #expect(link == .lookup) + } + + @Test + func rejectsNonHutchScheme() { + let link = DeepLink(url: URL(string: "https://example.com/home")!) + #expect(link == nil) + } + + @Test + func rejectsUnknownPath() { + let link = DeepLink(url: URL(string: "hutch://unknown")!) + #expect(link == nil) + } + + @Test + func rejectsTicketLinkWithNonNumericId() { + let link = DeepLink(url: URL(string: "hutch://todo/~owner/tracker/abc")!) + #expect(link == nil) + } + + @Test + func rejectsBuildLinkWithNonNumericId() { + let link = DeepLink(url: URL(string: "hutch://builds/abc")!) + #expect(link == nil) + } +} -- cgit v1.2.3