2025-03-25 10:04:03 +08:00
|
|
|
import { vlLocateMode } from '@/env';
|
2025-03-24 09:50:27 +08:00
|
|
|
import Insight from '@/insight';
|
|
|
|
import { sleep } from '@/utils';
|
|
|
|
import { getContextFromFixture } from 'tests/evaluation';
|
2025-03-25 10:04:03 +08:00
|
|
|
import { describe, expect, test, vi } from 'vitest';
|
2025-03-24 09:50:27 +08:00
|
|
|
|
|
|
|
vi.setConfig({
|
|
|
|
testTimeout: 60 * 1000,
|
|
|
|
});
|
|
|
|
|
2025-03-25 10:04:03 +08:00
|
|
|
const vlMode = vlLocateMode();
|
2025-03-24 09:50:27 +08:00
|
|
|
|
2025-03-25 10:04:03 +08:00
|
|
|
describe.skipIf(!vlMode)('insight locate with search area', () => {
|
|
|
|
test('insight locate with search area', async () => {
|
|
|
|
const { context } = await getContextFromFixture('taobao');
|
2025-03-24 09:50:27 +08:00
|
|
|
|
2025-03-25 10:04:03 +08:00
|
|
|
const insight = new Insight(context);
|
|
|
|
const { element } = await insight.locate({
|
|
|
|
prompt: '购物车 icon',
|
|
|
|
searchArea: '顶部购物车栏目',
|
|
|
|
});
|
|
|
|
expect(element).toBeDefined();
|
|
|
|
|
|
|
|
await sleep(3000);
|
|
|
|
});
|
2025-03-24 09:50:27 +08:00
|
|
|
|
2025-03-25 10:04:03 +08:00
|
|
|
test('insight locate with search area and think twice', async () => {
|
|
|
|
const { context } = await getContextFromFixture('taobao');
|
2025-03-24 09:50:27 +08:00
|
|
|
|
2025-03-25 10:04:03 +08:00
|
|
|
const insight = new Insight(context);
|
|
|
|
const { element } = await insight.locate({
|
|
|
|
prompt: '顶部购物车 icon',
|
|
|
|
deepThink: true,
|
|
|
|
});
|
|
|
|
expect(element).toBeDefined();
|
|
|
|
await sleep(3000);
|
2025-03-24 09:50:27 +08:00
|
|
|
});
|
|
|
|
});
|