@@ -34,31 +34,25 @@ final class AccountInformationViewTests: XCTestCase, WorkflowTestingReceiver {
3434
3535 private typealias MFAViewWorkflowView = WorkflowLauncher < WorkflowItem < MFAView , Never , MFAView > >
3636
37- func testUpdatedAccountInformationView( ) throws {
38- let exp = ViewHosting . loadView ( AccountInformationView ( ) ) . inspection. inspect { view in
39- XCTAssertEqual ( try view. find ( ViewType . Text. self) . string ( ) , " Email: " )
40- XCTAssertEqual ( try view
. find ( ViewType . Text
. self
, skipFound
: 1 ) . string ( ) , " [email protected] " ) 37+ func testUpdatedAccountInformationView( ) async throws {
38+ let view = try await AccountInformationView ( ) . hostAndInspect ( with: \. inspection)
4139
42- XCTAssertEqual ( try view. find ( ViewType . Text. self, skipFound : 2 ) . string ( ) , " Password : " )
43- XCTAssertEqual ( try view. find ( ViewType . SecureField . self) . input ( ) , " supersecure " )
40+ XCTAssertEqual ( try view. find ( ViewType . Text. self) . string ( ) , " Email : " )
41+ XCTAssertEqual ( try view
. find ( ViewType . Text . self
, skipFound : 1 ) . string ( ) , " [email protected] " ) 4442
45- XCTAssertEqual ( view. findAll ( ViewType . Button. self) . count, 2 )
46- }
47- wait ( for: [ exp] , timeout: TestConstant . timeout)
43+ XCTAssertEqual ( try view. find ( ViewType . Text. self, skipFound: 2 ) . string ( ) , " Password: " )
44+ XCTAssertEqual ( try view. find ( ViewType . SecureField. self) . input ( ) , " supersecure " )
45+
46+ XCTAssertEqual ( view. findAll ( ViewType . Button. self) . count, 2 )
4847 }
4948
50- func testAccountInformationCanLaunchUsernameWorkflowAgnostic( ) throws {
49+ func testAccountInformationCanLaunchUsernameWorkflowAgnostic( ) async throws {
5150 Self . workflowLaunchedData. removeAll ( )
52- var accountInformation : InspectableView < ViewType . View < AccountInformationView > > !
53- let exp = ViewHosting . loadView ( AccountInformationView ( ) ) . inspection. inspect { view in
54- accountInformation = view
55- XCTAssertFalse ( try view. actualView ( ) . emailWorkflowLaunched)
56- XCTAssertNoThrow ( try view. find ( ViewType . Button. self) . tap ( ) )
57- XCTAssert ( try view. actualView ( ) . emailWorkflowLaunched)
58- }
59- wait ( for: [ exp] , timeout: TestConstant . timeout)
6051
61- XCTAssertNotNil ( accountInformation)
52+ let accountInformation = try await AccountInformationView ( ) . hostAndInspect ( with: \. inspection)
53+ XCTAssertFalse ( try accountInformation. actualView ( ) . emailWorkflowLaunched)
54+ XCTAssertNoThrow ( try accountInformation. find ( ViewType . Button. self) . tap ( ) )
55+ XCTAssert ( try accountInformation. actualView ( ) . emailWorkflowLaunched)
6256
6357 waitUntil ( Self . workflowTestingData != nil )
6458 let data = Self . workflowTestingData
@@ -79,49 +73,38 @@ final class AccountInformationViewTests: XCTestCase, WorkflowTestingReceiver {
7973 // Complete workflow
8074 ( Self . workflowTestingData? . orchestrationResponder as? WorkflowViewModel ) ? . onFinishPublisher. send ( . args( " new email " ) )
8175
82- wait ( for: [
83- ViewHosting . loadView ( try accountInformation. actualView ( ) ) . inspection. inspect { view in
84- XCTAssertEqual ( try view. actualView ( ) . email, " new email " )
85- XCTAssertFalse ( try view. actualView ( ) . emailWorkflowLaunched)
86- }
87- ] , timeout: TestConstant . timeout)
76+ let view = try await accountInformation. actualView ( ) . hostAndInspect ( with: \. inspection)
77+ XCTAssertEqual ( try view. actualView ( ) . email, " new email " )
78+ XCTAssertFalse ( try view. actualView ( ) . emailWorkflowLaunched)
8879 }
8980
90- func testAccountInformationDoesNotBlowUp_IfUsernameWorkflowReturnsSomethingWEIRD( ) throws {
81+ func testAccountInformationDoesNotBlowUp_IfUsernameWorkflowReturnsSomethingWEIRD( ) async throws {
9182 class CustomObj { }
9283 Self . workflowLaunchedData. removeAll ( )
93- var accountInformation : InspectableView < ViewType . View < AccountInformationView > > !
94- var expectedEmail = " starting value "
95- let exp = ViewHosting . loadView ( AccountInformationView ( ) ) . inspection. inspect { view in
96- accountInformation = view
97- expectedEmail = try view. actualView ( ) . email
98- XCTAssertNoThrow ( try view. find ( ViewType . Button. self) . tap ( ) )
99- }
100- wait ( for: [ exp] , timeout: TestConstant . timeout)
10184
102- if Self . workflowTestingData == nil { throw XCTSkip ( " test data was not created " ) }
85+ let accountInformation = try await AccountInformationView ( ) . hostAndInspect ( with: \. inspection)
86+ let expectedEmail = try accountInformation. actualView ( ) . email
87+
88+ XCTAssertNoThrow ( try accountInformation. find ( ViewType . Button. self) . tap ( ) )
89+
90+ waitUntil ( Self . workflowTestingData != nil )
91+
92+ XCTAssertNotNil ( Self . workflowTestingData)
10393 ( Self . workflowTestingData? . orchestrationResponder as? WorkflowViewModel ) ? . onFinishPublisher. send ( . args( CustomObj ( ) ) )
10494
105- wait ( for: [
106- ViewHosting . loadView ( try accountInformation. actualView ( ) ) . inspection. inspect { view in
107- XCTAssert ( try view. actualView ( ) . emailWorkflowLaunched)
108- XCTAssertEqual ( try view. actualView ( ) . email, expectedEmail)
109- }
110- ] . compactMap { $0 } , timeout: TestConstant . timeout)
95+ let view = try await accountInformation. actualView ( ) . hostAndInspect ( with: \. inspection)
96+ XCTAssert ( try view. actualView ( ) . emailWorkflowLaunched)
97+ XCTAssertEqual ( try view. actualView ( ) . email, expectedEmail)
11198 }
11299
113- func testAccountInformationCanLaunchPasswordWorkflowAgnostic( ) throws {
100+ func testAccountInformationCanLaunchPasswordWorkflowAgnostic( ) async throws {
114101 Self . workflowLaunchedData. removeAll ( )
115- var accountInformation : InspectableView < ViewType . View < AccountInformationView > > !
116- let exp = ViewHosting . loadView ( AccountInformationView ( ) ) . inspection. inspect { view in
117- accountInformation = view
118- XCTAssertFalse ( try view. actualView ( ) . passwordWorkflowLaunched)
119- XCTAssertNoThrow ( try view. find ( ViewType . Button. self, skipFound: 1 ) . tap ( ) )
120- XCTAssert ( try view. actualView ( ) . passwordWorkflowLaunched)
121- }
122- wait ( for: [ exp] , timeout: TestConstant . timeout)
123102
124- XCTAssertNotNil ( accountInformation)
103+ let accountInformation = try await AccountInformationView ( ) . hostAndInspect ( with: \. inspection)
104+
105+ XCTAssertFalse ( try accountInformation. actualView ( ) . passwordWorkflowLaunched)
106+ XCTAssertNoThrow ( try accountInformation. find ( ViewType . Button. self, skipFound: 1 ) . tap ( ) )
107+ XCTAssert ( try accountInformation. actualView ( ) . passwordWorkflowLaunched)
125108
126109 waitUntil ( Self . workflowTestingData != nil )
127110 let data = Self . workflowTestingData
@@ -142,48 +125,39 @@ final class AccountInformationViewTests: XCTestCase, WorkflowTestingReceiver {
142125 // Complete workflow
143126 ( Self . workflowTestingData? . orchestrationResponder as? WorkflowViewModel ) ? . onFinishPublisher. send ( . args( " newPassword " ) )
144127
145- wait ( for: [
146- ViewHosting . loadView ( try accountInformation. actualView ( ) ) . inspection. inspect { view in
147- XCTAssertEqual ( try view. actualView ( ) . password, " newPassword " )
148- XCTAssertFalse ( try view. actualView ( ) . passwordWorkflowLaunched)
149- }
150- ] , timeout: TestConstant . timeout)
128+ let view = try await accountInformation. actualView ( ) . hostAndInspect ( with: \. inspection)
129+ XCTAssertEqual ( try view. actualView ( ) . password, " newPassword " )
130+ XCTAssertFalse ( try view. actualView ( ) . passwordWorkflowLaunched)
151131 }
152132
153- func testAccountInformationDoesNotBlowUp_IfPasswordWorkflowReturnsSomethingWEIRD( ) throws {
133+ func testAccountInformationDoesNotBlowUp_IfPasswordWorkflowReturnsSomethingWEIRD( ) async throws {
154134 class CustomObj { }
155135 Self . workflowLaunchedData. removeAll ( )
156- var accountInformation : InspectableView < ViewType . View < AccountInformationView > > !
157- var expectedPassword = " starting value "
158- let exp = ViewHosting . loadView ( AccountInformationView ( ) ) . inspection. inspect { view in
159- accountInformation = view
160- expectedPassword = try view. actualView ( ) . password
161- XCTAssertNoThrow ( try view. find ( ViewType . Button. self, skipFound: 1 ) . tap ( ) )
162- }
163- wait ( for: [ exp] , timeout: TestConstant . timeout)
164136
165- if Self . workflowTestingData == nil { throw XCTSkip ( " test data was not created " ) }
137+ let accountInformation = try await AccountInformationView ( ) . hostAndInspect ( with: \. inspection)
138+ let expectedPassword = try accountInformation. actualView ( ) . password
139+ XCTAssertNoThrow ( try accountInformation. find ( ViewType . Button. self, skipFound: 1 ) . tap ( ) )
140+
141+ waitUntil ( Self . workflowTestingData != nil )
142+ XCTAssertNotNil ( Self . workflowTestingData)
143+
166144 ( Self . workflowTestingData? . orchestrationResponder as? WorkflowViewModel ) ? . onFinishPublisher. send ( . args( CustomObj ( ) ) )
167145
168- wait ( for: [
169- ViewHosting . loadView ( try accountInformation. actualView ( ) ) . inspection. inspect { view in
170- XCTAssert ( try view. actualView ( ) . passwordWorkflowLaunched)
171- XCTAssertEqual ( try view. actualView ( ) . password, expectedPassword)
172- }
173- ] . compactMap { $0 } , timeout: TestConstant . timeout)
146+ let view = try await accountInformation. actualView ( ) . hostAndInspect ( with: \. inspection)
147+ XCTAssert ( try view. actualView ( ) . passwordWorkflowLaunched)
148+ XCTAssertEqual ( try view. actualView ( ) . password, expectedPassword)
174149 }
175150
176- func testAccountInformationCanLaunchBothWorkflows( ) throws {
177- let exp = ViewHosting . loadView ( AccountInformationView ( ) ) . inspection. inspect { view in
178- XCTAssertEqual ( view. findAll ( MFAViewWorkflowView . self) . count, 0 )
151+ func testAccountInformationCanLaunchBothWorkflows( ) async throws {
152+ let view = try await AccountInformationView ( ) . hostAndInspect ( with: \. inspection)
179153
180- let firstButton = try view. find ( ViewType . Button. self)
181- let secondButton = try view. find ( ViewType . Button. self, skipFound: 1 )
182- XCTAssertNoThrow ( try secondButton. tap ( ) )
183- XCTAssertNoThrow ( try firstButton. tap ( ) )
154+ XCTAssertEqual ( view. findAll ( MFAViewWorkflowView . self) . count, 0 )
184155
185- XCTAssertEqual ( view. findAll ( MFAViewWorkflowView . self) . count, 2 )
186- }
187- wait ( for: [ exp] , timeout: TestConstant . timeout)
156+ let firstButton = try view. find ( ViewType . Button. self)
157+ let secondButton = try view. find ( ViewType . Button. self, skipFound: 1 )
158+ XCTAssertNoThrow ( try secondButton. tap ( ) )
159+ XCTAssertNoThrow ( try firstButton. tap ( ) )
160+
161+ XCTAssertEqual ( view. findAll ( MFAViewWorkflowView . self) . count, 2 )
188162 }
189163}
0 commit comments