feat(auth): 회원가입 시 휴대폰·전화번호 선택 입력 추가
마이페이지·관리자 회원 폼에는 이미 연락처 필드가 있으나 회원가입 폼에만 빠져 두 화면이 불일치했다. DB·모델·Resource는 기존 존재하므로 회원가입 경로에만 검증·저장·입력 UI를 연결한다. 연락처는 선택 항목이다.
This commit is contained in:
1 parent
eb0c72c32b
commit
cd11fc60ce
18 files changed
+363
-6
No files matched your search
@@ -6,6 +6,10 @@
|
||||
|
||||
## [1.0.4] - 2026-07-19
|
||||
|
||||
### Added
|
||||
|
||||
- 회원가입 화면에 휴대폰번호·전화번호 입력란을 추가했습니다. 두 항목 모두 선택 사항입니다.
|
||||
|
||||
### Fixed
|
||||
|
||||
#### 검색·봇 화면
|
||||
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* @file auth-register-contact-fields.test.tsx
|
||||
* @description 회원가입 폼 휴대폰/전화번호 필드 정합성 회귀 테스트
|
||||
*
|
||||
* 배경: 마이페이지 프로필 편집에는 휴대폰/전화 필드가 있으나 회원가입 폼에만 빠져 있어
|
||||
* 두 화면이 불일치했다. 회원가입에도 연락처(선택) 입력 필드를 추가한다.
|
||||
*
|
||||
* 검증 항목:
|
||||
* 1. name="mobile" / name="phone" Input 노드가 각각 존재 (선택 항목이므로 required 없음)
|
||||
* 2. 라벨/placeholder 가 auth 네임스페이스 다국어 키를 사용
|
||||
* 3. 각 필드에 per-field 에러 span 이 존재 (_local.errors?.mobile / phone)
|
||||
* 4. 에러 필터 화이트리스트(폼 필드 vs 플러그인 기여 에러 구분)에 mobile/phone 이 포함
|
||||
* → 누락 시 mobile/phone 검증 에러가 상단 목록과 필드 하단에 이중 표시되는 회귀 방지
|
||||
* 5. 마케팅/광고 수신 동의 문구·체크박스는 코어 회원가입 폼에 들어가지 않는다
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import registerForm from '../../layouts/partials/auth/_register_form.json';
|
||||
|
||||
type Node = {
|
||||
type?: string;
|
||||
name?: string;
|
||||
if?: string;
|
||||
props?: Record<string, any>;
|
||||
children?: Node[];
|
||||
iteration?: Record<string, any>;
|
||||
text?: string;
|
||||
comment?: string;
|
||||
};
|
||||
|
||||
function walk(input: Node | Node[] | undefined, visit: (node: Node) => void): void {
|
||||
if (!input) return;
|
||||
const nodes = Array.isArray(input) ? input : [input];
|
||||
for (const node of nodes) {
|
||||
visit(node);
|
||||
if (Array.isArray(node.children)) walk(node.children, visit);
|
||||
}
|
||||
}
|
||||
|
||||
function findInput(name: string): Node | undefined {
|
||||
let found: Node | undefined;
|
||||
walk(registerForm as Node, (node) => {
|
||||
if (node.type === 'basic' && node.name === 'Input' && node.props?.name === name) {
|
||||
found = node;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
describe('회원가입 폼 휴대폰/전화번호 필드', () => {
|
||||
describe('입력 필드 존재', () => {
|
||||
it('name="mobile" Input 이 존재한다', () => {
|
||||
expect(findInput('mobile')).toBeDefined();
|
||||
});
|
||||
|
||||
it('name="phone" Input 이 존재한다', () => {
|
||||
expect(findInput('phone')).toBeDefined();
|
||||
});
|
||||
|
||||
it('휴대폰/전화 필드는 선택 항목이므로 required 가 아니다', () => {
|
||||
expect(findInput('mobile')?.props?.required).toBeUndefined();
|
||||
expect(findInput('phone')?.props?.required).toBeUndefined();
|
||||
});
|
||||
|
||||
it('라벨/placeholder 가 auth 다국어 키를 사용한다', () => {
|
||||
expect(findInput('mobile')?.props?.placeholder).toBe('$t:auth.mobile_placeholder');
|
||||
expect(findInput('phone')?.props?.placeholder).toBe('$t:auth.phone_placeholder');
|
||||
});
|
||||
});
|
||||
|
||||
describe('per-field 에러 표시', () => {
|
||||
function hasErrorSpan(field: string): boolean {
|
||||
let found = false;
|
||||
walk(registerForm as Node, (node) => {
|
||||
if (
|
||||
node.type === 'basic' &&
|
||||
node.name === 'Span' &&
|
||||
typeof node.if === 'string' &&
|
||||
node.if.includes(`errors?.${field}`)
|
||||
) {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
it('mobile 에러 span 이 존재한다', () => {
|
||||
expect(hasErrorSpan('mobile')).toBe(true);
|
||||
});
|
||||
|
||||
it('phone 에러 span 이 존재한다', () => {
|
||||
expect(hasErrorSpan('phone')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('에러 필터 화이트리스트 (이중 표시 회귀 방지)', () => {
|
||||
it('폼 필드 화이트리스트에 mobile/phone 이 포함되어 있다', () => {
|
||||
const raw = JSON.stringify(registerForm);
|
||||
const matches = raw.match(/\['email'[^\]]*'agree_privacy'\]/g) ?? [];
|
||||
// 두 곳(상단 목록 if + iteration source) 모두에 존재해야 함
|
||||
expect(matches.length).toBeGreaterThanOrEqual(2);
|
||||
for (const list of matches) {
|
||||
expect(list).toContain("'mobile'");
|
||||
expect(list).toContain("'phone'");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('마케팅/광고 수신 동의 미포함 (코어 중립성)', () => {
|
||||
it('코어 회원가입 폼에 마케팅/광고 수신 관련 문구가 없다', () => {
|
||||
const raw = JSON.stringify(registerForm);
|
||||
expect(raw).not.toContain('marketing');
|
||||
expect(raw).not.toContain('광고');
|
||||
expect(raw).not.toContain('마케팅');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -20,6 +20,10 @@
|
||||
"name_placeholder": "Enter your name",
|
||||
"nickname": "Nickname",
|
||||
"nickname_placeholder": "Enter your nickname (optional)",
|
||||
"mobile": "Mobile",
|
||||
"mobile_placeholder": "Enter your mobile number (optional)",
|
||||
"phone": "Phone",
|
||||
"phone_placeholder": "Enter your phone number (optional)",
|
||||
"language": "Language",
|
||||
"language_select": "Select language",
|
||||
"language_ko": "한국어",
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
"name_placeholder": "이름을 입력하세요",
|
||||
"nickname": "닉네임",
|
||||
"nickname_placeholder": "닉네임을 입력하세요 (선택)",
|
||||
"mobile": "휴대폰번호",
|
||||
"mobile_placeholder": "휴대폰번호를 입력하세요 (선택)",
|
||||
"phone": "전화번호",
|
||||
"phone_placeholder": "전화번호를 입력하세요 (선택)",
|
||||
"language": "언어",
|
||||
"language_select": "언어 선택",
|
||||
"language_ko": "한국어",
|
||||
|
||||
@@ -68,12 +68,12 @@
|
||||
"comment": "비-form-field 에러 메시지 (identity / verification_token 등 plugin 기여 에러)를 추가 안내",
|
||||
"type": "basic",
|
||||
"name": "Ul",
|
||||
"if": "{{_local.errors && Object.keys(_local.errors).filter(function(k) { return ['email','password','password_confirmation','name','nickname','language','agree_terms','agree_privacy'].indexOf(k) === -1; }).length > 0}}",
|
||||
"if": "{{_local.errors && Object.keys(_local.errors).filter(function(k) { return ['email','password','password_confirmation','name','nickname','mobile','phone','language','agree_terms','agree_privacy'].indexOf(k) === -1; }).length > 0}}",
|
||||
"props": {
|
||||
"className": "mt-2 list-disc list-inside space-y-1"
|
||||
},
|
||||
"iteration": {
|
||||
"source": "Object.entries(_local.errors ?? {}).filter(function(entry) { return ['email','password','password_confirmation','name','nickname','language','agree_terms','agree_privacy'].indexOf(entry[0]) === -1; }).flatMap(function(entry) { return Array.isArray(entry[1]) ? entry[1] : [entry[1]]; })",
|
||||
"source": "Object.entries(_local.errors ?? {}).filter(function(entry) { return ['email','password','password_confirmation','name','nickname','mobile','phone','language','agree_terms','agree_privacy'].indexOf(entry[0]) === -1; }).flatMap(function(entry) { return Array.isArray(entry[1]) ? entry[1] : [entry[1]]; })",
|
||||
"item_var": "message"
|
||||
},
|
||||
"children": [
|
||||
@@ -314,6 +314,76 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "휴대폰번호 필드 (선택)",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": {
|
||||
"className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"
|
||||
},
|
||||
"text": "$t:auth.mobile"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Input",
|
||||
"props": {
|
||||
"type": "tel",
|
||||
"name": "mobile",
|
||||
"placeholder": "$t:auth.mobile_placeholder",
|
||||
"className": "w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
|
||||
"disabled": "{{_local?.isRegistering}}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"if": "{{_local.errors?.mobile}}",
|
||||
"props": {
|
||||
"className": "text-red-500 text-xs mt-1"
|
||||
},
|
||||
"text": "{{_local.errors?.mobile?.[0] ?? ''}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "전화번호 필드 (선택)",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": {
|
||||
"className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"
|
||||
},
|
||||
"text": "$t:auth.phone"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Input",
|
||||
"props": {
|
||||
"type": "tel",
|
||||
"name": "phone",
|
||||
"placeholder": "$t:auth.phone_placeholder",
|
||||
"className": "w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
|
||||
"disabled": "{{_local?.isRegistering}}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"if": "{{_local.errors?.phone}}",
|
||||
"props": {
|
||||
"className": "text-red-500 text-xs mt-1"
|
||||
},
|
||||
"text": "{{_local.errors?.phone?.[0] ?? ''}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "언어 설정 필드",
|
||||
"type": "basic",
|
||||
|
||||
Reference in new issue
Block a user