@@ -160,6 +160,8 @@ describe('Chat', () => {
160160 new File ( [ 'image data' ] , 'image.png' , { type : 'image/png' } ) ,
161161 ] ;
162162
163+ const GAP = 40 ; // Default gap between elements in the chat container
164+
163165 let chat : IgcChatComponent ;
164166 let clock : SinonFakeTimers ;
165167
@@ -181,7 +183,7 @@ describe('Chat', () => {
181183
182184 it ( 'is rendered correctly' , ( ) => {
183185 expect ( chat ) . dom . to . equal (
184- `<igc-chat>
186+ `<igc-chat>
185187 </igc-chat>`
186188 ) ;
187189
@@ -414,39 +416,6 @@ describe('Chat', () => {
414416 expect ( textArea ?. placeholder ) . to . equal ( 'Type message here...' ) ;
415417 } ) ;
416418
417- it ( 'should render suggestions' , async ( ) => {
418- chat . options = {
419- suggestions : [ 'Suggestion 1' , 'Suggestion 2' ] ,
420- } ;
421- await elementUpdated ( chat ) ;
422-
423- const suggestionsContainer = chat . shadowRoot ?. querySelector (
424- 'div[part="suggestions-container"]'
425- ) ;
426-
427- expect ( suggestionsContainer ) . dom . to . equal (
428- `<div aria-label="Suggestions" part="suggestions-container" role="list">
429- <slot name="suggestions-header" part="suggestions-header"> </slot>
430- <slot name="suggestions" part="suggestions">
431- <slot name="suggestion" part="suggestion" role="listitem">
432- <igc-chip>
433- <span>
434- Suggestion 1
435- </span>
436- </igc-chip>
437- </slot>
438- <slot name="suggestion" part="suggestion" role="listitem">
439- <igc-chip>
440- <span>
441- Suggestion 2
442- </span>
443- </igc-chip>
444- </slot>
445- </slot>
446- </div>`
447- ) ;
448- } ) ;
449-
450419 it ( 'should enable/disable the send button properly' , async ( ) => {
451420 const inputArea = chat . shadowRoot ?. querySelector ( 'igc-chat-input' ) ;
452421 const sendButton =
@@ -683,7 +652,15 @@ describe('Chat', () => {
683652 } ) ;
684653 } ) ;
685654
686- it ( 'should render suggestions' , async ( ) => {
655+ it ( 'should not render container if suggestions are not provided' , async ( ) => {
656+ const suggestionsContainer = chat . shadowRoot ?. querySelector (
657+ `div[part='suggestions-container']`
658+ ) ;
659+
660+ expect ( suggestionsContainer ) . to . be . null ;
661+ } ) ;
662+
663+ it ( 'should render suggestions if provided' , async ( ) => {
687664 chat . options = {
688665 suggestions : [ 'Suggestion 1' , 'Suggestion 2' ] ,
689666 } ;
@@ -712,10 +689,69 @@ describe('Chat', () => {
712689 </igc-chip>
713690 </slot>
714691 </slot>
692+ <slot name="suggestions-actions" part="suggestions-actions"> </slot>
715693 </div>`
716694 ) ;
717695 } ) ;
718696
697+ it ( 'should render suggestions below empty state by default' , async ( ) => {
698+ chat . options = {
699+ suggestions : [ 'Suggestion 1' , 'Suggestion 2' ] ,
700+ } ;
701+ await elementUpdated ( chat ) ;
702+ const suggestionsContainer = chat . shadowRoot ?. querySelector (
703+ `div[part='suggestions-container']`
704+ ) ;
705+
706+ expect ( suggestionsContainer ?. previousElementSibling ?. part [ 0 ] ) . to . equal (
707+ 'empty-state'
708+ ) ;
709+ } ) ;
710+
711+ it ( 'should render suggestions below messages by default' , async ( ) => {
712+ chat . options = {
713+ suggestions : [ 'Suggestion 1' , 'Suggestion 2' ] ,
714+ } ;
715+ chat . messages . push ( {
716+ id : '5' ,
717+ text : 'New message' ,
718+ sender : 'user' ,
719+ timestamp : new Date ( ) ,
720+ } ) ;
721+ await elementUpdated ( chat ) ;
722+
723+ const suggestionsContainer = chat . shadowRoot ?. querySelector (
724+ `div[part='suggestions-container']`
725+ ) ! ;
726+
727+ const messageList = chat . shadowRoot ?. querySelector (
728+ 'igc-chat-message-list'
729+ ) ! ;
730+
731+ const diff =
732+ suggestionsContainer . getBoundingClientRect ( ) . top -
733+ messageList . getBoundingClientRect ( ) . bottom ;
734+ expect ( diff ) . to . equal ( GAP ) ;
735+ } ) ;
736+
737+ it ( "should render suggestions below input area when position is 'below-input'" , async ( ) => {
738+ chat . options = {
739+ suggestions : [ 'Suggestion 1' , 'Suggestion 2' ] ,
740+ suggestionsPosition : 'below-input' ,
741+ } ;
742+ await elementUpdated ( chat ) ;
743+
744+ const suggestionsContainer = chat . shadowRoot ?. querySelector (
745+ `div[part='suggestions-container']`
746+ ) ! ;
747+
748+ const inputArea = chat . shadowRoot ?. querySelector ( 'igc-chat-input' ) ! ;
749+ const diff =
750+ suggestionsContainer . getBoundingClientRect ( ) . top -
751+ inputArea . getBoundingClientRect ( ) . bottom ;
752+ expect ( diff ) . to . equal ( GAP ) ;
753+ } ) ;
754+
719755 it ( 'should render composing indicator if `isComposing` is true' , async ( ) => {
720756 chat . messages = [ messages [ 0 ] ] ;
721757 chat . options = {
0 commit comments