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-03-17 19:19:54 +08:00
|
|
|
import { getContextFromFixture } from 'tests/evaluation';
|
|
|
|
import { expect, test } from 'vitest';
|
|
|
|
|
|
|
|
test(
|
|
|
|
'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!,
|
|
|
|
});
|
|
|
|
console.log('tmpFile', tmpFile);
|
2025-03-17 19:19:54 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
timeout: 60 * 1000,
|
|
|
|
},
|
|
|
|
);
|