From ac8dd8809cf790e95d7dd5a8691baa24ecbdbfe6 Mon Sep 17 00:00:00 2001 From: margrop <1731827+margrop@users.noreply.github.com> Date: Fri, 4 Dec 2026 00:25:27 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E8=A1=A5=E9=BD=90=E5=85=B1=E4=BA=AB?= =?UTF-8?q?=E6=9D=83=E9=99=90=E9=9B=86=E6=88=90=E6=96=AD=E8=A8=80=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 统计、复习、薄弱知识点与标签统计同步新可读条件 Refs: https://github.com/margrop/wrong-notebook/issues/167 --- src/__tests__/integration/analytics.test.ts | 3 ++- src/__tests__/integration/review.test.ts | 3 ++- src/__tests__/integration/tags.test.ts | 8 ++++---- src/__tests__/integration/weak-tags.test.ts | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/__tests__/integration/analytics.test.ts b/src/__tests__/integration/analytics.test.ts index 62fa7c3c..0559fa70 100644 --- a/src/__tests__/integration/analytics.test.ts +++ b/src/__tests__/integration/analytics.test.ts @@ -57,7 +57,8 @@ function makeRequest(url: string): Request { /** 统计查询的可读错题条件:自有或已接受共享错题本 */ const ACCESS_WHERE = { OR: [ - { userId: 'user-123' }, + { userId: 'user-123', subjectId: null }, + { subject: { userId: 'user-123' } }, { subject: { shares: { some: { memberId: 'user-123', status: 'active' } } } }, ], }; diff --git a/src/__tests__/integration/review.test.ts b/src/__tests__/integration/review.test.ts index f64c31e4..7d7e1159 100644 --- a/src/__tests__/integration/review.test.ts +++ b/src/__tests__/integration/review.test.ts @@ -27,7 +27,8 @@ const get = (query = '') => GET(new Request(`http://localhost/api/review/due${qu /** 复习候选:自有或已接受共享错题本 */ const ACCESS_WHERE = { OR: [ - { userId: 'user-1' }, + { userId: 'user-1', subjectId: null }, + { subject: { userId: 'user-1' } }, { subject: { shares: { some: { memberId: 'user-1', status: 'active' } } } }, ], }; diff --git a/src/__tests__/integration/tags.test.ts b/src/__tests__/integration/tags.test.ts index a6d574ec..aada6a7f 100644 --- a/src/__tests__/integration/tags.test.ts +++ b/src/__tests__/integration/tags.test.ts @@ -86,15 +86,15 @@ describe('/api/tags', () => { await GET_STATS(statsRequest()); - expect(mocks.mockPrismaErrorItem.count).toHaveBeenCalledWith({ where: { userId: 'user-1' } }); + expect(mocks.mockPrismaErrorItem.count).toHaveBeenCalledWith({ where: { userId: 'user-1', subjectId: null } }); expect(mocks.mockPrismaKnowledgeTag.findMany).toHaveBeenCalledWith({ - where: { errorItems: { some: { userId: 'user-1' } } }, + where: { errorItems: { some: { userId: 'user-1', subjectId: null } } }, select: { id: true, name: true, subject: true, tagSet: true, - _count: { select: { errorItems: { where: { userId: 'user-1' } } } }, + _count: { select: { errorItems: { where: { userId: 'user-1', subjectId: null } } } }, }, }); expect(mocks.mockPrismaErrorItem.findMany).not.toHaveBeenCalled(); @@ -151,7 +151,7 @@ describe('/api/tags', () => { await GET_STATS(statsRequest('?tagSet=cnm')); expect(mocks.mockPrismaKnowledgeTag.findMany).toHaveBeenCalledWith(expect.objectContaining({ - where: { errorItems: { some: { userId: 'user-1' } }, tagSet: 'cnm' }, + where: { errorItems: { some: { userId: 'user-1', subjectId: null } }, tagSet: 'cnm' }, })); }); diff --git a/src/__tests__/integration/weak-tags.test.ts b/src/__tests__/integration/weak-tags.test.ts index 8123b447..e729ff9e 100644 --- a/src/__tests__/integration/weak-tags.test.ts +++ b/src/__tests__/integration/weak-tags.test.ts @@ -44,7 +44,8 @@ function makeRequest(url: string): Request { /** 薄弱知识点查询的可读错题条件:自有或已接受共享错题本 */ const ACCESS_WHERE = { OR: [ - { userId: 'user-123' }, + { userId: 'user-123', subjectId: null }, + { subject: { userId: 'user-123' } }, { subject: { shares: { some: { memberId: 'user-123', status: 'active' } } } }, ], };