midscene/packages/core/tests/ai/extract/extract.test.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

import { AiExtractElementInfo } from '@/ai-model';
import { getContextFromFixture } from '@/evaluation';
import { describe, expect, it, vi } from 'vitest';
vi.setConfig({
testTimeout: 180 * 1000,
hookTimeout: 30 * 1000,
});
2025-01-03 21:50:25 +08:00
describe('extract', () => {
it('todo', async () => {
const { context } = await getContextFromFixture('todo-input-with-value');
2025-01-03 21:50:25 +08:00
const { parseResult } = await AiExtractElementInfo({
dataQuery: 'Array<string>, Complete task list, string is the task',
context,
});
2025-01-03 21:50:25 +08:00
expect(parseResult).toMatchSnapshot();
});
2025-01-03 21:50:25 +08:00
it('online order', async () => {
const { context } = await getContextFromFixture('online_order');
2025-01-03 21:50:25 +08:00
const { parseResult } = await AiExtractElementInfo({
dataQuery: '{name: string, price: string}[], 饮品名称和价格',
context,
});
2025-01-03 21:50:25 +08:00
expect(parseResult).toMatchSnapshot();
});
2025-01-03 21:50:25 +08:00
it('todo obj', async () => {
const { context } = await getContextFromFixture('todo-input-with-value');
2025-01-03 21:50:25 +08:00
const { parseResult } = await AiExtractElementInfo({
dataQuery:
'{checked: boolean; text: string}[], Complete task list, task name as string and `checked` is true if the task is completed',
2025-01-03 21:50:25 +08:00
context,
});
2025-01-03 21:50:25 +08:00
expect(parseResult).toMatchSnapshot();
});
});