mirror of
https://github.com/web-infra-dev/midscene.git
synced 2025-07-29 03:44:08 +00:00
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describeUserPage } from '@/ai-model/prompt/util';
|
|
import { vlLocateMode } from '@/env';
|
|
import { getContextFromFixture } from 'tests/evaluation';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
describe('prompt utils', () => {
|
|
let lengthOfDescription: number;
|
|
it('describe context', async () => {
|
|
const context = await getContextFromFixture('taobao');
|
|
const { description } = await describeUserPage(context.context);
|
|
|
|
lengthOfDescription = description.length;
|
|
const stringLengthOfEachItem =
|
|
lengthOfDescription / context.context.content.length;
|
|
expect(description).toBeTruthy();
|
|
expect(stringLengthOfEachItem).toBeLessThan(250);
|
|
});
|
|
|
|
it('describe context, length = 100, filterNonTextContent = true', async () => {
|
|
const context = await getContextFromFixture('taobao');
|
|
|
|
const { description } = await describeUserPage(context.context, {
|
|
truncateTextLength: 100,
|
|
filterNonTextContent: true,
|
|
});
|
|
|
|
const stringLengthOfEachItem =
|
|
description.length / context.context.content.length;
|
|
expect(description).toBeTruthy();
|
|
expect(stringLengthOfEachItem).toBeLessThan(160);
|
|
|
|
if (!vlLocateMode()) {
|
|
expect(description.length).toBeLessThan(lengthOfDescription * 0.8);
|
|
}
|
|
});
|
|
});
|