@@ -20,6 +20,7 @@ struct VPNMenuStateTests {
20
20
$0. lastHandshake= . init( date: Date . now)
21
21
$0. lastPing= . with{
22
22
$0. latency= . init( floatLiteral: 0.05 )
23
+ $0. didP2P= true
23
24
}
24
25
$0. fqdn= [ " foo.coder " ]
25
26
}
@@ -32,6 +33,9 @@ struct VPNMenuStateTests {
32
33
#expect( storedAgent. wsName== " foo " )
33
34
#expect( storedAgent. primaryHost== " foo.coder " )
34
35
#expect( storedAgent. status== . okay)
36
+ #expect( storedAgent. statusString. contains ( " You're connected peer-to-peer. " ) )
37
+ #expect( storedAgent. statusString. contains ( " You ↔ 50.00 ms ↔ foo " ) )
38
+ #expect( storedAgent. statusString. contains ( " Last handshake: Just now " ) )
35
39
}
36
40
37
41
@Test
@@ -98,6 +102,26 @@ struct VPNMenuStateTests {
98
102
#expect( storedAgent. status== . warn)
99
103
}
100
104
105
+ @Test
106
+ mutating func testUpsertAgent_connecting( ) async throws {
107
+ let agentID = UUID ( )
108
+ let workspaceID = UUID ( )
109
+ state. upsertWorkspace ( Vpn_Workspace . with { $0. id= workspaceID. uuidData; $0. name= " foo " } )
110
+
111
+ let agent = Vpn_Agent . with {
112
+ $0. id= agentID. uuidData
113
+ $0. workspaceID= workspaceID. uuidData
114
+ $0. name= " agent1 "
115
+ $0. lastHandshake= . init( )
116
+ $0. fqdn= [ " foo.coder " ]
117
+ }
118
+
119
+ state. upsertAgent ( agent)
120
+
121
+ let storedAgent = try #require( state. agents [ agentID] )
122
+ #expect( storedAgent. status== . connecting)
123
+ }
124
+
101
125
@Test
102
126
mutating func testUpsertAgent_unhealthyAgent( ) async throws {
103
127
let agentID = UUID ( )
@@ -176,6 +200,7 @@ struct VPNMenuStateTests {
176
200
$0. name= " agent1 "
177
201
$0. lastHandshake= . init( date: Date . now. addingTimeInterval ( - 200 ) )
178
202
$0. lastPing= . with{
203
+ $0. didP2P= false
179
204
$0. latency= . init( floatLiteral: 0.05 )
180
205
}
181
206
$0. fqdn= [ " foo.coder " ]
@@ -187,6 +212,10 @@ struct VPNMenuStateTests {
187
212
#expect( output [ 0 ] . id== agentID)
188
213
#expect( output [ 0 ] . wsName== " foo " )
189
214
#expect( output [ 0 ] . status== . okay)
215
+ let storedAgentFromSort = try #require( state. agents [ agentID] )
216
+ #expect( storedAgentFromSort. statusString. contains ( " You're connected through a DERP relay. " ) )
217
+ #expect( storedAgentFromSort. statusString. contains ( " Total latency: 50.00 ms " ) )
218
+ #expect( storedAgentFromSort. statusString. contains ( " Last handshake: 3 minutes ago " ) )
190
219
}
191
220
192
221
@Test