mirror of
https://github.com/web-infra-dev/midscene.git
synced 2025-08-01 05:12:50 +00:00

* feat: enable search area for locate * fix: update evaluation * fix: build error * fix: ci * fix: locator * feat: show searchArea in report * chore: add yaml support for aiTap * feat: update status tip * fix: #473 (#484) * chore: optimize unit test list --------- Co-authored-by: zhouxiao.shaw <zhouxiao.shaw@bytedance.com>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { AiLocateElement, AiLocateSection } from '@/ai-model';
|
|
import { getContextFromFixture } from 'tests/evaluation';
|
|
import { expect, test } from 'vitest';
|
|
|
|
test(
|
|
'basic inspect',
|
|
async () => {
|
|
const { context } = await getContextFromFixture('todo');
|
|
|
|
const startTime = Date.now();
|
|
const { parseResult } = await AiLocateElement({
|
|
context,
|
|
targetElementDescription: 'input 输入框',
|
|
});
|
|
console.log('parseResult', JSON.stringify(parseResult, null, 2));
|
|
const endTime = Date.now();
|
|
const cost = endTime - startTime;
|
|
expect(parseResult.elements.length).toBe(1);
|
|
},
|
|
{
|
|
timeout: 1000000,
|
|
},
|
|
);
|
|
|
|
test('locate section', async () => {
|
|
const { context } = await getContextFromFixture('todo');
|
|
const { rect } = await AiLocateSection({
|
|
context,
|
|
sectionDescription: '搜索框',
|
|
});
|
|
expect(rect).toBeDefined();
|
|
});
|
|
|
|
test('use quick answer', async () => {
|
|
const { context } = await getContextFromFixture('todo');
|
|
|
|
const startTime = Date.now();
|
|
const { parseResult } = await AiLocateElement({
|
|
context,
|
|
targetElementDescription: 'never mind',
|
|
quickAnswer: {
|
|
id: context.content[0].id,
|
|
reason: 'never mind',
|
|
text: 'never mind',
|
|
},
|
|
});
|
|
console.log('parseResult', parseResult);
|
|
const endTime = Date.now();
|
|
const cost = endTime - startTime;
|
|
expect(parseResult.elements.length).toBe(1);
|
|
expect(cost).toBeLessThan(100);
|
|
});
|