@@ -68,6 +68,20 @@ async function installTalkBrowserFixtures(page: Page) {
6868 } ) ;
6969}
7070
71+ async function installBlockedMicrophoneFixture ( page : Page ) {
72+ await page . addInitScript ( ( ) => {
73+ Object . defineProperty ( navigator , "mediaDevices" , {
74+ configurable : true ,
75+ value : {
76+ enumerateDevices : async ( ) => [ ] ,
77+ getUserMedia : async ( ) => {
78+ throw new DOMException ( "Permission denied" , "NotAllowedError" ) ;
79+ } ,
80+ } ,
81+ } ) ;
82+ } ) ;
83+ }
84+
7185describeControlUiE2e ( "Control UI browser Talk" , ( ) => {
7286 beforeAll ( async ( ) => {
7387 server = await startControlUiE2eServer ( ) ;
@@ -104,23 +118,21 @@ describeControlUiE2e("Control UI browser Talk", () => {
104118 try {
105119 await page . goto ( `${ server . baseUrl } chat` ) ;
106120 await page . setViewportSize ( { width : 320 , height : 720 } ) ;
107- const microphoneTrigger = page . getByRole ( "button" , { name : "Microphone input" } ) ;
108- await microphoneTrigger . click ( ) ;
109- const microphoneMenu = page . getByRole ( "group" , { name : "Microphone input" } ) ;
110- const menuBounds = await microphoneMenu . boundingBox ( ) ;
111- expect ( menuBounds ) . not . toBeNull ( ) ;
112- expect ( menuBounds ?. x ?? 0 ) . toBeGreaterThanOrEqual ( 8 ) ;
113- expect ( ( menuBounds ?. x ?? 0 ) + ( menuBounds ?. width ?? 0 ) ) . toBeLessThanOrEqual ( 312 ) ;
114- await page . getByRole ( "button" , { name : "USB Audio Interface" } ) . click ( ) ;
115121 await expect
116- . poll ( ( ) => page . evaluate ( ( ) => document . activeElement ?. getAttribute ( "aria-label" ) ) )
117- . toBe ( "Microphone input" ) ;
118- await microphoneTrigger . click ( ) ;
119- await page . keyboard . press ( "Escape" ) ;
122+ . poll ( ( ) => page . getByRole ( "button" , { name : "Microphone input" } ) . count ( ) )
123+ . toBe ( 0 ) ;
124+ const settings = page . getByRole ( "button" , { name : "Chat settings" } ) ;
125+ await settings . click ( ) ;
126+ const settingsDialog = page . getByRole ( "dialog" , { name : "Chat settings" } ) ;
127+ const microphoneSelect = settingsDialog . locator ( '[data-talk-select="microphone"] select' ) ;
120128 await expect
121- . poll ( ( ) => page . evaluate ( ( ) => document . activeElement ?. getAttribute ( "aria-label" ) ) )
122- . toBe ( "Microphone input" ) ;
123- await expect . poll ( ( ) => microphoneMenu . count ( ) ) . toBe ( 0 ) ;
129+ . poll ( async ( ) =>
130+ ( await microphoneSelect . locator ( "option" ) . allTextContents ( ) ) . map ( ( label ) => label . trim ( ) ) ,
131+ )
132+ . toEqual ( [ "System default" , "Built-in Microphone" , "USB Audio Interface" ] ) ;
133+ await microphoneSelect . selectOption ( "usb" ) ;
134+ await settings . click ( ) ;
135+ await expect . poll ( ( ) => settingsDialog . isVisible ( ) ) . toBe ( false ) ;
124136 await page . getByRole ( "button" , { name : "Start voice input" } ) . click ( ) ;
125137
126138 const createRequest = await gateway . waitForRequest ( "talk.client.create" ) ;
@@ -184,4 +196,47 @@ describeControlUiE2e("Control UI browser Talk", () => {
184196 await browser . close ( ) ;
185197 }
186198 } ) ;
199+
200+ it ( "keeps blocked microphone guidance readable in a narrow viewport" , async ( ) => {
201+ const browser = await chromium . launch ( { executablePath : chromiumExecutablePath } ) ;
202+ const context = await browser . newContext ( ) ;
203+ const page = await context . newPage ( ) ;
204+ await installMockGateway ( page ) ;
205+ await installBlockedMicrophoneFixture ( page ) ;
206+
207+ try {
208+ await page . setViewportSize ( { width : 320 , height : 720 } ) ;
209+ await page . goto ( `${ server . baseUrl } chat` ) ;
210+ await page . getByRole ( "button" , { name : "Chat settings" } ) . click ( ) ;
211+
212+ const settingsDialog = page . getByRole ( "dialog" , { name : "Chat settings" } ) ;
213+ await settingsDialog . getByRole ( "button" , { name : "Refresh: Microphone input" } ) . click ( ) ;
214+ const permissionAlert = settingsDialog . getByRole ( "alert" ) ;
215+ await expect . poll ( ( ) => permissionAlert . isVisible ( ) ) . toBe ( true ) ;
216+
217+ const [ settingsBounds , alertBounds ] = await Promise . all ( [
218+ settingsDialog . boundingBox ( ) ,
219+ permissionAlert . boundingBox ( ) ,
220+ ] ) ;
221+ expect ( settingsBounds ) . not . toBeNull ( ) ;
222+ expect ( alertBounds ) . not . toBeNull ( ) ;
223+ expect ( settingsBounds ?. width ?? 0 ) . toBeGreaterThanOrEqual ( 280 ) ;
224+ expect ( settingsBounds ?. x ?? 0 ) . toBeGreaterThanOrEqual ( 8 ) ;
225+ expect ( ( settingsBounds ?. x ?? 0 ) + ( settingsBounds ?. width ?? 0 ) ) . toBeLessThanOrEqual ( 312 ) ;
226+ expect ( alertBounds ?. x ?? 0 ) . toBeGreaterThanOrEqual ( settingsBounds ?. x ?? 0 ) ;
227+ expect ( ( alertBounds ?. x ?? 0 ) + ( alertBounds ?. width ?? 0 ) ) . toBeLessThanOrEqual (
228+ ( settingsBounds ?. x ?? 0 ) + ( settingsBounds ?. width ?? 0 ) ,
229+ ) ;
230+ expect ( alertBounds ?. y ?? 0 ) . toBeGreaterThanOrEqual ( settingsBounds ?. y ?? 0 ) ;
231+ expect ( ( alertBounds ?. y ?? 0 ) + ( alertBounds ?. height ?? 0 ) ) . toBeLessThanOrEqual (
232+ ( settingsBounds ?. y ?? 0 ) + ( settingsBounds ?. height ?? 0 ) ,
233+ ) ;
234+ await expect
235+ . poll ( ( ) => permissionAlert . textContent ( ) )
236+ . toContain ( "Microphone access is blocked." ) ;
237+ } finally {
238+ await context . close ( ) ;
239+ await browser . close ( ) ;
240+ }
241+ } ) ;
187242} ) ;
0 commit comments