fix(tosspayments,templates,core): 결제수단 체크박스 라벨 미표시·저장 실패 수정

Checkbox 는 label prop 을 렌더하지 않는다(부모 Label 이 표시 담당). 그 prop 에만
의존해 결제수단 9종의 라벨이 화면에서 전부 비어 있었다. Label 로 감싸고 텍스트를
형제 Span 으로 분리했다 — 라벨 클릭 토글과 접근성 이름도 함께 확보된다.

수정 중 저장 결함을 함께 발견했다. 폼 자동바인딩은 값이 boolean 일 때만 checked 로
붙고, null 이면 value 분기로 떨어져 빈 문자열을 전송한다. 서버가 그것을 null 로
저장하면 기본값(false)을 덮어 화면에서 다시 켤 수 없게 고착된다. initLocal 로는
막을 수 없어(shallow 는 form 객체를 교체하고, deep 은 source 의 null 을 그대로
반영) 레이아웃이 boolean 을 직접 보장하도록 했다 — autoBinding:false + checked 강제
+ change 액션이 $event.target.checked 를 기록.

같은 원인으로 편집기 팔레트도 라벨 없는 체크박스를 삽입하고 있어 함께 고쳤다.

회귀 방어: 레이아웃/팔레트 계약 테스트, 엔진 동작(isCheckedBinding·deepMergeState)
고정, 저장 페이로드가 boolean 인지 검사하는 E2E, audit 룰
layout-checkbox-label-and-boolean(label prop=error, 자동바인딩 의존=warn).
This commit is contained in:
HeuJung committed 2026-08-06 13:27:45 +09:00
1 parent faa79b0ae1
commit 3f2674f1a7
8 files changed
+697 -40

No files matched your search

