v1.12.22 관리자 멤버 댓글 목록 및 최근 댓글 확인 추가
This commit is contained in:
45
tests/playwright/e2e/admin-comments.spec.js
Normal file
45
tests/playwright/e2e/admin-comments.spec.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
import postgres from 'postgres'
|
||||
|
||||
test('멤버 댓글 페이지 이동·게시물 링크와 대시보드 최근 댓글을 표시한다', async ({ page }) => {
|
||||
const database = postgres(process.env.DATABASE_URL, { max: 1 })
|
||||
let postId
|
||||
try {
|
||||
const login = await page.request.post('/admin/api/auth/login', {
|
||||
data: { email: 'playwright-admin@example.com', password: 'playwright-admin-password' }
|
||||
})
|
||||
expect(login.ok()).toBeTruthy()
|
||||
const admin = await login.json()
|
||||
const created = await page.request.post('/admin/api/posts', {
|
||||
data: { title: '댓글 화면 검증 게시물', slug: 'comments-ui-test', content: '본문', status: 'published', tags: [], tagNames: {} }
|
||||
})
|
||||
expect(created.ok()).toBeTruthy()
|
||||
postId = (await created.json()).id
|
||||
for (let index = 0; index < 11; index += 1) {
|
||||
await database`
|
||||
INSERT INTO comments (post_id, user_id, body, created_at)
|
||||
VALUES (${postId}, ${admin.userId}, ${`화면 댓글 ${index}`}, now() + ${index} * interval '1 second')
|
||||
`
|
||||
}
|
||||
await page.goto(`/admin/members/${admin.userId}`)
|
||||
await page.waitForLoadState('networkidle')
|
||||
const list = page.locator('.admin-comment-list')
|
||||
await expect(list.locator('.admin-comment-list__item')).toHaveCount(10)
|
||||
await expect(list.locator('.admin-comment-list__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-comment-list__item')).toHaveCount(1)
|
||||
await expect(list.locator('.admin-comment-list__body')).toHaveText('화면 댓글 0')
|
||||
await list.getByRole('button', { name: '이전' }).click()
|
||||
await expect(list.locator('.admin-comment-list__item')).toHaveCount(10)
|
||||
await page.goto('/admin')
|
||||
await expect(page.locator('.admin-comment-list__item')).toHaveCount(5)
|
||||
await expect(page.locator('.admin-comment-list__body').first()).toHaveText('화면 댓글 10')
|
||||
await page.goto('/admin/posts')
|
||||
const row = page.locator('.admin-posts__row').filter({ hasText: '댓글 화면 검증 게시물' })
|
||||
await expect(row.locator('.admin-posts__comment-count')).toHaveText('11')
|
||||
} finally {
|
||||
if (postId) await database`DELETE FROM posts WHERE id = ${postId}`
|
||||
await database.end()
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user