11import type { PleasantestUtils } from 'pleasantest' ;
2- import { withBrowser , devices } from 'pleasantest' ;
2+ import {
3+ experimentalGetAccessibilityTree ,
4+ withBrowser ,
5+ devices ,
6+ } from 'pleasantest' ;
7+
38import { Liquid } from 'liquidjs' ;
49import * as path from 'path' ;
510const iPhone = devices [ 'iPhone 11' ] ;
@@ -75,23 +80,46 @@ test(
7580 await expect ( await screen . getByText ( aboutText ) ) . not . toBeVisible ( ) ;
7681
7782 // Before JS initializes the menus should be links
78- let aboutBtn = await screen . getByRole ( 'link' , { name : / a b o u t / i } ) ;
79- await expect ( aboutBtn ) . toHaveAttribute ( 'href' ) ;
80- await expect (
81- await screen . queryByRole ( 'button' , { name : / a b o u t / i } ) ,
82- ) . not . toBeInTheDocument ( ) ;
83+ expect (
84+ await experimentalGetAccessibilityTree (
85+ await screen . getByRole ( 'navigation' ) ,
86+ ) ,
87+ ) . toMatchInlineSnapshot ( `
88+ navigation
89+ heading "Company"
90+ link "Company"
91+ list
92+ listitem
93+ link "Products"
94+ listitem
95+ link "About"
96+ listitem
97+ link "Log In"
98+ ` ) ;
8399
84100 await utils . runJS ( `
85101 import { init } from '.'
86102 init()
87103 ` ) ;
88104
89- // The menus should be upgraded to buttons
90- aboutBtn = await screen . getByRole ( 'button' , { name : / a b o u t / i } ) ;
91- await expect (
92- await screen . queryByRole ( 'link' , { name : / a b o u t / i } ) ,
93- ) . not . toBeInTheDocument ( ) ;
94-
105+ // The menus should be upgraded to buttons,
106+ const aboutBtn = await screen . getByRole ( 'button' , { name : / a b o u t / i } ) ;
107+ expect (
108+ await experimentalGetAccessibilityTree (
109+ await screen . getByRole ( 'navigation' ) ,
110+ ) ,
111+ ) . toMatchInlineSnapshot ( `
112+ navigation
113+ heading "Company"
114+ link "Company"
115+ list
116+ listitem
117+ button "Products"
118+ listitem
119+ button "About"
120+ listitem
121+ link "Log In"
122+ ` ) ;
95123 // Login should still be a link, since it does not trigger a menu to open
96124 const loginBtn = await screen . getByRole ( 'link' , { name : / l o g i n / i } ) ;
97125 await expect ( loginBtn ) . toHaveAttribute ( 'href' ) ;
@@ -110,6 +138,7 @@ test(
110138 const productsBtn = await screen . getByRole ( 'button' , { name : / p r o d u c t s / i } ) ;
111139 // First click: opens about menu
112140 await user . click ( aboutBtn ) ;
141+
113142 await expect ( await screen . getByText ( aboutText ) ) . toBeVisible ( ) ;
114143 // Second click: closes about menu
115144 await user . click ( aboutBtn ) ;
0 commit comments