@@ -225,6 +225,88 @@ describe('Chat', () => {
225225 ) ;
226226 } ) ;
227227
228+ it ( 'should apply `speakPlaceholder` while recording' , async ( ) => {
229+ chat . options = {
230+ inputPlaceholder : 'Type message here...' ,
231+ speakPlaceholder : 'Listening...' ,
232+ speechToText : { enable : true , serviceProvider : 'webspeech' } ,
233+ } ;
234+ await elementUpdated ( chat ) ;
235+
236+ const { input } = getChatDOM ( chat ) ;
237+ expect ( input . textarea . placeholder ) . to . equal (
238+ chat . options . inputPlaceholder
239+ ) ;
240+
241+ Reflect . set ( input . self , 'isRecording' , true ) ;
242+ input . self . requestUpdate ( ) ;
243+ await elementUpdated ( input . self ) ;
244+
245+ expect ( input . textarea . placeholder ) . to . equal (
246+ chat . options . speakPlaceholder
247+ ) ;
248+ } ) ;
249+
250+ it ( 'should fallback to `inputPlaceholder` while recording if `speakPlaceholder` is not set' , async ( ) => {
251+ chat . options = {
252+ inputPlaceholder : 'Type message here...' ,
253+ speechToText : { enable : true , serviceProvider : 'webspeech' } ,
254+ } ;
255+ await elementUpdated ( chat ) ;
256+
257+ const { input } = getChatDOM ( chat ) ;
258+ Reflect . set ( input . self , 'isRecording' , true ) ;
259+ input . self . requestUpdate ( ) ;
260+ await elementUpdated ( input . self ) ;
261+
262+ expect ( input . textarea . placeholder ) . to . equal (
263+ chat . options . inputPlaceholder
264+ ) ;
265+ } ) ;
266+
267+ it ( 'should render the speech-to-text button only when enabled' , async ( ) => {
268+ chat . options = {
269+ speechToText : { enable : true , serviceProvider : 'webspeech' } ,
270+ } ;
271+ await elementUpdated ( chat ) ;
272+
273+ let speechToTextButton = getChatDOM (
274+ chat
275+ ) . input . self . renderRoot . querySelector (
276+ 'igc-icon-button[part="speech-to-text"]'
277+ ) ;
278+ expect ( speechToTextButton ) . not . to . be . null ;
279+
280+ chat . options = {
281+ speechToText : { enable : false , serviceProvider : 'webspeech' } ,
282+ } ;
283+ await elementUpdated ( chat ) ;
284+
285+ speechToTextButton = getChatDOM ( chat ) . input . self . renderRoot . querySelector (
286+ 'igc-icon-button[part="speech-to-text"]'
287+ ) ;
288+ expect ( speechToTextButton ) . to . be . null ;
289+ } ) ;
290+
291+ it ( 'should pass an accessibility audit with speech-to-text enabled and disabled' , async ( ) => {
292+ chat . options = {
293+ inputPlaceholder : 'Type message here...' ,
294+ speakPlaceholder : 'Listening...' ,
295+ speechToText : { enable : true , serviceProvider : 'webspeech' } ,
296+ } ;
297+ await elementUpdated ( chat ) ;
298+ await expect ( chat ) . to . be . accessible ( ) ;
299+ await expect ( chat ) . shadowDom . to . be . accessible ( ) ;
300+
301+ chat . options = {
302+ inputPlaceholder : 'Type message here...' ,
303+ speechToText : { enable : false , serviceProvider : 'webspeech' } ,
304+ } ;
305+ await elementUpdated ( chat ) ;
306+ await expect ( chat ) . to . be . accessible ( ) ;
307+ await expect ( chat ) . shadowDom . to . be . accessible ( ) ;
308+ } ) ;
309+
228310 it ( 'should enable/disable the send button properly' , async ( ) => {
229311 const { textarea, sendButton, fileInput } = getChatDOM ( chat ) . input ;
230312
0 commit comments