v1.12.24 멤버 작성 이력 통합 표 및 종류 필터 추가
This commit is contained in:
@@ -293,6 +293,38 @@ test('멤버 작성 글 조회는 작성자를 분리하고 전체 이력을 검
|
||||
'draft', ${author.id}, now() + index * interval '1 second'
|
||||
FROM generate_series(1, 11) AS index
|
||||
`
|
||||
const [targetPost] = await database`SELECT id FROM posts WHERE author_id = ${author.id} ORDER BY created_at DESC LIMIT 1`
|
||||
await database`
|
||||
INSERT INTO comments (post_id, user_id, body, created_at)
|
||||
VALUES (${targetPost.id}, ${author.id}, '통합 댓글 최신', now() + interval '20 second'),
|
||||
(${targetPost.id}, ${author.id}, '통합 댓글 과거', now() - interval '1 day'),
|
||||
(${targetPost.id}, ${adminUser.userId}, '다른 회원 댓글', now() + interval '30 second')
|
||||
`
|
||||
const activityUrl = `/admin/api/members/${author.id}/activity`
|
||||
expect((await anonymousApi.get(activityUrl)).status()).toBe(401)
|
||||
for (const query of ['type=invalid', 'page=0', 'pageSize=101']) {
|
||||
expect((await adminApi.get(`${activityUrl}?${query}`)).status()).toBe(400)
|
||||
}
|
||||
expect((await adminApi.get('/admin/api/members/invalid/activity')).status()).toBe(400)
|
||||
const mixed = await (await adminApi.get(activityUrl)).json()
|
||||
expect(mixed.pagination).toMatchObject({ total: 13, pageCount: 2, page: 1 })
|
||||
expect(mixed.items).toHaveLength(10)
|
||||
expect(mixed.items[0]).toMatchObject({ kind: 'comment', body: '통합 댓글 최신', postId: targetPost.id, publicUrl: null })
|
||||
expect(mixed.items[1]).toMatchObject({ kind: 'post', postTitle: '작성 이력 11', body: '검색 본문 11' })
|
||||
const mixedLast = await (await adminApi.get(`${activityUrl}?page=999`)).json()
|
||||
expect(mixedLast.pagination.page).toBe(2)
|
||||
expect(mixedLast.items).toHaveLength(3)
|
||||
expect(mixedLast.items[2].body).toBe('통합 댓글 과거')
|
||||
const onlyComments = await (await adminApi.get(`${activityUrl}?type=comment`)).json()
|
||||
expect(onlyComments.pagination.total).toBe(2)
|
||||
expect(onlyComments.items.every((item) => item.kind === 'comment')).toBe(true)
|
||||
const onlyPosts = await (await adminApi.get(`${activityUrl}?type=post`)).json()
|
||||
expect(onlyPosts.pagination.total).toBe(11)
|
||||
expect(onlyPosts.items.every((item) => item.kind === 'post')).toBe(true)
|
||||
const activitySearch = await (await adminApi.get(`${activityUrl}?q=${encodeURIComponent('통합 댓글 최신')}`)).json()
|
||||
expect(activitySearch.pagination.total).toBe(1)
|
||||
const activityEmpty = await (await adminApi.get(`${activityUrl}?type=post&q=%25`)).json()
|
||||
expect(activityEmpty.items).toEqual([])
|
||||
const authorUrl = `/admin/api/members/${author.id}/posts`
|
||||
const first = await (await adminApi.get(authorUrl)).json()
|
||||
expect(first.pagination).toMatchObject({ total: 11, pageCount: 2, page: 1 })
|
||||
|
||||
Reference in New Issue
Block a user