mirror of
https://github.com/web-infra-dev/midscene.git
synced 2025-12-17 10:09:49 +00:00
* fix(web): fix sharp deps * chore: optimize sharp deps * refactor(extract): migrate sharp to jimp * refactor: migrate img common logic to shared lib * chore: merge main branch * chore: merge main branch * chore: merge main branch * chore: delete unless code * chore: optimize code * chore: optimize ai test branch trigger method * chore: optimize ai test branch trigger method * chore: optimize trigger method
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import path, { join } from 'node:path';
|
|
import { parseContextFromWebPage } from '@/common/utils';
|
|
import { generateExtractData } from '@/debug';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { launchPage } from '../ai/puppeteer/utils';
|
|
|
|
const pagePath = join(__dirname, './fixtures/extractor/index.html');
|
|
describe(
|
|
'extractor',
|
|
() => {
|
|
it('basic', async () => {
|
|
const { page, reset } = await launchPage(`file://${pagePath}`);
|
|
|
|
const { content } = await parseContextFromWebPage(page);
|
|
await generateExtractData(
|
|
page,
|
|
path.join(__dirname, 'fixtures/extractor'),
|
|
{
|
|
disableInputImage: false,
|
|
disableOutputImage: false,
|
|
disableOutputWithoutTextImg: true,
|
|
disableResizeOutputImg: true,
|
|
disableSnapshot: true,
|
|
},
|
|
);
|
|
|
|
const list = content.map((item) => {
|
|
return {
|
|
content: item.content,
|
|
attributes: item.attributes,
|
|
};
|
|
});
|
|
|
|
expect(list).toMatchSnapshot();
|
|
await reset();
|
|
});
|
|
|
|
it('profile ', async () => {
|
|
const { page, reset } = await launchPage('https://webinfra.org/about');
|
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
console.time('total - parseContextFromWebPage');
|
|
const { content } = await parseContextFromWebPage(page);
|
|
console.timeEnd('total - parseContextFromWebPage');
|
|
await reset();
|
|
});
|
|
},
|
|
{
|
|
timeout: 90 * 1000,
|
|
},
|
|
);
|