@@ -164,7 +164,7 @@ test.describe('#sendMessages', () => {
164164 ) ;
165165 } ) ;
166166
167- test ( 'should send with cell content' , async ( { page } ) => {
167+ test ( 'should send with code cell content' , async ( { page } ) => {
168168 const cellContent = 'a = 1\nprint(f"a={a}")' ;
169169 const chatPanel = await openChat ( page , FILENAME ) ;
170170 const messages = chatPanel . locator ( '.jp-chat-messages-container' ) ;
@@ -189,14 +189,56 @@ test.describe('#sendMessages', () => {
189189 await expect ( sendWithSelection ) . toBeEnabled ( ) ;
190190 await expect ( sendWithSelection ) . toContainText ( 'Code from 1 active cell' ) ;
191191 await sendWithSelection . click ( ) ;
192+ await expect ( messages ! . locator ( '.jp-chat-message' ) ) . toHaveCount ( 1 ) ;
193+
194+ // It seems that the markdown renderer adds a new line, but the '\n' inserter when
195+ // pressing Enter above is trimmed.
196+ const rendered = messages . locator (
197+ '.jp-chat-message .jp-chat-rendered-markdown'
198+ ) ;
199+ await expect ( rendered ) . toHaveText ( `${ MSG_CONTENT } \n${ cellContent } \n` ) ;
192200
201+ // Code should have python language class.
202+ await expect ( rendered . locator ( 'code' ) ) . toHaveClass ( 'language-python' ) ;
203+ } ) ;
204+
205+ test ( 'should send with markdown cell content' , async ( { page } ) => {
206+ const cellContent = 'markdown content' ;
207+ const chatPanel = await openChat ( page , FILENAME ) ;
208+ const messages = chatPanel . locator ( '.jp-chat-messages-container' ) ;
209+ const input = chatPanel
210+ . locator ( '.jp-chat-input-container' )
211+ . getByRole ( 'combobox' ) ;
212+ const openerButton = chatPanel . locator (
213+ '.jp-chat-input-container .jp-chat-send-include-opener'
214+ ) ;
215+ const sendWithSelection = page . locator ( '.jp-chat-send-include' ) ;
216+
217+ const notebook = await page . notebook . createNew ( ) ;
218+ // write content in the first cell after changing it to markdown.
219+ const cell = ( await page . notebook . getCellLocator ( 0 ) ) ! ;
220+ await page . notebook . setCellType ( 0 , 'markdown' ) ;
221+ await cell . getByRole ( 'textbox' ) . pressSequentially ( cellContent ) ;
222+
223+ await splitMainArea ( page , notebook ! ) ;
224+
225+ await input . pressSequentially ( MSG_CONTENT ) ;
226+ await openerButton . click ( ) ;
227+ await expect ( sendWithSelection ) . toBeVisible ( ) ;
228+ await expect ( sendWithSelection ) . toBeEnabled ( ) ;
229+ await expect ( sendWithSelection ) . toContainText ( 'Code from 1 active cell' ) ;
230+ await sendWithSelection . click ( ) ;
193231 await expect ( messages ! . locator ( '.jp-chat-message' ) ) . toHaveCount ( 1 ) ;
194232
195233 // It seems that the markdown renderer adds a new line, but the '\n' inserter when
196234 // pressing Enter above is trimmed.
197- await expect (
198- messages . locator ( '.jp-chat-message .jp-chat-rendered-markdown' )
199- ) . toHaveText ( `${ MSG_CONTENT } \n${ cellContent } \n` ) ;
235+ const rendered = messages . locator (
236+ '.jp-chat-message .jp-chat-rendered-markdown'
237+ ) ;
238+ await expect ( rendered ) . toHaveText ( `${ MSG_CONTENT } \n${ cellContent } \n` ) ;
239+
240+ // Code should not have python language class since it come from a markdown cell.
241+ await expect ( rendered . locator ( 'code' ) ) . toHaveClass ( '' ) ;
200242 } ) ;
201243
202244 test ( 'should send with text selection' , async ( { page } ) => {
@@ -243,8 +285,12 @@ test.describe('#sendMessages', () => {
243285
244286 // It seems that the markdown renderer adds a new line, but the '\n' inserter when
245287 // pressing Enter above is trimmed.
246- await expect (
247- messages . locator ( '.jp-chat-message .jp-chat-rendered-markdown' )
248- ) . toHaveText ( `${ MSG_CONTENT } \nprint\n` ) ;
288+ const rendered = messages . locator (
289+ '.jp-chat-message .jp-chat-rendered-markdown'
290+ ) ;
291+ await expect ( rendered ) . toHaveText ( `${ MSG_CONTENT } \nprint\n` ) ;
292+
293+ // Code should have python or ipython language class.
294+ await expect ( rendered . locator ( 'code' ) ) . toHaveClass ( / l a n g u a g e - [ i ] ? p y t h o n / ) ;
249295 } ) ;
250296} ) ;
0 commit comments