@@ -151,6 +151,38 @@ struct NavigationTests {
151151 #expect( node. props [ " hasConfirmationDialog " ] == nil ) // dismissed
152152 }
153153
154+ @Test ( " searchable surfaces a per-screen field whose input drives its binding " )
155+ func searchable( ) {
156+ struct Screen : View {
157+ @State var query = " "
158+ var body : some View {
159+ NavigationStack {
160+ Text ( " Results for \( query) " )
161+ . searchable ( text: $query, prompt: " Find " )
162+ }
163+ }
164+ }
165+ let host = ViewHost ( Screen ( ) )
166+ let node = host. evaluate ( )
167+ #expect( node. type == " NavStack " )
168+ guard case . array( let searches) ? = node. props [ " searches " ] ,
169+ case . array( let entry) = searches [ 0 ] , entry. count == 3 else {
170+ Issue . record ( " expected a search descriptor for the root screen " ) ; return
171+ }
172+ #expect( entry [ 0 ] == . string( " " ) ) // current text
173+ #expect( entry [ 2 ] == . string( " Find " ) ) // prompt
174+ guard case . int( let id) = entry [ 1 ] else {
175+ Issue . record ( " missing search callback id " ) ; return
176+ }
177+ host. callbacks. invokeString ( Int64 ( id) , " abc " )
178+ let updated = host. evaluate ( )
179+ guard case . array( let searches2) ? = updated. props [ " searches " ] ,
180+ case . array( let entry2) = searches2 [ 0 ] else {
181+ Issue . record ( " missing search descriptor after input " ) ; return
182+ }
183+ #expect( entry2 [ 0 ] == . string( " abc " ) ) // binding round-tripped
184+ }
185+
154186 @Test ( " TabView emits tabs with their item labels and selection " )
155187 func tabs( ) {
156188 struct Screen : View {
0 commit comments