mirror of
https://github.com/margrop/wrong-notebook.git
synced 2026-12-05 07:29:27 +08:00
test: 补齐共享权限集成断言更新
- 统计、复习、薄弱知识点与标签统计同步新可读条件 Refs: https://github.com/margrop/wrong-notebook/issues/167
This commit is contained in:
@@ -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' } } } },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -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' } } } },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -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' },
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
@@ -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' } } } },
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user