diff --git a/e2e/image-input.spec.ts b/e2e/image-input.spec.ts index fa6b531a..e14e6eae 100644 --- a/e2e/image-input.spec.ts +++ b/e2e/image-input.spec.ts @@ -5,7 +5,7 @@ import type { Page, TestInfo } from '@playwright/test'; import { test } from './support/fixtures'; import type { Scenario } from './support/fixtures'; -const fixture = (name: string) => resolve('e2e/fixtures', name); +const fixture = (name: string) => resolve('src/__tests__/fixtures/images', name); /** 生成灰度 PNG(每行一种灰度),用于构造「文件很小但像素很多」的图片 */ function grayPng(width: number, height: number): Buffer { diff --git a/e2e/import-task-recovery.spec.ts b/e2e/import-task-recovery.spec.ts index a7e820bc..67615c1a 100644 --- a/e2e/import-task-recovery.spec.ts +++ b/e2e/import-task-recovery.spec.ts @@ -9,7 +9,7 @@ async function upload(page: Page, scenario: Scenario, path = '/') { await scenario.control({ hold: true }); await scenario.login(page); await page.goto(path); - await page.locator('input[type="file"]').first().setInputFiles(resolve('e2e/fixtures/math_test.png')); + await page.locator('input[type="file"]').first().setInputFiles(resolve('src/__tests__/fixtures/images/math_test.png')); await expect(page.getByRole('heading', { name: /裁剪|Crop/ })).toBeVisible(); await page.getByRole('button', { name: /确认|Confirm/ }).click(); await expect.poll(async () => (await scenario.model()).calls.filter((call) => call.operation === 'analysis').length).toBe(1); @@ -123,7 +123,7 @@ test('[E2E-T04] 框选 5 题先全部落库,模型排队时关闭页面后仍 await scenario.control({ hold: true }); await scenario.login(page); await page.goto(`/notebooks/${scenario.book.id}/add`); - await page.locator('input[type="file"]').first().setInputFiles(resolve('e2e/fixtures/math_test.png')); + await page.locator('input[type="file"]').first().setInputFiles(resolve('src/__tests__/fixtures/images/math_test.png')); await page.getByRole('button', { name: '手工框选' }).click(); const overlay = page.locator('.cursor-crosshair').first(); await expect(overlay).toBeVisible(); diff --git a/e2e/multi-question-photo.spec.ts b/e2e/multi-question-photo.spec.ts index bb2e7e86..5a5c6981 100644 --- a/e2e/multi-question-photo.spec.ts +++ b/e2e/multi-question-photo.spec.ts @@ -3,7 +3,7 @@ import { expect, test } from './support/fixtures'; import { batchOf, calls, expectNoHorizontalOverflow, expectNotCovered, saveShot } from './support/batch-flows'; import { viewports } from './support/flows'; -const PAGE_PHOTO = resolve('e2e/fixtures/multi-question-page.jpg'); +const PAGE_PHOTO = resolve('src/__tests__/fixtures/images/multi-question-page.jpg'); for (const profile of viewports) { test.describe(`照片 ${profile.name}`, () => { diff --git a/e2e/support/flows.ts b/e2e/support/flows.ts index 1b21c99c..51c49305 100644 --- a/e2e/support/flows.ts +++ b/e2e/support/flows.ts @@ -12,7 +12,7 @@ export async function importImage(page: Page, scenario: Scenario, confirm: boole await scenario.control({ hold: true }); await scenario.login(page); await page.goto(confirm ? '/' : `/?notebook=${scenario.book.id}`); - await page.locator('input[type="file"]').first().setInputFiles(resolve('e2e/fixtures/math_test.png')); + await page.locator('input[type="file"]').first().setInputFiles(resolve('src/__tests__/fixtures/images/math_test.png')); await expect(page.getByRole('heading', { name: /裁剪|Crop/ })).toBeVisible(); await page.getByRole('button', { name: /确认|Confirm/ }).click(); await expect.poll(async () => (await scenario.model()).calls.filter((call) => call.operation === 'analysis').length).toBe(1); diff --git a/e2e/support/mock-ai.mjs b/e2e/support/mock-ai.mjs index 6ade1e72..05374fd0 100644 --- a/e2e/support/mock-ai.mjs +++ b/e2e/support/mock-ai.mjs @@ -8,7 +8,7 @@ function json(response, status, value) { response.end(JSON.stringify(value)); } -/** 多题照片样例(e2e/fixtures/multi-question-page.jpg)中各题的位置,按 0~1000 归一化 */ +/** 多题照片样例(src/__tests__/fixtures/images/multi-question-page.jpg)中各题的位置,按 0~1000 归一化 */ export const PAGE_QUESTIONS = [ { label: '1', text: '如图,长方形 ABCD 的长和宽如图中所示,求它的面积是多少平方厘米?', regions: [{ x: 48, y: 197, w: 905, h: 350 }], hasFigure: true }, { label: '2', text: '下列分数中,与 3/4 相等的是(  )。A.6/8 B.4/6 C.9/16 D.5/7', regions: [{ x: 48, y: 590, w: 905, h: 105 }], hasFigure: false }, diff --git a/scripts/test-openclaw-integration.js b/scripts/test-openclaw-integration.js index a1b989ab..e5a577fc 100644 --- a/scripts/test-openclaw-integration.js +++ b/scripts/test-openclaw-integration.js @@ -107,7 +107,7 @@ echo "-----------------------------------------" echo "" # 准备测试图片 (base64) -TEST_IMAGE=$(base64 -i e2e/fixtures/math_test.png 2>/dev/null || echo "") +TEST_IMAGE=$(base64 -i src/__tests__/fixtures/images/math_test.png 2>/dev/null || echo "") if [ -z "$TEST_IMAGE" ]; then echo "使用内置测试图片..." # 创建一个简单的1x1像素PNG图片的base64 diff --git a/e2e/fixtures/corrupt.heic b/src/__tests__/fixtures/images/corrupt.heic similarity index 100% rename from e2e/fixtures/corrupt.heic rename to src/__tests__/fixtures/images/corrupt.heic diff --git a/e2e/fixtures/heic-named-as.jpg b/src/__tests__/fixtures/images/heic-named-as.jpg similarity index 100% rename from e2e/fixtures/heic-named-as.jpg rename to src/__tests__/fixtures/images/heic-named-as.jpg diff --git a/e2e/fixtures/math_test.heic b/src/__tests__/fixtures/images/math_test.heic similarity index 100% rename from e2e/fixtures/math_test.heic rename to src/__tests__/fixtures/images/math_test.heic diff --git a/e2e/fixtures/math_test.png b/src/__tests__/fixtures/images/math_test.png similarity index 100% rename from e2e/fixtures/math_test.png rename to src/__tests__/fixtures/images/math_test.png diff --git a/e2e/fixtures/multi-question-page.jpg b/src/__tests__/fixtures/images/multi-question-page.jpg similarity index 100% rename from e2e/fixtures/multi-question-page.jpg rename to src/__tests__/fixtures/images/multi-question-page.jpg diff --git a/e2e/fixtures/orientation-6.heic b/src/__tests__/fixtures/images/orientation-6.heic similarity index 100% rename from e2e/fixtures/orientation-6.heic rename to src/__tests__/fixtures/images/orientation-6.heic diff --git a/e2e/fixtures/orientation-6.jpg b/src/__tests__/fixtures/images/orientation-6.jpg similarity index 100% rename from e2e/fixtures/orientation-6.jpg rename to src/__tests__/fixtures/images/orientation-6.jpg diff --git a/src/__tests__/unit/image-pipeline.test.ts b/src/__tests__/unit/image-pipeline.test.ts index 24ad4368..d18c19c8 100644 --- a/src/__tests__/unit/image-pipeline.test.ts +++ b/src/__tests__/unit/image-pipeline.test.ts @@ -6,7 +6,7 @@ import { resolve } from 'node:path'; import { describe, expect, it } from 'vitest'; import { computeOutputSize, DEFAULT_IMAGE_LIMITS, sniffImageFormat } from '@/lib/image-pipeline'; -const fixture = (name: string) => new Uint8Array(readFileSync(resolve('e2e/fixtures', name))); +const fixture = (name: string) => new Uint8Array(readFileSync(resolve('src/__tests__/fixtures/images', name))); const brandFile = (major: string, ...compatible: string[]) => { const brands = [major, '\0\0\0\0', ...compatible].join(''); const size = 8 + brands.length; @@ -142,7 +142,7 @@ describe('renderRegion', () => { }); describe('prepareImage', () => { - const file = (name: string, type = '') => new File([readFileSync(resolve('e2e/fixtures', name))], name, { type }); + const file = (name: string, type = '') => new File([readFileSync(resolve('src/__tests__/fixtures/images', name))], name, { type }); it('系统可以解码时不加载 HEIC 解码库(如 Safari 解码 HEIC)', async () => { const createImageBitmap = vi.fn(async () => ({ width: 1024, height: 1024, close: vi.fn() }));