Skip to content

Commit 27af099

Browse files
committed
fix(*): Fixed input actions template and tests.
1 parent 79acef9 commit 27af099

File tree

3 files changed

+43
-30
lines changed

3 files changed

+43
-30
lines changed

src/components/chat/chat-input.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ export default class IgcChatInputComponent extends LitElement {
204204
<div part="input-wrapper">
205205
${templates?.textInputTemplate(this._chatState?.inputValue ?? '')}
206206
</div>
207-
${templates?.textAreaActionsTemplate()}
207+
<div part="buttons-container">
208+
${templates?.textAreaActionsTemplate()}
209+
</div>
208210
</div>
209211
`;
210212
}

src/components/chat/chat-state.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,8 @@ export class ChatState {
198198
};
199199

200200
private renderDefaultActionsArea = () => {
201-
return html` <div part="buttons-container">
202-
${this.renderDefaultFileUploadButton()} ${this.renderDefaultSendButton()}
203-
</div>`;
201+
return html` ${this.renderDefaultFileUploadButton()}
202+
${this.renderDefaultSendButton()}`;
204203
};
205204
/**
206205
* Default typing indicator template used when no custom template is provided.

src/components/chat/chat.spec.ts

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,24 @@ describe('Chat', () => {
695695
<div part="attachment">
696696
<div part="attachment-header" role="button">
697697
<div part="details">
698+
<igc-icon
699+
collection="material"
700+
name="file"
701+
part="attachment-icon"
702+
>
703+
</igc-icon>
698704
<span part="file-name">
699705
img2.png
700706
</span>
701707
</div>
702708
</div>
709+
<div part="attachment-content">
710+
<img
711+
alt="img2.png"
712+
part="file-attachment"
713+
src="http://localhost:8000/src/components/chat/assets/file.png"
714+
>
715+
</div>
703716
</div>
704717
</div>`
705718
);
@@ -731,10 +744,7 @@ describe('Chat', () => {
731744
aria-label="Suggestions"
732745
role="list"
733746
>
734-
<igc-list-header
735-
hidden=""
736-
part="suggestions-header"
737-
>
747+
<igc-list-header part="suggestions-header">
738748
<span>
739749
Suggestions
740750
</span>
@@ -751,13 +761,16 @@ describe('Chat', () => {
751761
role="listitem"
752762
>
753763
<igc-list-item>
754-
<igc-icon
755-
collection="material"
756-
name="star-icon"
757-
slot="start"
758-
>
759-
</igc-icon>
760-
<span>Suggestion 1</span>
764+
<span slot="start">
765+
<igc-icon
766+
collection="material"
767+
name="star-icon"
768+
>
769+
</igc-icon>
770+
</span>
771+
<span slot="title">
772+
Suggestion 1
773+
</span>
761774
</igc-list-item>
762775
</slot>
763776
<slot
@@ -766,13 +779,16 @@ describe('Chat', () => {
766779
role="listitem"
767780
>
768781
<igc-list-item>
769-
<igc-icon
770-
collection="material"
771-
name="star-icon"
772-
slot="start"
773-
>
774-
</igc-icon>
775-
<span>Suggestion 2</span>
782+
<span slot="start">
783+
<igc-icon
784+
collection="material"
785+
name="star-icon"
786+
>
787+
</igc-icon>
788+
</span>
789+
<span slot="title">
790+
Suggestion 2
791+
</span>
776792
</igc-list-item>
777793
</slot>
778794
</slot>
@@ -945,12 +961,11 @@ describe('Chat', () => {
945961
},
946962
};
947963
await elementUpdated(chat);
948-
await clock.tickAsync(500);
964+
await aTimeout(500);
949965

950966
const messageElements = chat.shadowRoot
951967
?.querySelector('igc-chat-message-list')
952-
?.shadowRoot?.querySelector(`div[part='message-list']`)
953-
?.querySelectorAll('igc-chat-message');
968+
?.shadowRoot?.querySelectorAll('igc-chat-message');
954969
expect(messageElements).not.to.be.undefined;
955970
messageElements?.forEach((messageElement, index) => {
956971
const messsageContainer =
@@ -985,8 +1000,7 @@ describe('Chat', () => {
9851000
await aTimeout(500);
9861001
const messageElements = chat.shadowRoot
9871002
?.querySelector('igc-chat-message-list')
988-
?.shadowRoot?.querySelector(`div[part='message-list']`)
989-
?.querySelectorAll('igc-chat-message');
1003+
?.shadowRoot?.querySelectorAll('igc-chat-message');
9901004
expect(messageElements).not.to.be.undefined;
9911005
messageElements?.forEach((messageElement, index) => {
9921006
const messsageContainer =
@@ -998,8 +1012,6 @@ describe('Chat', () => {
9981012
<h5>${chat.messages[index].sender === 'user' ? 'You' : 'Bot'}: </h5>
9991013
<p>${(messsageContainer?.querySelector('p') as HTMLElement)?.innerText}</p>
10001014
</div>
1001-
<igc-message-attachments>
1002-
</igc-message-attachments>
10031015
${chat.messages[index].sender !== 'user' ? messageReactions : ''}
10041016
</div>`
10051017
);
@@ -1027,7 +1039,7 @@ describe('Chat', () => {
10271039
expect(messsageContainer).dom.to.equal(
10281040
`<div part="bubble">
10291041
<pre part="plain-text">
1030-
${messages[0].text}
1042+
${chat.messages[index].text}
10311043
</pre>
10321044
<igc-message-attachments>
10331045
</igc-message-attachments>

0 commit comments

Comments
 (0)