@@ -33,6 +33,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
33
33
. onFinish { _ in
34
34
expectOnFinish. fulfill ( )
35
35
}
36
+ . embedInNavigationView ( )
36
37
}
37
38
. hostAndInspect ( with: \. inspection)
38
39
. extractWorkflowLauncher ( )
@@ -71,6 +72,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
71
72
. onFinish { _ in
72
73
expectOnFinish. fulfill ( )
73
74
}
75
+ . embedInNavigationView ( )
74
76
}
75
77
. hostAndInspect ( with: \. inspection)
76
78
. extractWorkflowLauncher ( )
@@ -109,6 +111,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
109
111
. onFinish { _ in
110
112
expectOnFinish. fulfill ( )
111
113
}
114
+ . embedInNavigationView ( )
112
115
}
113
116
. hostAndInspect ( with: \. inspection)
114
117
. extractWorkflowLauncher ( )
@@ -152,6 +155,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
152
155
. onFinish { _ in
153
156
expectOnFinish. fulfill ( )
154
157
}
158
+ . embedInNavigationView ( )
155
159
}
156
160
. hostAndInspect ( with: \. inspection)
157
161
. extractWorkflowLauncher ( )
@@ -196,6 +200,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
196
200
. onFinish { _ in
197
201
expectOnFinish. fulfill ( )
198
202
}
203
+ . embedInNavigationView ( )
199
204
}
200
205
. hostAndInspect ( with: \. inspection)
201
206
. extractWorkflowLauncher ( )
@@ -240,6 +245,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
240
245
. onFinish { _ in
241
246
expectOnFinish. fulfill ( )
242
247
}
248
+ . embedInNavigationView ( )
243
249
}
244
250
. hostAndInspect ( with: \. inspection)
245
251
. extractWorkflowLauncher ( )
@@ -269,7 +275,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
269
275
WorkflowItem ( FR1 . self) . presentationType ( . navigationLink)
270
276
WorkflowItem ( FR1 . self) . presentationType ( . navigationLink)
271
277
WorkflowItem ( FR1 . self)
272
- }
278
+ } . embedInNavigationView ( )
273
279
}
274
280
. hostAndInspect ( with: \. inspection)
275
281
. extractWorkflowLauncher ( )
@@ -337,7 +343,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
337
343
WorkflowItem ( FR5 . self) . presentationType ( . navigationLink)
338
344
WorkflowItem ( FR6 . self) . presentationType ( . navigationLink)
339
345
WorkflowItem ( FR7 . self) . presentationType ( . navigationLink)
340
- }
346
+ } . embedInNavigationView ( )
341
347
}
342
348
. hostAndInspect ( with: \. inspection)
343
349
. extractWorkflowLauncher ( )
@@ -364,6 +370,51 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
364
370
try await wfr7. find ( FR7 . self) . proceedInWorkflow ( )
365
371
}
366
372
373
+ func testWorkflowCanBeAbandoned( ) async throws {
374
+ struct FR1 : View , FlowRepresentable , Inspectable {
375
+ var _workflowPointer : AnyFlowRepresentable ?
376
+ var body : some View { Text ( " FR1 type " ) }
377
+ }
378
+ struct FR2 : View , FlowRepresentable , Inspectable {
379
+ var _workflowPointer : AnyFlowRepresentable ?
380
+ var body : some View { Text ( " FR2 type " ) }
381
+ }
382
+ struct FR3 : View , FlowRepresentable , Inspectable {
383
+ var _workflowPointer : AnyFlowRepresentable ?
384
+ var body : some View {
385
+ Button ( " continue " ) {
386
+ workflow? . abandon ( )
387
+ }
388
+ }
389
+ }
390
+
391
+ let wfr1 = try await MainActor . run {
392
+ WorkflowView {
393
+ WorkflowItem ( FR1 . self) . presentationType ( . navigationLink)
394
+ WorkflowItem ( FR2 . self) . presentationType ( . navigationLink)
395
+ WorkflowItem ( FR3 . self) . presentationType ( . navigationLink)
396
+ } . embedInNavigationView ( )
397
+ }
398
+ . hostAndInspect ( with: \. inspection)
399
+ . extractWorkflowLauncher ( )
400
+ . extractWorkflowItemWrapper ( )
401
+
402
+ let navLink = try XCTUnwrap ( try ? wfr1. find ( ViewType . NavigationLink. self) )
403
+ try await wfr1. proceedAndCheckNavLink ( on: FR1 . self)
404
+ XCTAssertFalse ( try navLink. isActive ( ) )
405
+
406
+ let wfr2 = try await wfr1. extractWrappedWrapper ( )
407
+ try await wfr2. proceedAndCheckNavLink ( on: FR2 . self)
408
+
409
+ let wfr3 = try await wfr2. extractWrappedWrapper ( )
410
+ XCTAssertNoThrow ( try wfr3. find ( button: " continue " ) . tap ( ) )
411
+
412
+ XCTAssertNoThrow ( try wfr1. find ( FR1 . self) )
413
+ XCTAssertEqual ( try wfr1. find ( ViewType . NavigationLink. self) . isActive ( ) , false )
414
+ XCTAssertThrowsError ( try wfr1. find ( FR2 . self) )
415
+ XCTAssertThrowsError ( try wfr1. find ( FR3 . self) )
416
+ }
417
+
367
418
func testNavLinkWorkflowsCanSkipTheFirstItem( ) async throws {
368
419
struct FR1 : View , FlowRepresentable , Inspectable {
369
420
var _workflowPointer : AnyFlowRepresentable ?
@@ -384,6 +435,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
384
435
WorkflowItem ( FR2 . self) . presentationType ( . navigationLink)
385
436
WorkflowItem ( FR3 . self)
386
437
}
438
+ . embedInNavigationView ( )
387
439
}
388
440
. hostAndInspect ( with: \. inspection)
389
441
. extractWorkflowLauncher ( )
@@ -418,6 +470,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
418
470
WorkflowItem ( FR2 . self) . presentationType ( . navigationLink)
419
471
WorkflowItem ( FR3 . self)
420
472
}
473
+ . embedInNavigationView ( )
421
474
}
422
475
. hostAndInspect ( with: \. inspection)
423
476
. extractWorkflowLauncher ( )
@@ -458,6 +511,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
458
511
WorkflowItem ( FR3 . self)
459
512
WorkflowItem ( FR4 . self)
460
513
}
514
+ . embedInNavigationView ( )
461
515
}
462
516
. hostAndInspect ( with: \. inspection)
463
517
. extractWorkflowLauncher ( )
@@ -500,6 +554,7 @@ final class SwiftCurrent_NavigationLinkTests: XCTestCase, View {
500
554
. onFinish { _ in
501
555
expectOnFinish. fulfill ( )
502
556
}
557
+ . embedInNavigationView ( )
503
558
}
504
559
. hostAndInspect ( with: \. inspection)
505
560
. extractWorkflowLauncher ( )
0 commit comments