@@ -61,6 +61,62 @@ describe('plugin_settings — 결제 방식 섹션', () => {
expect(names).toHaveLength(9);
});
it('결제수단 9종의 라벨이 Label 래핑 + Span 텍스트로 렌더된다', () => {
// Checkbox 컴포넌트는 label prop 을 렌더하지 않는다 (부모 Label 이 처리).
// label prop 에만 의존하면 화면에 라벨이 표시되지 않으므로 사용을 금지한다.
const checkboxes = collect(pluginSettingsLayout, (n) => n.name === 'Checkbox');
const withLabelProp = checkboxes.filter((n) => (n.props as Record<string, unknown>)?.label !== undefined);
expect(withLabelProp).toHaveLength(0);
// 각 method_* 체크박스는 Label 로 감싸이고 형제 Span 이 라벨 텍스트를 갖는다.
const wrappers = collect(pluginSettingsLayout, (n) => {
if (n.name !== 'Label' || !Array.isArray(n.children)) return false;
const children = n.children as Record<string, unknown>[];
return children.some((c) => c.name === 'Checkbox' && nameOf(c).startsWith('method_'));
});
expect(wrappers).toHaveLength(9);
for (const wrapper of wrappers) {
const children = wrapper.children as Record<string, unknown>[];
const checkbox = children.find((c) => c.name === 'Checkbox')!;
const span = children.find((c) => c.name === 'Span');
expect(span, `${nameOf(checkbox)} 라벨 Span 누락`).toBeDefined();
expect(String(span!.text)).toBe(`$t:sirsoft-tosspayments.settings.${nameOf(checkbox)}`);
}
});
it('결제수단 체크박스는 boolean 저장을 보장한다 (autoBinding 우회 + checked 강제 + change 액션)', () => {
// 엔진의 폼 자동바인딩은 현재 값이 boolean 일 때만 checked 바인딩을 쓴다
// (DynamicRenderer `isCheckedBinding`: typeof currentValue === 'boolean').
// 저장값이 null/undefined 면 value 바인딩으로 떨어져 빈 문자열('')이 전송되고,
// 서버가 그것을 null 로 저장하면 defaults(false) 를 덮어 영구 고착된다.
// → 레이아웃이 boolean 을 직접 보장해야 한다.
const checkboxes = collect(pluginSettingsLayout, (n) => n.name === 'Checkbox' && nameOf(n).startsWith('method_'));
expect(checkboxes).toHaveLength(9);
for (const box of checkboxes) {
const name = nameOf(box);
const props = (box.props ?? {}) as Record<string, unknown>;
// 자동바인딩의 value 분기 개입을 차단한다.
expect(props.autoBinding, `${name}: autoBinding=false 누락`).toBe(false);
// checked 는 !! 로 boolean 강제 — 저장값이 null 이어도 false 로 렌더된다.
expect(String(props.checked), `${name}: checked 가 boolean 강제(!!)가 아님`).toBe(
`{{!!_local.form?.${name}}}`
);
// change 액션이 $event.target.checked(항상 boolean)를 직접 기록한다.
const actions = (box.actions ?? []) as Record<string, unknown>[];
const change = actions.find((a) => a.type === 'change');
expect(change, `${name}: change 액션 누락`).toBeDefined();
const params = (change!.params ?? {}) as Record<string, unknown>;
expect(params[`form.${name}`], `${name}: boolean 이 아닌 값을 기록`).toBe('{{$event.target.checked}}');
expect(params.hasChanges, `${name}: hasChanges 미설정 — 저장 버튼이 비활성 유지됨`).toBe(true);
}
});
it('결제수단 그룹은 order_sheet_mode 가 켜졌을 때만 노출된다 (if)', () => {
const group = findById(pluginSettingsLayout, 'enabled_methods_group');
expect(group).toBeDefined();
@@ -705,75 +705,309 @@
"children": [
{
"type": "basic",
"name": "Checkbox",
"name": "Label",
"props": {
"name": "method_card",
"label": "$t:sirsoft-tosspayments.settings.method_card"
}
"className": "flex items-center gap-2 cursor-pointer text-sm text-gray-700 dark:text-gray-300"
},
"children": [
{
"type": "basic",
"name": "Checkbox",
"props": {
"name": "method_card",
"autoBinding": false,
"checked": "{{!!_local.form?.method_card}}"
},
"actions": [
{
"type": "change",
"handler": "setState",
"params": {
"target": "local",
"form.method_card": "{{$event.target.checked}}",
"hasChanges": true
}
}
]
},
{
"type": "basic",
"name": "Span",
"text": "$t:sirsoft-tosspayments.settings.method_card"
}
]
},
{
"type": "basic",
"name": "Checkbox",
"name": "Label",
"props": {
"name": "method_virtual_account",
"label": "$t:sirsoft-tosspayments.settings.method_virtual_account"
}
"className": "flex items-center gap-2 cursor-pointer text-sm text-gray-700 dark:text-gray-300"
},
"children": [
{
"type": "basic",
"name": "Checkbox",
"props": {
"name": "method_virtual_account",
"autoBinding": false,
"checked": "{{!!_local.form?.method_virtual_account}}"
},
"actions": [
{
"type": "change",
"handler": "setState",
"params": {
"target": "local",
"form.method_virtual_account": "{{$event.target.checked}}",
"hasChanges": true
}
}
]
},
{
"type": "basic",
"name": "Span",
"text": "$t:sirsoft-tosspayments.settings.method_virtual_account"
}
]
},
{
"type": "basic",
"name": "Checkbox",
"name": "Label",
"props": {
"name": "method_transfer",
"label": "$t:sirsoft-tosspayments.settings.method_transfer"
}
"className": "flex items-center gap-2 cursor-pointer text-sm text-gray-700 dark:text-gray-300"
},
"children": [
{
"type": "basic",
"name": "Checkbox",
"props": {
"name": "method_transfer",
"autoBinding": false,
"checked": "{{!!_local.form?.method_transfer}}"
},
"actions": [
{
"type": "change",
"handler": "setState",
"params": {
"target": "local",
"form.method_transfer": "{{$event.target.checked}}",
"hasChanges": true
}
}
]
},
{
"type": "basic",
"name": "Span",
"text": "$t:sirsoft-tosspayments.settings.method_transfer"
}
]
},
{
"type": "basic",
"name": "Checkbox",
"name": "Label",
"props": {
"name": "method_mobile_phone",
"label": "$t:sirsoft-tosspayments.settings.method_mobile_phone"
}
"className": "flex items-center gap-2 cursor-pointer text-sm text-gray-700 dark:text-gray-300"
},
"children": [
{
"type": "basic",
"name": "Checkbox",
"props": {
"name": "method_mobile_phone",
"autoBinding": false,
"checked": "{{!!_local.form?.method_mobile_phone}}"
},
"actions": [
{
"type": "change",
"handler": "setState",
"params": {
"target": "local",
"form.method_mobile_phone": "{{$event.target.checked}}",
"hasChanges": true
}
}
]
},
{
"type": "basic",
"name": "Span",
"text": "$t:sirsoft-tosspayments.settings.method_mobile_phone"
}
]
},
{
"type": "basic",
"name": "Checkbox",
"name": "Label",
"props": {
"name": "method_tosspay",
"label": "$t:sirsoft-tosspayments.settings.method_tosspay"
}
"className": "flex items-center gap-2 cursor-pointer text-sm text-gray-700 dark:text-gray-300"
},
"children": [
{
"type": "basic",
"name": "Checkbox",
"props": {
"name": "method_tosspay",
"autoBinding": false,
"checked": "{{!!_local.form?.method_tosspay}}"
},
"actions": [
{
"type": "change",
"handler": "setState",
"params": {
"target": "local",
"form.method_tosspay": "{{$event.target.checked}}",
"hasChanges": true
}
}
]
},
{
"type": "basic",
"name": "Span",
"text": "$t:sirsoft-tosspayments.settings.method_tosspay"
}
]
},
{
"type": "basic",
"name": "Checkbox",
"name": "Label",
"props": {
"name": "method_kakaopay",
"label": "$t:sirsoft-tosspayments.settings.method_kakaopay"
}
"className": "flex items-center gap-2 cursor-pointer text-sm text-gray-700 dark:text-gray-300"
},
"children": [
{
"type": "basic",
"name": "Checkbox",
"props": {
"name": "method_kakaopay",
"autoBinding": false,
"checked": "{{!!_local.form?.method_kakaopay}}"
},
"actions": [
{
"type": "change",
"handler": "setState",
"params": {
"target": "local",
"form.method_kakaopay": "{{$event.target.checked}}",
"hasChanges": true
}
}
]
},
{
"type": "basic",
"name": "Span",
"text": "$t:sirsoft-tosspayments.settings.method_kakaopay"
}
]
},
{
"type": "basic",
"name": "Checkbox",
"name": "Label",
"props": {
"name": "method_naverpay",
"label": "$t:sirsoft-tosspayments.settings.method_naverpay"
}
"className": "flex items-center gap-2 cursor-pointer text-sm text-gray-700 dark:text-gray-300"
},
"children": [
{
"type": "basic",
"name": "Checkbox",
"props": {
"name": "method_naverpay",
"autoBinding": false,
"checked": "{{!!_local.form?.method_naverpay}}"
},
"actions": [
{
"type": "change",
"handler": "setState",
"params": {
"target": "local",
"form.method_naverpay": "{{$event.target.checked}}",
"hasChanges": true
}
}
]
},
{
"type": "basic",
"name": "Span",
"text": "$t:sirsoft-tosspayments.settings.method_naverpay"
}
]
},
{
"type": "basic",
"name": "Checkbox",
"name": "Label",
"props": {
"name": "method_payco",
"label": "$t:sirsoft-tosspayments.settings.method_payco"
}
"className": "flex items-center gap-2 cursor-pointer text-sm text-gray-700 dark:text-gray-300"
},
"children": [
{
"type": "basic",
"name": "Checkbox",
"props": {
"name": "method_payco",
"autoBinding": false,
"checked": "{{!!_local.form?.method_payco}}"
},
"actions": [
{
"type": "change",
"handler": "setState",
"params": {
"target": "local",
"form.method_payco": "{{$event.target.checked}}",
"hasChanges": true
}
}
]
},
{
"type": "basic",
"name": "Span",
"text": "$t:sirsoft-tosspayments.settings.method_payco"
}
]
},
{
"type": "basic",
"name": "Checkbox",
"name": "Label",
"props": {
"name": "method_samsungpay",
"label": "$t:sirsoft-tosspayments.settings.method_samsungpay"
}
"className": "flex items-center gap-2 cursor-pointer text-sm text-gray-700 dark:text-gray-300"
},
"children": [
{
"type": "basic",
"name": "Checkbox",
"props": {
"name": "method_samsungpay",
"autoBinding": false,
"checked": "{{!!_local.form?.method_samsungpay}}"
},
"actions": [
{
"type": "change",
"handler": "setState",
"params": {
"target": "local",
"form.method_samsungpay": "{{$event.target.checked}}",
"hasChanges": true
}
}
]
},
{
"type": "basic",
"name": "Span",
"text": "$t:sirsoft-tosspayments.settings.method_samsungpay"
}
]
}
]
},