Skip to content

Commit f4db521

Browse files
committed
Update tests to match function call -> tool call API change
1 parent 206facb commit f4db521

File tree

1 file changed

+50
-43
lines changed

1 file changed

+50
-43
lines changed

packages/matrix/tests/messages.spec.ts

+50-43
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ test.describe('Room messages', () => {
251251
expect(serializeCard.data.attributes.picture).toBeUndefined();
252252
});
253253

254-
test(`it does include patch function in message event when top-most card is writable and context is shared`, async ({
254+
test(`it does include patch tool in message event when top-most card is writable and context is shared`, async ({
255255
page,
256256
}) => {
257257
await login(page, 'user1', 'pass');
@@ -268,49 +268,52 @@ test.describe('Room messages', () => {
268268
let message = (await getRoomEvents()).pop()!;
269269
expect(message.content.msgtype).toStrictEqual('org.boxel.message');
270270
let boxelMessageData = JSON.parse(message.content.data);
271-
expect(boxelMessageData.context.functions).toMatchObject([
271+
expect(boxelMessageData.context.tools).toMatchObject([
272272
{
273-
name: 'patchCard',
274-
description:
275-
'Propose a patch to an existing card to change its contents. Any attributes specified will be fully replaced, return the minimum required to make the change. Ensure the description explains what change you are making',
276-
parameters: {
277-
type: 'object',
278-
properties: {
279-
description: {
280-
type: 'string',
281-
},
282-
card_id: {
283-
type: 'string',
284-
const: `${testHost}/mango`,
285-
},
286-
attributes: {
287-
type: 'object',
288-
properties: {
289-
firstName: {
290-
type: 'string',
291-
},
292-
lastName: {
293-
type: 'string',
294-
},
295-
email: {
296-
type: 'string',
297-
},
298-
posts: {
299-
type: 'number',
300-
},
301-
thumbnailURL: {
302-
type: 'string',
273+
type: 'function',
274+
function: {
275+
name: 'patchCard',
276+
description:
277+
'Propose a patch to an existing card to change its contents. Any attributes specified will be fully replaced, return the minimum required to make the change. Ensure the description explains what change you are making',
278+
parameters: {
279+
type: 'object',
280+
properties: {
281+
description: {
282+
type: 'string',
283+
},
284+
card_id: {
285+
type: 'string',
286+
const: `${testHost}/mango`,
287+
},
288+
attributes: {
289+
type: 'object',
290+
properties: {
291+
firstName: {
292+
type: 'string',
293+
},
294+
lastName: {
295+
type: 'string',
296+
},
297+
email: {
298+
type: 'string',
299+
},
300+
posts: {
301+
type: 'number',
302+
},
303+
thumbnailURL: {
304+
type: 'string',
305+
},
303306
},
304307
},
305308
},
309+
required: ['card_id', 'attributes', 'description'],
306310
},
307-
required: ['card_id', 'attributes', 'description'],
308311
},
309312
},
310313
]);
311314
});
312315

313-
test(`it does not include patch function in message event for an open card that is not attached`, async ({
316+
test(`it does not include patch tool in message event for an open card that is not attached`, async ({
314317
page,
315318
}) => {
316319
await login(page, 'user1', 'pass');
@@ -332,10 +335,10 @@ test.describe('Room messages', () => {
332335
let message = (await getRoomEvents()).pop()!;
333336
expect(message.content.msgtype).toStrictEqual('org.boxel.message');
334337
let boxelMessageData = JSON.parse(message.content.data);
335-
expect(boxelMessageData.context.functions).toMatchObject([]);
338+
expect(boxelMessageData.context.tools).toMatchObject([]);
336339
});
337340

338-
test(`it does not include patch function in message event when top-most card is read-only`, async ({
341+
test(`it does not include patch tool in message event when top-most card is read-only`, async ({
339342
page,
340343
}) => {
341344
// the base realm is a read-only realm
@@ -355,7 +358,7 @@ test.describe('Room messages', () => {
355358
let message = (await getRoomEvents()).pop()!;
356359
expect(message.content.msgtype).toStrictEqual('org.boxel.message');
357360
let boxelMessageData = JSON.parse(message.content.data);
358-
expect(boxelMessageData.context.functions).toMatchObject([]);
361+
expect(boxelMessageData.context.tools).toMatchObject([]);
359362
});
360363

361364
test('can send only a card as a message', async ({ page }) => {
@@ -886,16 +889,20 @@ test.describe('Room messages', () => {
886889
.click();
887890
});
888891

889-
test('displays error message if message is too large', async ({
890-
page,
891-
}) => {
892+
test('displays error message if message is too large', async ({ page }) => {
892893
await login(page, 'user1', 'pass');
893894

894895
await page.locator('[data-test-message-field]').fill('a'.repeat(65000));
895896
await page.locator('[data-test-send-message-btn]').click();
896897

897-
await expect(page.locator('[data-test-ai-assistant-message]')).toHaveCount(1);
898-
await expect(page.locator('[data-test-card-error]')).toContainText('Message is too large');
899-
await expect(page.locator('[data-test-ai-bot-retry-button]')).toHaveCount(0);
898+
await expect(page.locator('[data-test-ai-assistant-message]')).toHaveCount(
899+
1,
900+
);
901+
await expect(page.locator('[data-test-card-error]')).toContainText(
902+
'Message is too large',
903+
);
904+
await expect(page.locator('[data-test-ai-bot-retry-button]')).toHaveCount(
905+
0,
906+
);
900907
});
901908
});

0 commit comments

Comments
 (0)