mirror of
https://github.com/margrop/wrong-notebook.git
synced 2026-12-02 02:29:34 +08:00
- 新增 ImportBatch 表(迁移只做加法),ImportTask 增加所属批次、题目标识与文字任务原文; 文字任务按「文字 AI 解题」相同的年级规则与候选知识点解析,题干保留用户确认的原文 - 批次接口:创建(幂等)、读取(整页图按需返回)、带版本号保存草稿、开始、重试、按识别结果批量入库、丢弃、已读; 开始时在一个事务内抢占草稿并建出全部任务,提交后才逐题计额度并在后台执行,失败整体回滚、批次仍可编辑 - 本地文字分题规则:按同一写法连续递增的题号分题,选项与小问留在原题,标题/姓名栏列为未计入内容, 公共材料只作用于所属题组;编号像小问时保守地按一道题,超出 60 题或 2 万字时不静默截断 - 四个提供商新增 splitQuestions:文字只返回行号范围、由原文拼回;图片随请求发送真实图片,区域按 0~1000 校验; JSON 截断、越界、重叠、空结果统一校验,模型不支持图片时给出明确错误 - 批次页:分题预览(选择、编辑、拆分、合并、移动、删除、撤销、原图区域)、统一进度与逐题结果,只重试失败的题; 识别任务列表把批次作为「一批 N 题」显示,逐题校对保存后回到本批 - 备份升级到第 6 版,导出未完成的批次及批次内任务,导入不调用 AI,旧版文件照常导入
27 lines
1.3 KiB
TypeScript
27 lines
1.3 KiB
TypeScript
import { expect } from './fixtures';
|
|
import type { Page, Scenario } from './fixtures';
|
|
|
|
/** 页面不出现横向滚动 */
|
|
export async function expectNoHorizontalOverflow(page: Page) {
|
|
const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
|
|
expect(overflow).toBeLessThanOrEqual(1);
|
|
}
|
|
|
|
/** 元素中心没有被底部导航、悬浮按钮等遮挡 */
|
|
export async function expectNotCovered(page: Page, testId: string) {
|
|
const covered = await page.getByTestId(testId).evaluate((element) => {
|
|
const box = element.getBoundingClientRect();
|
|
const hit = document.elementFromPoint(box.left + box.width / 2, box.top + box.height / 2);
|
|
return !hit || !(element === hit || element.contains(hit));
|
|
});
|
|
expect(covered).toBe(false);
|
|
}
|
|
|
|
export async function saveShot(page: Page, name: string, testInfo: { outputPath: (name: string) => string }) {
|
|
await page.screenshot({ path: testInfo.outputPath(`${name}.png`), fullPage: true });
|
|
}
|
|
|
|
export const batchOf = (scenario: Scenario) => scenario.db.importBatch.findFirstOrThrow({ where: { userId: scenario.user.id }, include: { tasks: true } });
|
|
export const calls = async (scenario: Scenario, operation: string) => (await scenario.model()).calls.filter((call) => call.operation === operation);
|
|
|