2025-03-17 19:19:54 +08:00
|
|
|
import { AiLocateElement } from '@/ai-model';
|
|
|
|
import { AiLocateSection } from '@/ai-model/inspect';
|
2025-03-24 09:50:27 +08:00
|
|
|
import { saveBase64Image } from '@/image';
|
|
|
|
import { getTmpFile } from '@/utils';
|
2025-04-24 22:54:52 +08:00
|
|
|
import { vlLocateMode } from '@midscene/shared/env';
|
2025-03-17 19:19:54 +08:00
|
|
|
import { getContextFromFixture } from 'tests/evaluation';
|
|
|
|
import { expect, test } from 'vitest';
|
|
|
|
|
2025-04-03 10:51:50 +08:00
|
|
|
test.skipIf(!vlLocateMode())(
|
2025-03-17 19:19:54 +08:00
|
|
|
'locate section',
|
|
|
|
async () => {
|
|
|
|
const { context } = await getContextFromFixture('antd-tooltip');
|
2025-03-24 09:50:27 +08:00
|
|
|
const { rect, imageBase64 } = await AiLocateSection({
|
2025-03-17 19:19:54 +08:00
|
|
|
context,
|
|
|
|
sectionDescription: 'the version info on the top right corner',
|
|
|
|
});
|
2025-03-24 09:50:27 +08:00
|
|
|
expect(rect).toBeDefined();
|
|
|
|
expect(imageBase64).toBeDefined();
|
|
|
|
|
|
|
|
const tmpFile = getTmpFile('jpg');
|
|
|
|
await saveBase64Image({
|
|
|
|
base64Data: imageBase64!,
|
|
|
|
outputPath: tmpFile!,
|
|
|
|
});
|
2025-03-17 19:19:54 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
timeout: 60 * 1000,
|
|
|
|
},
|
|
|
|
);
|