1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
import Testing
@testable import Hutch
struct AppStateTests {
@Test
@MainActor
func presentRepositoryDeepLinkErrorSetsUserFacingMessage() {
let appState = AppState()
appState.presentRepositoryDeepLinkError()
#expect(appState.deepLinkError == "The repository could not be found or is inaccessible.")
}
@Test
@MainActor
func presentTicketDeepLinkErrorSetsUserFacingMessage() {
let appState = AppState()
appState.presentTicketDeepLinkError()
#expect(appState.deepLinkError == "The ticket could not be found or is inaccessible.")
}
@Test
@MainActor
func openSystemStatusSelectsMoreTabAndQueuesNavigation() {
let appState = AppState()
appState.openSystemStatus()
#expect(appState.selectedTab == .more)
#expect(appState.pendingTabNavigation == .systemStatus)
}
@Test
@MainActor
func navigateToBuildsListSelectsBuildsTabAndQueuesBuildsNavigation() {
let appState = AppState()
appState.navigateToBuildsList()
#expect(appState.selectedTab == .builds)
#expect(appState.pendingTabNavigation == .builds)
}
@Test
@MainActor
func navigationHelpersQueueExpectedTargets() {
let appState = AppState()
let repository = RepositorySummary(
fields: .init(
id: 1,
rid: "repo",
service: .git,
name: "hutch",
description: nil,
visibility: .publicVisibility,
updated: .distantPast,
owner: Entity(canonicalName: "~owner"),
head: nil
)
)
let tracker = TrackerSummary(
id: 2,
rid: "tracker",
name: "todo",
description: nil,
visibility: .publicVisibility,
updated: .distantPast,
owner: Entity(canonicalName: "~owner")
)
appState.navigateToRepository(repository)
#expect(appState.selectedTab == .repositories)
#expect(appState.pendingTabNavigation == .repository(repository))
appState.navigateToTracker(tracker)
#expect(appState.selectedTab == .tickets)
#expect(appState.pendingTabNavigation == .tracker(tracker))
appState.navigateToBuild(jobId: 42)
#expect(appState.selectedTab == .builds)
#expect(appState.pendingDeepLink == .build(jobId: 42))
appState.navigateToTicket(ownerUsername: "owner", trackerName: "todo", ticketId: 9)
#expect(appState.selectedTab == .tickets)
#expect(appState.pendingDeepLink == .ticket(owner: "owner", tracker: "todo", ticketId: 9))
}
}
|