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' } } } }, ], };