v1.12.24 멤버 작성 이력 통합 표 및 종류 필터 추가

This commit is contained in:
2026-10-21 17:03:07 +09:00
parent 7c95797fd2
commit 93dc6c04bd
13 changed files with 229 additions and 73 deletions

View File

@@ -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 })

View File

@@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test'
import postgres from 'postgres'
test('멤버 댓글 페이지 이동·게시물 링크와 대시보드 최근 댓글을 표시한다', async ({ page }) => {
test('멤버 통합 작성 이력의 종류 필터·검색·페이지와 대시보드 댓글을 표시한다', async ({ page }) => {
const database = postgres(process.env.DATABASE_URL, { max: 1 })
let postId
try {
@@ -24,28 +24,36 @@ test('멤버 댓글 페이지 이동·게시물 링크와 대시보드 최근
await page.goto(`/admin/members/${admin.userId}`)
await page.waitForLoadState('networkidle')
await expect(page.locator('.admin-member-activity')).toHaveCount(0)
await page.getByRole('button', { name: '작성한 댓글', exact: true }).click()
const list = page.locator('.admin-member-activity')
await expect(list.locator('.admin-member-activity__item')).toHaveCount(10)
await expect(list.locator('.admin-member-activity__body').first()).toHaveText('화면 댓글 10')
await expect(list.getByRole('link', { name: '게시물 보기' }).first()).toHaveAttribute('href', '/post/comments-ui-test#comments')
await list.getByRole('button', { name: '다음 페이지' }).click()
await expect(list.locator('.admin-member-activity__item')).toHaveCount(1)
await expect(list.locator('.admin-member-activity__body')).toHaveText('화면 댓글 0')
await list.getByRole('button', { name: '이전 페이지' }).click()
await expect(list.locator('.admin-member-activity__item')).toHaveCount(10)
await list.getByLabel('작성한 댓글 검색').fill('화면 댓글 0')
await list.getByRole('button', { name: '검색', exact: true }).click()
await expect(list.locator('.admin-member-activity__item')).toHaveCount(1)
await expect(list.locator('.admin-member-activity__body')).toHaveText('화면 댓글 0')
await list.getByLabel('작성한 댓글 검색').fill('결과없음')
await list.getByRole('button', { name: '검색', exact: true }).click()
await expect(list).toContainText('검색 결과가 없습니다.')
await expect(page.getByRole('button', { name: '작성한 댓글', exact: true })).toHaveCount(0)
await page.getByRole('button', { name: '작성한 글', exact: true }).click()
await expect(page.locator('.admin-member-activity__item')).toHaveCount(1)
await page.getByLabel('작성한 글 검색').fill('없는글')
await page.locator('.admin-member-activity').getByRole('button', { name: '검색', exact: true }).click()
await expect(page.locator('.admin-member-activity')).toContainText('검색 결과가 없습니다.')
const list = page.locator('.admin-member-activity')
const items = list.locator('.admin-member-activity__item')
await expect(items).toHaveCount(10)
await expect(list.locator('.admin-member-activity__body').first()).toHaveText('화면 댓글 10')
await expect(list.locator('.admin-member-activity__post').first()).toHaveAttribute('href', '/post/comments-ui-test#comments')
await list.getByRole('button', { name: '다음 페이지' }).click()
await expect(items).toHaveCount(2)
await expect(list.locator('.admin-member-activity__kind')).toHaveText(['댓글', '게시글'])
await list.getByLabel('작성 종류').selectOption('comment')
await expect(items).toHaveCount(10)
await expect(list.locator('.admin-member-activity__kind').first()).toHaveText('댓글')
await list.getByRole('button', { name: '다음 페이지' }).click()
await expect(items).toHaveCount(1)
await list.getByLabel('작성한 글 검색').fill('화면 댓글 0')
await list.getByRole('button', { name: '검색', exact: true }).click()
await expect(items).toHaveCount(1)
await expect(list.locator('.admin-member-activity__body')).toHaveText('화면 댓글 0')
await list.getByLabel('작성 종류').selectOption('post')
await expect(list).toContainText('검색 결과가 없습니다.')
await list.getByLabel('작성한 글 검색').fill('')
await list.getByRole('button', { name: '검색', exact: true }).click()
await expect(items).toHaveCount(1)
await expect(list.locator('.admin-member-activity__kind')).toHaveText('게시글')
await expect(list.locator('.admin-member-activity__body')).toHaveText('본문')
await list.getByLabel('작성 종류').selectOption('all')
await expect(items).toHaveCount(10)
const rowBox = await items.first().boundingBox()
expect(rowBox.height).toBeLessThan(40)
await page.getByRole('button', { name: '정보', exact: true }).click()
await expect(page.locator('.admin-member-form__body')).toBeVisible()
await page.goto('/admin')