@@ -21,4 +21,44 @@ test.describe('modal: inline', () => {
2121
2222 expect ( await page . screenshot ( ) ) . toMatchSnapshot ( `modal-inline-dismiss-${ page . getSnapshotSettings ( ) } .png` ) ;
2323 } ) ;
24+
25+ test ( 'presenting should create a single root element with the ion-page class' , async ( { page, skip } , testInfo ) => {
26+ skip . mode ( 'md' ) ;
27+ skip . rtl ( ) ;
28+
29+ testInfo . annotations . push ( {
30+ type : 'issue' ,
31+ description : 'https://github.com/ionic-team/ionic-framework/issues/26117' ,
32+ } ) ;
33+
34+ await page . setContent ( `
35+ <ion-datetime-button datetime="datetime"></ion-datetime-button>
36+
37+ <ion-modal>
38+ <ion-datetime id="datetime" presentation="date-time"></ion-datetime>
39+ </ion-modal>
40+ ` ) ;
41+
42+ const ionModalDidPresent = await page . spyOnEvent ( 'ionModalDidPresent' ) ;
43+ const ionModalDidDismiss = await page . spyOnEvent ( 'ionModalDidDismiss' ) ;
44+ const modal = page . locator ( 'ion-modal' ) ;
45+
46+ await page . locator ( '#date-button' ) . click ( ) ;
47+ await ionModalDidPresent . next ( ) ;
48+
49+ // Verifies that the host element exists with the .ion-page class
50+ expect ( await modal . evaluate ( ( el : HTMLIonModalElement ) => el . firstElementChild ! . className ) ) . toContain ( 'ion-page' ) ;
51+
52+ await modal . evaluate ( ( el : HTMLIonModalElement ) => el . dismiss ( ) ) ;
53+ await ionModalDidDismiss . next ( ) ;
54+
55+ await page . locator ( '#date-button' ) . click ( ) ;
56+ await ionModalDidPresent . next ( ) ;
57+
58+ // Verifies that presenting the overlay again does not create a new host element
59+ expect ( await modal . evaluate ( ( el : HTMLIonModalElement ) => el . firstElementChild ! . className ) ) . toContain ( 'ion-page' ) ;
60+ expect (
61+ await modal . evaluate ( ( el : HTMLIonModalElement ) => el . firstElementChild ! . firstElementChild ! . className )
62+ ) . not . toContain ( 'ion-page' ) ;
63+ } ) ;
2464} ) ;
0 commit comments