chore(payment): NHN KCP와 NICE 결제 플러그인 개발 브랜치 분리
정식 develop에서는 기본 번들 정책에 따라 제거된 결제 플러그인을 별도 개발 브랜치에서 계속 유지보수할 수 있도록 복원한다.
This commit is contained in:
1 parent
49b21e788c
commit
657f546efc
651 files changed
+49118
-20476
No files matched your search
-237
@@ -1,237 +0,0 @@
|
||||
/**
|
||||
* @file admin-cross-navigation.test.tsx
|
||||
* @description 유저 화면 → 관리자 화면 크로스링크 노출 게이트 회귀 테스트 (이슈 #450)
|
||||
*
|
||||
* 검증 항목:
|
||||
* 1. 게시판: can_access_admin = true → 관리자 진입 링크 2개(게시물 조회 + 게시판 관리) 렌더
|
||||
* 2. 게시판: can_access_admin = false → 관리자 진입 링크 미렌더
|
||||
* 3. 상품: can_update = true → 관리자 상품 수정 링크 렌더 + href 검증
|
||||
* 4. 상품: can_update = false → 관리자 상품 수정 링크 미렌더
|
||||
* 5. 게이트는 실제 파티셜 JSON(_admin_links.json / _admin_edit_link.json)의 if 표현식과 일치
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { createLayoutTest, screen } from '@/core/template-engine/__tests__/utils/layoutTestUtils';
|
||||
import { ComponentRegistry } from '@/core/template-engine/ComponentRegistry';
|
||||
|
||||
// 실제 파티셜 JSON — 게이트 표현식/href 회귀 고정
|
||||
import adminLinks from '../../../layouts/partials/board/index/_admin_links.json';
|
||||
import adminEditLink from '../../../layouts/partials/shop/detail/_admin_edit_link.json';
|
||||
|
||||
// ============================================================
|
||||
// 테스트용 컴포넌트
|
||||
// ============================================================
|
||||
|
||||
const TestDiv: React.FC<{ className?: string; children?: React.ReactNode; 'data-testid'?: string }> = ({
|
||||
className,
|
||||
children,
|
||||
'data-testid': testId,
|
||||
}) => (
|
||||
<div className={className} data-testid={testId}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
const TestA: React.FC<{
|
||||
href?: string;
|
||||
target?: string;
|
||||
rel?: string;
|
||||
title?: string;
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
'data-testid'?: string;
|
||||
}> = ({ href, target, rel, title, className, children, 'data-testid': testId }) => (
|
||||
<a href={href} target={target} rel={rel} title={title} className={className} data-testid={testId}>
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
|
||||
const TestSpan: React.FC<{ className?: string; children?: React.ReactNode; text?: string }> = ({
|
||||
className,
|
||||
children,
|
||||
text,
|
||||
}) => <span className={className}>{children || text}</span>;
|
||||
|
||||
const TestIcon: React.FC<{ name?: string }> = ({ name }) => <i data-icon={name} />;
|
||||
|
||||
function setupTestRegistry(): ComponentRegistry {
|
||||
const registry = ComponentRegistry.getInstance();
|
||||
const Fragment: React.FC<{ children?: React.ReactNode }> = ({ children }) => <>{children}</>;
|
||||
(registry as unknown as { registry: Record<string, unknown> }).registry = {
|
||||
Fragment: { component: Fragment, metadata: { name: 'Fragment', type: 'layout' } },
|
||||
Div: { component: TestDiv, metadata: { name: 'Div', type: 'basic' } },
|
||||
A: { component: TestA, metadata: { name: 'A', type: 'basic' } },
|
||||
Span: { component: TestSpan, metadata: { name: 'Span', type: 'basic' } },
|
||||
Icon: { component: TestIcon, metadata: { name: 'Icon', type: 'basic' } },
|
||||
};
|
||||
return registry;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 게시판 admin-links 게이트 (can_access_admin)
|
||||
// ============================================================
|
||||
|
||||
const boardAdminLinksLayout = {
|
||||
version: '1.0.0',
|
||||
layout_name: 'board_admin_links_test',
|
||||
data_sources: [
|
||||
{
|
||||
id: 'posts',
|
||||
type: 'api',
|
||||
endpoint: '/api/modules/sirsoft-board/boards/test/posts',
|
||||
method: 'GET',
|
||||
auto_fetch: true,
|
||||
},
|
||||
],
|
||||
components: [
|
||||
{
|
||||
type: 'basic',
|
||||
name: 'A',
|
||||
if: '{{posts?.data?.abilities?.can_access_admin}}',
|
||||
props: {
|
||||
'data-testid': 'board-admin-posts-link',
|
||||
href: '/admin/board/{{route.slug}}',
|
||||
target: '_blank',
|
||||
},
|
||||
children: [{ type: 'basic', name: 'Span', text: 'Admin posts' }],
|
||||
},
|
||||
{
|
||||
type: 'basic',
|
||||
name: 'A',
|
||||
if: '{{posts?.data?.abilities?.can_access_admin}}',
|
||||
props: {
|
||||
'data-testid': 'board-admin-manage-link',
|
||||
href: '/admin/boards/{{route.slug}}/edit',
|
||||
target: '_blank',
|
||||
},
|
||||
children: [{ type: 'basic', name: 'Span', text: 'Board settings' }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// ============================================================
|
||||
// 상품 admin edit 게이트 (can_update)
|
||||
// ============================================================
|
||||
|
||||
const productAdminEditLayout = {
|
||||
version: '1.0.0',
|
||||
layout_name: 'product_admin_edit_test',
|
||||
data_sources: [
|
||||
{
|
||||
id: 'product',
|
||||
type: 'api',
|
||||
endpoint: '/api/modules/sirsoft-ecommerce/products/1',
|
||||
method: 'GET',
|
||||
auto_fetch: true,
|
||||
},
|
||||
],
|
||||
components: [
|
||||
{
|
||||
type: 'basic',
|
||||
name: 'A',
|
||||
if: '{{product.data?.abilities?.can_update}}',
|
||||
props: {
|
||||
'data-testid': 'product-admin-edit-link',
|
||||
href: '/admin/ecommerce/products/{{product.data?.product_code ?? route.product_code}}/edit',
|
||||
target: '_blank',
|
||||
},
|
||||
children: [{ type: 'basic', name: 'Span', text: 'Edit in admin' }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// ============================================================
|
||||
// 테스트
|
||||
// ============================================================
|
||||
|
||||
describe('이슈 #450 — 유저→관리자 크로스링크 게이트', () => {
|
||||
beforeEach(() => {
|
||||
setupTestRegistry();
|
||||
});
|
||||
|
||||
describe('게시판 관리자 진입 링크 (can_access_admin)', () => {
|
||||
it('can_access_admin = true → 게시물 조회 + 게시판 관리 링크 2개 렌더', async () => {
|
||||
const testUtils = createLayoutTest(boardAdminLinksLayout, { routeParams: { slug: 'free' } });
|
||||
testUtils.mockApi('posts', {
|
||||
response: { data: { abilities: { can_access_admin: true } } },
|
||||
});
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.getByTestId('board-admin-posts-link')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('board-admin-manage-link')).toBeInTheDocument();
|
||||
// "게시판 관리" 는 해당 게시판의 개별 설정 화면(/admin/boards/:slug/edit)으로 이동
|
||||
expect(screen.getByTestId('board-admin-manage-link').getAttribute('href')).toBe('/admin/boards/free/edit');
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
|
||||
it('can_access_admin = false → 관리자 진입 링크 미렌더', async () => {
|
||||
const testUtils = createLayoutTest(boardAdminLinksLayout);
|
||||
testUtils.mockApi('posts', {
|
||||
response: { data: { abilities: { can_access_admin: false } } },
|
||||
});
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('board-admin-posts-link')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('board-admin-manage-link')).not.toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
});
|
||||
|
||||
describe('상품 관리자 수정 링크 (can_update)', () => {
|
||||
it('can_update = true → 관리자 상품 수정 링크 렌더', async () => {
|
||||
const testUtils = createLayoutTest(productAdminEditLayout);
|
||||
testUtils.mockApi('product', {
|
||||
response: { data: { id: 42, product_code: 'KOWZBDA045RJQHDJ', abilities: { can_update: true } } },
|
||||
});
|
||||
await testUtils.render();
|
||||
|
||||
const link = screen.getByTestId('product-admin-edit-link');
|
||||
expect(link).toBeInTheDocument();
|
||||
// 관리자 편집 링크는 product_code 기준
|
||||
expect(link.getAttribute('href')).toBe('/admin/ecommerce/products/KOWZBDA045RJQHDJ/edit');
|
||||
expect(link.getAttribute('target')).toBe('_blank');
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
|
||||
it('can_update = false → 관리자 상품 수정 링크 미렌더', async () => {
|
||||
const testUtils = createLayoutTest(productAdminEditLayout);
|
||||
testUtils.mockApi('product', {
|
||||
response: { data: { id: 42, product_code: 'KOWZBDA045RJQHDJ', abilities: { can_update: false } } },
|
||||
});
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('product-admin-edit-link')).not.toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// 실제 파티셜 JSON 게이트/속성 회귀 고정 (구조 분석)
|
||||
// ============================================================
|
||||
describe('파티셜 JSON 회귀 고정', () => {
|
||||
it('_admin_links.json 은 can_access_admin 게이트를 사용한다', () => {
|
||||
expect((adminLinks as { if?: string }).if).toBe('{{posts?.data?.abilities?.can_access_admin}}');
|
||||
});
|
||||
|
||||
it('_admin_links.json 은 관리자 게시물 조회 + 게시판 관리 링크를 새 탭으로 연다', () => {
|
||||
const dump = JSON.stringify(adminLinks);
|
||||
expect(dump).toContain('/admin/board/{{route.slug}}');
|
||||
// "게시판 관리" 는 개별 게시판 설정 화면(:slug/edit)으로 이동
|
||||
expect(dump).toContain('/admin/boards/{{route.slug}}/edit');
|
||||
expect(dump).toContain('"target":"_blank"');
|
||||
});
|
||||
|
||||
it('_admin_edit_link.json 은 can_update 게이트 + 새 탭 + 상품 수정 경로를 사용한다', () => {
|
||||
expect((adminEditLink as { if?: string }).if).toBe('{{product.data?.abilities?.can_update}}');
|
||||
const dump = JSON.stringify(adminEditLink);
|
||||
// 상품 관리자 편집 링크는 product_code 기준
|
||||
expect(dump).toContain('/admin/ecommerce/products/{{product.data?.product_code ?? route.product_code}}/edit');
|
||||
expect(dump).toContain('"target":"_blank"');
|
||||
});
|
||||
});
|
||||
});
|
||||
+2
-2
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* 근본 원인 / 수정:
|
||||
* - 증상2: onSuccess 에 post 데이터소스 refetch 누락 → refetchDataSource(post) 추가
|
||||
* - 증상1: onError 에 closeModal 누락 → "모달 닫고 토스트"(설계 결정) 로 보강
|
||||
* - 증상1: onError 에 closeModal 누락 → "모달 닫고 토스트"(PO 결정) 로 보강
|
||||
*
|
||||
* 신고 모달은 게시글/댓글 공용 1파일이므로 이 단언이 양쪽을 모두 커버한다.
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ describe('신고 모달 제출 피드백 (이슈 #413-60)', () => {
|
||||
expect(toast?.params?.type).toBe('error');
|
||||
});
|
||||
|
||||
it('onError 에 closeModal 이 있어야 한다 (설계 결정: 실패 시 모달 닫고 토스트)', () => {
|
||||
it('onError 에 closeModal 이 있어야 한다 (PO 결정: 실패 시 모달 닫고 토스트)', () => {
|
||||
const close = onError.find((a) => a.handler === 'closeModal');
|
||||
expect(close).toBeDefined();
|
||||
});
|
||||
|
||||
+1
-9
@@ -207,17 +207,9 @@ export function useFileUploader(options: UseFileUploaderOptions): UseFileUploade
|
||||
const handleFiles = useCallback(
|
||||
async (selectedFiles: FileList) => {
|
||||
const totalCount = existingFiles.length + pendingFiles.length;
|
||||
const remainingSlots = Math.max(0, maxFiles - totalCount);
|
||||
const remainingSlots = maxFiles - totalCount;
|
||||
const filesToAdd = Array.from(selectedFiles).slice(0, remainingSlots);
|
||||
|
||||
// 개수 상한 초과분은 조용히 절단하지 않고 안내 (개수 초과 silent 무시 방지)
|
||||
if (selectedFiles.length > remainingSlots) {
|
||||
const overflow = Array.from(selectedFiles).slice(remainingSlots);
|
||||
const message = t('attachment.upload_limit_exceeded', { max: maxFiles });
|
||||
// 잘린 첫 파일을 대표로 콜백에 전달 (없으면 무시)
|
||||
onUploadError?.(message, overflow[0] ?? selectedFiles[0]);
|
||||
}
|
||||
|
||||
for (const file of filesToAdd) {
|
||||
// 크기 검증
|
||||
if (file.size > maxSize * 1024 * 1024) {
|
||||
|
||||
@@ -71,8 +71,6 @@ interface ProductLabel {
|
||||
interface ProductCardProps {
|
||||
product: {
|
||||
id: number;
|
||||
/** 상품코드 — 상세 페이지 링크 식별자 (product_code 기준 라우팅). 없으면 id 로 폴백 */
|
||||
product_code?: string;
|
||||
name?: string | Record<string, string>;
|
||||
name_localized?: string;
|
||||
thumbnail_url: string;
|
||||
@@ -220,9 +218,7 @@ const ProductCard: React.FC<ProductCardProps> = ({
|
||||
onClick(product.id);
|
||||
} else {
|
||||
const base = shopBase === '/' ? '' : shopBase;
|
||||
// 상세 페이지는 product_code 기준 라우팅. code 미제공 시 id 로 폴백(하위호환).
|
||||
const identifier = product.product_code ?? product.id;
|
||||
navigate(`${base}/products/${identifier}`);
|
||||
navigate(`${base}/products/${product.id}`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
/**
|
||||
* FileUploader 개수 상한 초과 안내 테스트
|
||||
*
|
||||
* maxFiles 를 초과해 파일을 선택하면 초과분을 조용히 버리지 않고
|
||||
* onUploadError 콜백으로 안내한다. (admin_basic 과 동일 동작 — 공통 문구)
|
||||
*
|
||||
* @vitest-environment jsdom
|
||||
* @module composite/__tests__/FileUploaderLimit.test
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { useFileUploader } from '../FileUploader/useFileUploader';
|
||||
import type { Attachment } from '../FileUploader/types';
|
||||
|
||||
// G7Core 모킹 (useFileUploader 가 모듈 스코프에서 window.G7Core 를 캐싱하므로
|
||||
// 새 객체로 교체하지 않고 기존 객체에 프로퍼티를 직접 추가)
|
||||
beforeEach(() => {
|
||||
const listeners = new Map<string, Set<Function>>();
|
||||
|
||||
if (!(window as any).G7Core) {
|
||||
(window as any).G7Core = {};
|
||||
}
|
||||
const g7 = (window as any).G7Core;
|
||||
|
||||
g7.componentEvent = {
|
||||
on: vi.fn((event: string, callback: Function) => {
|
||||
if (!listeners.has(event)) {
|
||||
listeners.set(event, new Set());
|
||||
}
|
||||
listeners.get(event)!.add(callback);
|
||||
return () => {
|
||||
listeners.get(event)?.delete(callback);
|
||||
};
|
||||
}),
|
||||
emit: vi.fn(),
|
||||
};
|
||||
g7.createLogger = vi.fn(() => ({
|
||||
log: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
}));
|
||||
});
|
||||
|
||||
vi.mock('browser-image-compression', () => ({
|
||||
default: vi.fn((file: File) => Promise.resolve(file)),
|
||||
}));
|
||||
|
||||
URL.createObjectURL = vi.fn(() => 'blob:mock-url');
|
||||
URL.revokeObjectURL = vi.fn();
|
||||
|
||||
describe('FileUploader - 개수 상한 초과 안내 (useFileUploader 훅)', () => {
|
||||
const defaultEndpoints = {
|
||||
upload: '/api/attachments',
|
||||
delete: '/api/attachments/:id',
|
||||
reorder: '/api/attachments/reorder',
|
||||
};
|
||||
|
||||
const STABLE_EMPTY_FILES: Attachment[] = [];
|
||||
const STABLE_EMPTY_ROLE_IDS: number[] = [];
|
||||
|
||||
function makeFileList(files: File[]): FileList {
|
||||
return {
|
||||
...files,
|
||||
length: files.length,
|
||||
item: (i: number) => files[i] ?? null,
|
||||
} as unknown as FileList;
|
||||
}
|
||||
|
||||
it('maxFiles 초과 시 onUploadError 로 안내하고 상한까지만 추가한다', async () => {
|
||||
const onUploadError = vi.fn();
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
useFileUploader({
|
||||
collection: 'test',
|
||||
maxFiles: 2,
|
||||
maxSize: 10,
|
||||
maxConcurrentUploads: 3,
|
||||
roleIds: STABLE_EMPTY_ROLE_IDS,
|
||||
autoUpload: false,
|
||||
initialFiles: STABLE_EMPTY_FILES,
|
||||
confirmBeforeRemove: false,
|
||||
onUploadError,
|
||||
endpoints: defaultEndpoints,
|
||||
})
|
||||
);
|
||||
|
||||
// 상한(2)보다 많은 3개 선택
|
||||
const files = [
|
||||
new File(['1'], 'a.png', { type: 'image/png' }),
|
||||
new File(['2'], 'b.png', { type: 'image/png' }),
|
||||
new File(['3'], 'c.png', { type: 'image/png' }),
|
||||
];
|
||||
|
||||
await act(async () => {
|
||||
await result.current.handleFiles(makeFileList(files));
|
||||
});
|
||||
|
||||
// 초과 안내 콜백 1회 (조용히 버리지 않음)
|
||||
expect(onUploadError).toHaveBeenCalledTimes(1);
|
||||
// 상한까지만 추가 (2개)
|
||||
expect(result.current.pendingFiles).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('상한 이내로 선택하면 onUploadError 를 발화하지 않는다 (오발화 없음)', async () => {
|
||||
const onUploadError = vi.fn();
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
useFileUploader({
|
||||
collection: 'test',
|
||||
maxFiles: 5,
|
||||
maxSize: 10,
|
||||
maxConcurrentUploads: 3,
|
||||
roleIds: STABLE_EMPTY_ROLE_IDS,
|
||||
autoUpload: false,
|
||||
initialFiles: STABLE_EMPTY_FILES,
|
||||
confirmBeforeRemove: false,
|
||||
onUploadError,
|
||||
endpoints: defaultEndpoints,
|
||||
})
|
||||
);
|
||||
|
||||
const files = [
|
||||
new File(['1'], 'a.png', { type: 'image/png' }),
|
||||
new File(['2'], 'b.png', { type: 'image/png' }),
|
||||
];
|
||||
|
||||
await act(async () => {
|
||||
await result.current.handleFiles(makeFileList(files));
|
||||
});
|
||||
|
||||
expect(onUploadError).not.toHaveBeenCalled();
|
||||
expect(result.current.pendingFiles).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user