feat(board): 게시글 반응(추천/비추천) 프론트엔드 화면

4단계 화면 3면 + 백엔드 수용.

- 게시글 상세(show.json): 신고 버튼 위에 반응 영역 — use_reaction &&
 유형 존재 시 노출, 유형 iteration(아이콘+라벨+개수, 0도 노출), 본인 글 비활성화,
 같은 유형 재클릭=해제·다른 유형=전환, 비로그인 안내 후 로그인 유도
- 관리 설정 기본값 탭 + 개별 게시판 편집 폼: 반응 사용 토글 + 유형 체크박스
 (reactionTypes data_source iteration, active_reaction_types code 토글)
- FormRequest(Store/Update Board, Store/BulkApply Settings)에 use_reaction·
 active_reaction_types 화이트리스트/캐스트/시드 추가 (미추가 시 토글 미저장)
- BoardResource.icon_name(fa-* 토큰) — Icon 컴포넌트 접두사 중복 방지
- ko/en 다국어 + boards/settings API 문서 갱신
- Vitest 10건(템플릿 4 + 모듈 6) green, board 관리/설정 87건 회귀 green

ja 언어팩·시나리오 매니페스트·E2E·버전 bump·CHANGELOG 는 5단계.
This commit is contained in:
chym1217 committed 2026-08-07 17:00:48 +09:00
1 parent 4060a91d28
commit 2ba0c2ba2d
22 files changed
+662 -6

No files matched your search

