@@ -23,11 +23,12 @@ module('Integration | Component | RoomMessage', function (hooks) {
23
23
isStreaming : boolean ,
24
24
timeAgoForCreated : number ,
25
25
timeAgoForUpdated : number ,
26
+ messageContent : string ,
26
27
) {
27
28
let message = {
28
29
author: { userId: ' @aibot:localhost' },
29
- message: ' Hello, ' ,
30
- formattedMessage: ' Hello, ' ,
30
+ message: messageContent ,
31
+ formattedMessage: messageContent ,
31
32
created: new Date (new Date ().getTime () - timeAgoForCreated * 60 * 1000 ),
32
33
updated: new Date (new Date ().getTime () - timeAgoForUpdated * 60 * 1000 ),
33
34
};
@@ -67,7 +68,7 @@ module('Integration | Component | RoomMessage', function (hooks) {
67
68
}
68
69
69
70
test (' it shows an error when AI bot message streaming timeouts' , async function (assert ) {
70
- let testScenario = await setupTestScenario (true , 2 , 1 ); // Streaming, created 2 mins ago, updated 1 min ago
71
+ let testScenario = await setupTestScenario (true , 2 , 1 , ' Hello, ' ); // Streaming, created 2 mins ago, updated 1 min ago
71
72
await renderRoomMessageComponent (testScenario );
72
73
73
74
await waitUntil (
@@ -85,7 +86,7 @@ module('Integration | Component | RoomMessage', function (hooks) {
85
86
});
86
87
87
88
test (' it does not show an error when last streaming chunk is still within reasonable time limit' , async function (assert ) {
88
- let testScenario = await setupTestScenario (true , 2 , 0.5 ); // Streaming, created 2 mins ago, updated 30 seconds ago
89
+ let testScenario = await setupTestScenario (true , 2 , 0.5 , ' Hello, ' ); // Streaming, created 2 mins ago, updated 30 seconds ago
89
90
await renderRoomMessageComponent (testScenario );
90
91
91
92
assert
@@ -96,4 +97,30 @@ module('Integration | Component | RoomMessage', function (hooks) {
96
97
.dom (' [data-test-ai-message-content] span.streaming-text' )
97
98
.includesText (' Hello,' );
98
99
});
100
+
101
+ test (' it escapes html code that is in code tags' , async function (assert ) {
102
+ let testScenario = await setupTestScenario (
103
+ true ,
104
+ 0 ,
105
+ 0 ,
106
+ `
107
+ \`\`\` typescript
108
+ <template >
109
+ <h1 >Hello, world!</h1 >
110
+ </template >
111
+ \`\`\`
112
+ ` ,
113
+ );
114
+ await renderRoomMessageComponent (testScenario );
115
+
116
+ let content = document .querySelector (
117
+ ' [data-test-ai-message-content]' ,
118
+ )?.innerHTML ;
119
+ assert .ok (
120
+ content ?.includes (` <template>
121
+ <h1>Hello, world!</h1>
122
+ </template> ` ),
123
+ ' rendered code snippet in a streaming message should contain escaped HTML template so that we see code, not rendered html' ,
124
+ );
125
+ });
99
126
});
0 commit comments