Skip to content

Commit ef3e71f

Browse files
committed
fix tests: context message is now after user prompt
1 parent 55d420a commit ef3e71f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

extensions/positron-assistant/src/test/participants.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ suite('PositronAssistantParticipant', () => {
167167
const [messages,] = sendRequestSpy.getCall(0).args;
168168
const c = positronChatContext;
169169
assert.strictEqual(messages.length, DEFAULT_EXPECTED_MESSAGE_COUNT, `Unexpected messages: ${JSON.stringify(messages)}`);
170-
assertContextMessage(messages[0],
170+
assertContextMessage(messages.at(-1)!,
171171
`<context>
172172
<session description="Current active session" language="${c.activeSession!.language}" version="${c.activeSession!.version}" mode="console" identifier="${c.activeSession!.identifier}">
173173
<executions>
@@ -224,7 +224,7 @@ Today's date is: Wednesday 11 June 2025 at 13:30:00 BST
224224
const filePath = vscode.workspace.asRelativePath(fileReferenceUri);
225225
const attachmentsText = await readFile(path.join(MARKDOWN_DIR, 'prompts', 'chat', 'attachments.md'), 'utf8');
226226
assert.strictEqual(messages.length, DEFAULT_EXPECTED_MESSAGE_COUNT, `Unexpected messages: ${JSON.stringify(messages)}`);
227-
assertContextMessage(messages[0],
227+
assertContextMessage(messages.at(-1)!,
228228
`<attachments>
229229
${attachmentsText}
230230
<attachment filePath="${filePath}" description="Full contents of the file" language="${document.languageId}">
@@ -255,7 +255,7 @@ ${document.getText()}
255255
const filePath = vscode.workspace.asRelativePath(folderReferenceUri);
256256
const attachmentsText = await readFile(path.join(MARKDOWN_DIR, 'prompts', 'chat', 'attachments.md'), 'utf8');
257257
assert.strictEqual(messages.length, DEFAULT_EXPECTED_MESSAGE_COUNT, `Unexpected messages: ${JSON.stringify(messages)}`);
258-
assertContextMessage(messages[0],
258+
assertContextMessage(messages.at(-1)!,
259259
`<attachments>
260260
${attachmentsText}
261261
<attachment filePath="${filePath}" description="Contents of the directory">
@@ -290,7 +290,7 @@ subfolder/
290290
const filePath = vscode.workspace.asRelativePath(fileReferenceUri);
291291
const attachmentsText = await readFile(path.join(MARKDOWN_DIR, 'prompts', 'chat', 'attachments.md'), 'utf8');
292292
assert.strictEqual(messages.length, DEFAULT_EXPECTED_MESSAGE_COUNT, `Unexpected messages: ${JSON.stringify(messages)}`);
293-
assertContextMessage(messages[0],
293+
assertContextMessage(messages.at(-1)!,
294294
`<attachments>
295295
${attachmentsText}
296296
<attachment filePath="${filePath}" description="Visible region of the active file" language="${document.languageId}" startLine="${range.start.line + 1}" endLine="${range.end.line + 1}">
@@ -326,7 +326,7 @@ ${document.getText()}
326326
const [messages,] = sendRequestSpy.getCall(0).args;
327327
const attachmentsText = await readFile(path.join(MARKDOWN_DIR, 'prompts', 'chat', 'attachments.md'), 'utf8');
328328
assert.strictEqual(messages.length, DEFAULT_EXPECTED_MESSAGE_COUNT, `Unexpected messages: ${JSON.stringify(messages)}`);
329-
assertContextMessage(messages[0],
329+
assertContextMessage(messages.at(-1)!,
330330
`<attachments>
331331
${attachmentsText}
332332
<img src="${reference.name}" />
@@ -357,7 +357,7 @@ It should be included in the chat message.`;
357357
sinon.assert.calledOnce(sendRequestSpy);
358358
const [messages,] = sendRequestSpy.getCall(0).args;
359359
assert.strictEqual(messages.length, DEFAULT_EXPECTED_MESSAGE_COUNT, `Unexpected messages: ${JSON.stringify(messages)}`);
360-
assertContextMessage(messages[0],
360+
assertContextMessage(messages.at(-1)!,
361361
`<instructions>
362362
${llmsTxtContent}
363363
</instructions>`);
@@ -386,7 +386,7 @@ ${llmsTxtContent}
386386
const [messages,] = sendRequestSpy.getCall(0).args;
387387
assert.strictEqual(messages.length, DEFAULT_EXPECTED_MESSAGE_COUNT, `Unexpected messages: ${JSON.stringify(messages)}`);
388388
const filePath = vscode.workspace.asRelativePath(fileReferenceUri);
389-
assertContextMessage(messages[0],
389+
assertContextMessage(messages.at(-1)!,
390390
`<editor description="Current active editor" filePath="${filePath}" language="${document.languageId}" line="${selection.active.line + 1}" column="${selection.active.character + 1}" documentOffset="${document.offsetAt(selection.active)}">
391391
<document description="Full contents of the active file">
392392
${document.getText()}

0 commit comments

Comments
 (0)