test: 适配原题图片地址校验与用户删除 404 的既有断言

- 判重历史与仅图片题目改用合法站内相对路径
- 管理员删除不存在用户按新行为断言 404

Refs: https://github.com/margrop/wrong-notebook/issues/187
Refs: https://github.com/margrop/wrong-notebook/issues/176
This commit is contained in:
margrop
2026-12-04 06:47:41 +08:00
parent 79691e4327
commit 3040bd451f
2 changed files with 4 additions and 4 deletions

View File

@@ -126,7 +126,7 @@ describe('删除用户后通知 AI 账户实现', () => {
expect(mocks.onUserDeleted).toHaveBeenCalledWith(alice.id);
mocks.onUserDeleted.mockClear();
expect((await remove('missing-user')).status).toBe(500);
expect((await remove('missing-user')).status).toBe(404);
expect(mocks.onUserDeleted).not.toHaveBeenCalled();
});

View File

@@ -255,10 +255,10 @@ describe('题目导入自动判重(真实 SQLite)', () => {
it('新错误快照可从举一反三历史读取', async () => {
await existing();
await save({ wrongAnswerText: '新作答', mistakeAnalysis: '新错因', originalImageUrl: 'new-image' });
await save({ wrongAnswerText: '新作答', mistakeAnalysis: '新错因', originalImageUrl: '/uploads/new-image.png' });
const response = await GET_HISTORY(new Request('http://localhost'), { params: Promise.resolve({ id: 'existing' }) });
expect(response.status).toBe(200);
expect((await response.json()).records[0]).toMatchObject({ result: 'wrong', source: 'duplicate_import', wrongAnswerText: '新作答', mistakeAnalysis: '新错因', originalImageUrl: 'new-image' });
expect((await response.json()).records[0]).toMatchObject({ result: 'wrong', source: 'duplicate_import', wrongAnswerText: '新作答', mistakeAnalysis: '新错因', originalImageUrl: '/uploads/new-image.png' });
});
it('恰好 90% 时仍创建新题', async () => {
@@ -292,7 +292,7 @@ describe('题目导入自动判重(真实 SQLite)', () => {
it('没有题干时不把只有图片的不同题目判为相同', async () => {
await existing({ questionText: null });
expect((await save({ questionText: '', originalImageUrl: 'image' })).status).toBe(201);
expect((await save({ questionText: '', originalImageUrl: '/uploads/image.png' })).status).toBe(201);
expect(await database.practiceRecord.count()).toBe(0);
});