@@ -0,0 +1,114 @@
/**
* @file board-reaction-buttons.test.tsx
* @description 게시글 상세 반응(추천/비추천) 버튼 레이아웃 회귀 (이슈 #525)
*
* 검증 방식: 레이아웃 JSON 트리 직접 분석 (board 파티션 테스트 관례 — show.json 은 partial).
* 고정 대상:
* - 반응 영역은 use_reaction && reaction_type_options.length > 0 일 때만 노출 (확정 11)
* - reaction_type_options 를 iteration 으로 순회 (확정 02·유형 동적 렌더)
* - 유형별 개수는 reaction_counts[유형 ID] 를 바인딩, 없으면 0 (확정 09)
* - 본인 글이면 버튼 disabled (확정 08)
* - 클릭 시 비로그인은 안내+로그인 유도, 로그인 사용자는 react API 호출 후 post 재조회 (확정 03·07)
*/
import { describe, it, expect } from 'vitest';
import basicShow from '../../layouts/partials/board/types/basic/show.json';
type Node = Record<string, unknown> & { children?: unknown };
function collectNodes(node: unknown, predicate: (n: Node) => boolean): Node[] {
const result: Node[] = [];
const walk = (cur: unknown): void => {
if (Array.isArray(cur)) {
cur.forEach(walk);
return;
}
if (cur && typeof cur === 'object') {
const obj = cur as Node;
if (predicate(obj)) {
result.push(obj);
}
Object.values(obj).forEach(walk);
}
};
walk(node);
return result;
}
function findByComment(root: unknown, commentText: string): Node[] {
return collectNodes(root, (n) => typeof n.comment === 'string' && (n.comment as string).includes(commentText));
}
describe('이슈 #525 — 게시글 상세 반응 버튼 (basic/show.json)', () => {
it('반응 영역은 use_reaction + reaction_type_options 존재 시에만 노출된다 (확정 11)', () => {
const areas = findByComment(basicShow, '게시글 반응(추천/비추천) 영역');
expect(areas.length).toBe(1);
const area = areas[0];
expect(typeof area.if).toBe('string');
expect(area.if as string).toContain('use_reaction');
expect(area.if as string).toContain('reaction_type_options');
expect(area.if as string).toContain('length > 0');
});
it('반응 유형을 reaction_type_options 로 iteration 한다', () => {
const areas = findByComment(basicShow, '게시글 반응(추천/비추천) 영역');
const iterations = collectNodes(areas[0], (n) => n.iteration !== undefined);
expect(iterations.length).toBeGreaterThan(0);
const iter = iterations[0].iteration as Record<string, unknown>;
expect(iter.source as string).toContain('reaction_type_options');
expect(iter.item_var).toBe('reactionType');
});
it('유형별 버튼은 본인 글이면 disabled 이고 개수를 바인딩한다 (확정 08·09)', () => {
const areas = findByComment(basicShow, '게시글 반응(추천/비추천) 영역');
const buttons = collectNodes(areas[0], (n) => n.name === 'Button');
expect(buttons.length).toBeGreaterThan(0);
const btn = buttons[0];
const props = btn.props as Record<string, unknown>;
expect(props.type).toBe('button');
expect(String(props.disabled)).toContain('is_author');
// 개수 바인딩 (reaction_counts[유형 ID] ?? 0)
const counts = collectNodes(btn, (n) =>
typeof n.text === 'string' && (n.text as string).includes('reaction_counts')
);
expect(counts.length).toBe(1);
expect(counts[0].text as string).toContain('reactionType.id');
expect(counts[0].text as string).toContain('?? 0');
});
it('클릭 액션은 비로그인/로그인 분기 — react API 호출 + post 재조회 (확정 03·07)', () => {
const areas = findByComment(basicShow, '게시글 반응(추천/비추천) 영역');
const buttons = collectNodes(areas[0], (n) => n.name === 'Button');
const actions = (buttons[0].actions as Node[]) ?? [];
expect(actions.length).toBeGreaterThan(0);
const action = actions[0];
expect(action.handler).toBe('switch');
const cases = action.cases as Record<string, Node>;
expect(cases.logged_in).toBeDefined();
expect(cases.not_logged_in).toBeDefined();
// 로그인 사용자: react API 호출 후 post 데이터소스 재조회
const loggedIn = cases.logged_in;
expect(loggedIn.handler).toBe('apiCall');
expect(loggedIn.target as string).toContain('/react');
const onSuccess = loggedIn.onSuccess as Node[];
expect(onSuccess.some((a) => a.handler === 'refetchDataSource')).toBe(true);
// 비로그인: 안내 후 로그인 유도 (redirect 파라미터 전달)
const guest = cases.not_logged_in;
const guestActions = guest.actions as Node[];
expect(guestActions.some((a) => a.handler === 'toast')).toBe(true);
const navAction = guestActions.find((a) => a.handler === 'navigate');
expect(navAction).toBeDefined();
const navParams = navAction!.params as Record<string, unknown>;
expect(navParams.path).toBe('/login');
expect((navParams.query as Record<string, unknown>).redirect).toContain('/board/');
});
});
@@ -141,7 +141,8 @@
"laugh": "Funny",
"agree": "Agree",
"thanks": "Thanks",
"wow": "Wow"
"wow": "Wow",
"login_required": "You need to sign in to use this feature."
},
"attachments": {
"title": "Attachments",
@@ -141,7 +141,8 @@
"laugh": "웃겨요",
"agree": "동의해요",
"thanks": "감사해요",
"wow": "놀라워요"
"wow": "놀라워요",
"login_required": "로그인이 필요한 기능입니다"
},
"attachments": {
"title": "첨부파일",
@@ -927,6 +927,121 @@
}
]
},
{
"comment": "게시글 반응(추천/비추천) 영역 — 반응 사용 on + 게시판이 켠 유형이 1개 이상일 때만 노출(확정 11). 활성 유형을 iteration 으로 순회해 유형별 버튼(아이콘+라벨+개수, 개수 0도 항상 노출, 확정 09). 본인 글은 버튼/개수는 노출하되 클릭 불가(확정 08). 비로그인은 안내 후 로그인 유도, 로그인 사용자는 같은 유형 재클릭=해제·다른 유형=전환.",
"type": "basic",
"name": "Div",
"if": "{{post?.data?.board?.use_reaction && (post?.data?.board?.reaction_type_options ?? []).length > 0}}",
"props": {
"className": "flex flex-wrap items-center gap-2 px-6 py-4 border-t border-gray-200 dark:border-gray-700"
},
"children": [
{
"type": "basic",
"name": "Div",
"iteration": {
"source": "{{post?.data?.board?.reaction_type_options ?? []}}",
"item_var": "reactionType",
"index_var": "reactionIdx"
},
"children": [
{
"comment": "반응 유형 버튼 — my_reaction_type_id 와 일치하면 하이라이트, 본인 글이면 비활성화",
"type": "basic",
"name": "Button",
"props": {
"type": "button",
"disabled": "{{post?.data?.is_author === true}}",
"className": "{{post?.data?.my_reaction_type_id === reactionType.id ? 'px-4 py-2 text-sm border border-blue-500 dark:border-blue-400 bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded-lg flex items-center gap-1.5 font-medium transition-colors' : 'px-4 py-2 text-sm border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors flex items-center gap-1.5'}}{{post?.data?.is_author ? ' cursor-not-allowed opacity-60' : ' cursor-pointer'}}"
},
"actions": [
{
"type": "click",
"handler": "switch",
"params": {
"value": "{{_global.currentUser?.uuid ? 'logged_in' : 'not_logged_in'}}"
},
"cases": {
"logged_in": {
"handler": "apiCall",
"target": "/api/modules/sirsoft-board/boards/{{route.slug}}/posts/{{route.id}}/react",
"auth_mode": "required",
"params": {
"method": "POST",
"body": {
"reaction_type_id": "{{reactionType.id}}"
}
},
"onSuccess": [
{
"handler": "refetchDataSource",
"params": {
"dataSourceId": "post"
}
}
],
"onError": [
{
"handler": "toast",
"params": {
"type": "error",
"message": "{{error.message}}"
}
}
]
},
"not_logged_in": {
"handler": "sequence",
"actions": [
{
"handler": "toast",
"params": {
"type": "info",
"message": "$t:board.reaction.login_required"
}
},
{
"handler": "navigate",
"params": {
"path": "/login",
"query": {
"redirect": "/board/{{route.slug}}/{{route.id}}"
}
}
}
]
}
}
}
],
"children": [
{
"type": "basic",
"name": "Icon",
"props": {
"name": "{{reactionType.icon_name ?? 'fa-thumbs-up'}}",
"size": "sm"
}
},
{
"type": "basic",
"name": "Span",
"text": "{{reactionType.name ?? ''}}"
},
{
"type": "basic",
"name": "Span",
"props": {
"className": "tabular-nums"
},
"text": "{{post?.data?.reaction_counts?.[reactionType.id] ?? 0}}"
}
]
}
]
}
]
},
{
"comment": "게시글 액션 버튼 영역 (답변, 신고, 수정, 삭제) - 비회원 글은 항상 표시 (수정/삭제용)",
"type": "basic",