@@ -116,6 +116,41 @@ struct NavigationTests {
116116 #expect( node. children. contains { $0. type == " Sheet " } )
117117 }
118118
119+ @Test ( " Confirmation dialog presents its buttons and a chosen action dismisses it " )
120+ func confirmationDialog( ) {
121+ struct Screen : View {
122+ @State var shown = false
123+ @State var picked = " "
124+ var body : some View {
125+ Button ( " Show " ) { shown = true }
126+ . confirmationDialog ( " Manage " , isPresented: $shown, titleVisibility: . visible, buttons: [
127+ AlertButton ( " Duplicate " ) { picked = " dup " } ,
128+ AlertButton ( " Delete " , role: . destructive) { picked = " del " } ,
129+ ] )
130+ }
131+ }
132+ let host = ViewHost ( Screen ( ) )
133+ var node = host. evaluate ( )
134+ #expect( node. props [ " hasConfirmationDialog " ] == nil )
135+ host. callbacks. invokeVoid ( findOnTap ( node) !)
136+ node = host. evaluate ( )
137+ #expect( node. props [ " hasConfirmationDialog " ] == . bool( true ) )
138+ let dialog = node. children. first { $0. type == " ConfirmationDialog " }
139+ #expect( dialog? . props [ " showsTitle " ] == . bool( true ) )
140+ guard case . array( let buttons) ? = dialog? . props [ " buttons " ] , buttons. count == 2 else {
141+ Issue . record ( " expected two buttons " ) ; return
142+ }
143+ // second button (destructive) fires its action and dismisses the dialog
144+ guard case . array( let second) = buttons [ 1 ] , case . string( let role) = second [ 1 ] ,
145+ case . int( let id) = second [ 2 ] else {
146+ Issue . record ( " malformed button " ) ; return
147+ }
148+ #expect( role == " destructive " )
149+ host. callbacks. invokeVoid ( Int64 ( id) )
150+ node = host. evaluate ( )
151+ #expect( node. props [ " hasConfirmationDialog " ] == nil ) // dismissed
152+ }
153+
119154 @Test ( " TabView emits tabs with their item labels and selection " )
120155 func tabs( ) {
121156 struct Screen : View {
0 commit comments