fix(cart): 장바구니 전체 선택 개수 최초 로딩 미표시 수정
표시식이 selectedCount 를 fallback 없이 보간했다. 이 키는 체크박스 change 핸들러에서만 기록되므로 최초 마운트 구간에 undefined 이고, 엔진이 undefined 를 예외 없이 빈 문자열로 서식해 (/27) 로 보였다. 선택 상태의 SSoT 인 selectedItems 파생으로 교체해 주문 요약과 계산 방식을 일치시켰다. 같은 결함 클래스(초기값 없는 키를 옵셔널 없이 하위 접근) 28곳을 함께 방어하고, 3조건 동시 충족만 잡는 audit 룰로 codify 했다. 브라우저 실측(T9)에서 다운로드 이력 모달의 iteration 문자열 선언(매 렌더 TypeError)·미존재 아이콘명·정적 id 중복 3종을 추가로 발견해 정정했다. 공개 이슈: gnuboard/g7
This commit is contained in:
1 parent
95957bb167
commit
7765695339
25 files changed
+839
-99
No files matched your search
@@ -10,6 +10,9 @@
|
||||
|
||||
- 언어/통화 설정에서 기본 제공 통화(달러·엔·위안·유로)를 삭제해도 저장 직후 다시 나타나던 문제를 수정했습니다. 삭제한 통화는 설정 화면과 쇼핑몰 화면 양쪽에서 유지되며, 통화 추가로 다시 등록하면 복원됩니다. 사용 중지된 통화를 표시 통화로 갖고 있던 구매자의 주문은 기본 통화로 안전하게 진행됩니다. (#91 @koojunho 님께서 제보해주셨습니다.)
|
||||
- 통화를 삭제한 뒤 그 통화로 결제된 과거 주문의 금액 표기가 달라지던 문제를 수정했습니다. 주문·환불 금액의 소수 자릿수는 주문 시점 기준을 유지하므로, 엔화처럼 소수점을 쓰지 않는 통화가 `¥14,835.00` 으로 바뀌거나 소수점 이하 자릿수가 많은 통화의 표시 금액이 잘리지 않습니다. (#91 @koojunho 님께서 제보해주셨습니다.)
|
||||
- 관리자 엑셀 다운로드 관리의 다운로드 이력 모달에서, 이력 항목이 아직 선택되지 않은 순간에 파일 정보·상태 배지가 비정상적으로 처리되던 문제를 보완했습니다. 항목을 선택한 뒤의 표시는 종전과 동일합니다.
|
||||
- 같은 모달의 "다운로드 기록" 목록이 항상 비어 보이던 문제를 수정했습니다. 이제 누가 언제 몇 번째로 내려받았는지 기록이 표시됩니다.
|
||||
- 같은 모달의 "처리중"·"실패"·"만료" 상태 배지에서 아이콘이 표시되지 않던 문제를 수정했습니다.
|
||||
|
||||
## [1.1.0] - 2026-08-10
|
||||
|
||||
|
||||
+10
-4
@@ -97,11 +97,17 @@ describe('B2 — 주문상세 모달 상품표 카드형 전환', () => {
|
||||
const cancel = load('partials/admin_ecommerce_order_detail/_modal_cancel_order.json');
|
||||
const batch = load('partials/admin_ecommerce_order_detail/_modal_batch_change_confirm.json');
|
||||
|
||||
const unitPrice = collect(
|
||||
// 금액 노드는 서버가 통화까지 포함해 서식한 `*_formatted` 를 그대로 출력한다.
|
||||
// (한때 `원` 리터럴로 이 노드를 찾았으나 통화 하드코딩 제거 후 선택자가 아무것도 못 찾아
|
||||
// `cls(undefined)` 를 단언하는 빈 가드가 되어 있었다 — 선택자를 서식 필드 기준으로 고정한다)
|
||||
const unitPrices = collect(
|
||||
cancel,
|
||||
(n) => typeof n.text === 'string' && n.text.includes('unit_price') && n.text.includes('원'),
|
||||
)[0];
|
||||
expect(cls(unitPrice)).toContain('whitespace-nowrap');
|
||||
(n) => typeof n.text === 'string' && n.text.includes('unit_price_formatted'),
|
||||
);
|
||||
expect(unitPrices.length, '단가 표시 노드를 찾지 못했다').toBeGreaterThan(0);
|
||||
for (const node of unitPrices) {
|
||||
expect(cls(node)).toContain('whitespace-nowrap');
|
||||
}
|
||||
|
||||
const batchAmounts = collect(
|
||||
batch,
|
||||
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* @file excel-download-history-modal-fallback.test.tsx
|
||||
* @description 엑셀 다운로드 이력 모달의 미선택 상태 표시 가드 (공개 이슈 #92 동일 결함 클래스)
|
||||
*
|
||||
* 결함 클래스: 부모 레이아웃 state 에 `null` 로만 선언된 키를 옵셔널 체이닝 없이 하위 접근하면,
|
||||
* 그 키를 채우는 유일한 지점(행 클릭 setState)이 아직 실행되지 않은 구간에서 표시가 비거나
|
||||
* 조건식이 예외로 떨어진다. `admin_ecommerce_excel_download_index.json` 의 `selectedItem` 이
|
||||
* 그 형태이고, 이 모달에는 selectedItem 을 검사하는 `if` 가드가 없다.
|
||||
*
|
||||
* 정정: 모달의 모든 `selectedItem` 하위 접근에 `?.` + 표시식 폴백(`?? ''`, count 인자는 `?? 0`)을 부여한다.
|
||||
* 값이 채워진 뒤의 출력은 이전과 바이트 동일하므로 기능 변화는 없다.
|
||||
*
|
||||
* @vitest-environment jsdom
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import downloadHistoryModal from '../../../layouts/admin/partials/admin_ecommerce_excel_download_index/_modal_download_history.json';
|
||||
import excelDownloadIndex from '../../../layouts/admin/admin_ecommerce_excel_download_index.json';
|
||||
|
||||
/**
|
||||
* JSON 트리에서 특정 문자열을 포함하는 문자열 값을 모두 수집합니다.
|
||||
*
|
||||
* @param node 순회 시작 노드
|
||||
* @param needle 찾을 부분 문자열
|
||||
* @returns 매칭된 문자열 값 목록
|
||||
*/
|
||||
function collectStringsContaining(node: unknown, needle: string): string[] {
|
||||
const out: string[] = [];
|
||||
const walk = (n: unknown): void => {
|
||||
if (Array.isArray(n)) {
|
||||
n.forEach(walk);
|
||||
return;
|
||||
}
|
||||
if (!n || typeof n !== 'object') return;
|
||||
const obj = n as Record<string, unknown>;
|
||||
for (const v of Object.values(obj)) {
|
||||
if (typeof v === 'string' && v.includes(needle)) out.push(v);
|
||||
}
|
||||
Object.values(obj).forEach(walk);
|
||||
};
|
||||
walk(node);
|
||||
return out;
|
||||
}
|
||||
|
||||
const refs = collectStringsContaining(downloadHistoryModal, 'selectedItem');
|
||||
|
||||
describe('_modal_download_history.json — selectedItem 표시 가드', () => {
|
||||
/**
|
||||
* @scenario selection_state=unselected
|
||||
* @effects history_modal_display_guarded
|
||||
*/
|
||||
it('부모 레이아웃이 selectedItem 을 null 로만 시드한다 (전제 확인)', () => {
|
||||
const state = (excelDownloadIndex as any).state ?? {};
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(state, 'selectedItem'),
|
||||
'selectedItem 시드가 사라졌다면 이 테스트의 전제를 재검토할 것'
|
||||
).toBe(true);
|
||||
expect(state.selectedItem).toBeNull();
|
||||
});
|
||||
|
||||
/**
|
||||
* @scenario selection_state=unselected
|
||||
* @effects history_modal_display_guarded
|
||||
*/
|
||||
it('selectedItem 하위 접근은 전부 옵셔널 체이닝을 쓴다', () => {
|
||||
expect(refs.length, 'selectedItem 참조를 찾지 못했다').toBeGreaterThan(0);
|
||||
const unguarded = refs.filter((r) => /selectedItem\.[A-Za-z_]/.test(r));
|
||||
expect(
|
||||
unguarded,
|
||||
`selectedItem 뒤에 '?.' 없는 역참조: ${unguarded.join(' | ')}`
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
/**
|
||||
* 다운로드 기록 목록이 문자열 형태 `"iteration": "{{...}}"` 로 선언되어 있어
|
||||
* 엔진이 `iteration.source` 를 읽지 못하고 매 렌더마다 TypeError 로 떨어졌다
|
||||
* (목록이 통째로 비어 보임 — 브라우저 실측에서 발견).
|
||||
*
|
||||
* @scenario selection_state=selected
|
||||
* @effects history_list_renders
|
||||
*/
|
||||
it('다운로드 기록 iteration 이 source/item_var/index_var 객체 형태다', () => {
|
||||
const iterations: unknown[] = [];
|
||||
const walk = (n: unknown): void => {
|
||||
if (Array.isArray(n)) { n.forEach(walk); return; }
|
||||
if (!n || typeof n !== 'object') return;
|
||||
const obj = n as Record<string, unknown>;
|
||||
if ('iteration' in obj) iterations.push(obj.iteration);
|
||||
Object.values(obj).forEach(walk);
|
||||
};
|
||||
walk(downloadHistoryModal);
|
||||
|
||||
expect(iterations.length, 'iteration 선언을 찾지 못했다').toBeGreaterThan(0);
|
||||
for (const it of iterations) {
|
||||
expect(typeof it, `문자열 형태 iteration 은 엔진이 해석하지 못한다: ${String(it)}`).toBe('object');
|
||||
const cfg = it as Record<string, unknown>;
|
||||
expect(typeof cfg.source).toBe('string');
|
||||
expect(cfg.item_var).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @scenario selection_state=selected
|
||||
* @effects history_modal_display_guarded
|
||||
*/
|
||||
it('표시식(text)은 값 부재 시 폴백을 갖는다', () => {
|
||||
const textRefs: string[] = [];
|
||||
const walk = (n: unknown): void => {
|
||||
if (Array.isArray(n)) {
|
||||
n.forEach(walk);
|
||||
return;
|
||||
}
|
||||
if (!n || typeof n !== 'object') return;
|
||||
const obj = n as Record<string, unknown>;
|
||||
if (typeof obj.text === 'string' && obj.text.includes('selectedItem')) {
|
||||
textRefs.push(obj.text);
|
||||
}
|
||||
Object.values(obj).forEach(walk);
|
||||
};
|
||||
walk(downloadHistoryModal);
|
||||
|
||||
// 개수를 고정한다 — `> 0` 만 두면 표시식이 삭제돼도 남은 것들이 폴백을 갖는 한 통과한다.
|
||||
// 현재 6건: file_content / category_name / created_date / expire_date / download_count /
|
||||
// download_history.length (마지막 1건은 원래부터 가드가 있어 #92 수정 대상 5건에 포함되지 않는다)
|
||||
expect(textRefs.length, `selectedItem 표시식 개수 변동: ${textRefs.join(' | ')}`).toBe(6);
|
||||
for (const t of textRefs) {
|
||||
expect(t, `폴백 없는 표시식: ${t}`).toMatch(/\?\?\s*('{2}|0)/);
|
||||
}
|
||||
});
|
||||
});
|
||||
+24
-20
@@ -41,7 +41,7 @@
|
||||
"props": {
|
||||
"className": "text-primary text-right"
|
||||
},
|
||||
"text": "{{_local.selectedItem.file_content}}"
|
||||
"text": "{{_local.selectedItem?.file_content ?? ''}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -57,7 +57,7 @@
|
||||
"props": {
|
||||
"className": "text-primary text-right"
|
||||
},
|
||||
"text": "{{_local.selectedItem.category_name}}"
|
||||
"text": "{{_local.selectedItem?.category_name ?? ''}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -77,7 +77,7 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"condition": "{{_local.selectedItem.status === 'completed'}}",
|
||||
"condition": "{{_local.selectedItem?.status === 'completed'}}",
|
||||
"props": {
|
||||
"className": "badge-status badge-status-success"
|
||||
},
|
||||
@@ -87,7 +87,7 @@
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "check-circle",
|
||||
"className": "w-3 h-3"
|
||||
"className": "text-xs"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -100,7 +100,7 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"condition": "{{_local.selectedItem.status === 'processing'}}",
|
||||
"condition": "{{_local.selectedItem?.status === 'processing'}}",
|
||||
"props": {
|
||||
"className": "badge-status badge-status-processing"
|
||||
},
|
||||
@@ -109,8 +109,8 @@
|
||||
"type": "basic",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "loader",
|
||||
"className": "w-3 h-3 animate-spin"
|
||||
"name": "spinner",
|
||||
"className": "text-xs animate-spin"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -123,7 +123,7 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"condition": "{{_local.selectedItem.status === 'failed'}}",
|
||||
"condition": "{{_local.selectedItem?.status === 'failed'}}",
|
||||
"props": {
|
||||
"className": "badge-status badge-status-error"
|
||||
},
|
||||
@@ -132,8 +132,8 @@
|
||||
"type": "basic",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "alert-circle",
|
||||
"className": "w-3 h-3"
|
||||
"name": "circle-exclamation",
|
||||
"className": "text-xs"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -146,7 +146,7 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"condition": "{{_local.selectedItem.status === 'expired'}}",
|
||||
"condition": "{{_local.selectedItem?.status === 'expired'}}",
|
||||
"props": {
|
||||
"className": "badge-status badge-status-expired"
|
||||
},
|
||||
@@ -155,8 +155,8 @@
|
||||
"type": "basic",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "file-text",
|
||||
"className": "w-3 h-3"
|
||||
"name": "file-lines",
|
||||
"className": "text-xs"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -182,7 +182,7 @@
|
||||
"props": {
|
||||
"className": "text-primary text-right"
|
||||
},
|
||||
"text": "{{_local.selectedItem.created_date}}"
|
||||
"text": "{{_local.selectedItem?.created_date ?? ''}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -198,7 +198,7 @@
|
||||
"props": {
|
||||
"className": "text-primary text-right"
|
||||
},
|
||||
"text": "{{_local.selectedItem.expire_date}}"
|
||||
"text": "{{_local.selectedItem?.expire_date ?? ''}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -214,7 +214,7 @@
|
||||
"props": {
|
||||
"className": "text-primary text-right font-medium"
|
||||
},
|
||||
"text": "$t:sirsoft-ecommerce.admin.excel_download.modal.download_history.download_count|count={{_local.selectedItem.download_count}}"
|
||||
"text": "$t:sirsoft-ecommerce.admin.excel_download.modal.download_history.download_count|count={{_local.selectedItem?.download_count ?? 0}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -259,10 +259,14 @@
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "history_item",
|
||||
"id": "history_item_{{index}}",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"iteration": "{{_local.selectedItem?.download_history ?? []}}",
|
||||
"iteration": {
|
||||
"source": "{{_local.selectedItem?.download_history ?? []}}",
|
||||
"item_var": "item",
|
||||
"index_var": "index"
|
||||
},
|
||||
"props": {
|
||||
"className": "admin-card mb-3"
|
||||
},
|
||||
@@ -286,7 +290,7 @@
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "user",
|
||||
"className": "w-4 h-4"
|
||||
"className": "text-base"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -329,7 +333,7 @@
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "calendar",
|
||||
"className": "w-3 h-3"
|
||||
"className": "text-xs"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
feature: 엑셀 다운로드 이력 모달의 선택 항목 표시 가드
|
||||
|
||||
description: |
|
||||
관리자 "엑셀 다운로드 관리" 화면의 다운로드 이력 모달은 목록에서 고른 항목(`_local.selectedItem`)의
|
||||
파일 내용·분류·생성일·만료일·다운로드 횟수를 표시한다. 이 키는 부모 레이아웃이 `null` 로만 시드하고
|
||||
행 클릭 시에만 채워지므로, 아직 아무 행도 고르지 않은 구간이 항상 존재한다.
|
||||
|
||||
수정 이력 (공개 이슈 #92 와 동일한 결함 클래스):
|
||||
- 모든 표시식이 `{{_local.selectedItem.<field>}}` 형태로 옵셔널 체이닝이 없었고,
|
||||
모달에 selectedItem 을 검사하는 `if` 가드도 없었다. 상태 배지의 조건식
|
||||
(`selectedItem.status === '...'`)은 값 부재 구간에서 조건 평가가 실패해
|
||||
경고 로그를 남기며 false 로 떨어지고 있었다.
|
||||
- 모든 하위 접근에 `?.` 를, 표시식에 폴백(`?? ''`, 횟수는 `?? 0`)을 부여했다.
|
||||
값이 채워진 뒤의 출력은 이전과 동일하므로 기능 변화는 없다.
|
||||
- 브라우저 실측에서 별개 결함이 함께 드러났다 — "다운로드 기록" 목록의 iteration 이
|
||||
문자열 형태로 선언되어 엔진이 source 를 읽지 못하고 매 렌더마다 예외로 떨어졌다.
|
||||
목록이 통째로 비어 보이던 문제이며, 객체 형태(source/item_var/index_var)로 정정했다.
|
||||
- 상태 배지 3종의 아이콘 이름이 Font Awesome Free 에 없는 값이라 빈 글리프로 렌더됐다.
|
||||
|
||||
axes:
|
||||
selection_state: [unselected, selected] # 이력 행 미선택 / 선택
|
||||
|
||||
effects:
|
||||
- history_modal_display_guarded # 값 부재 구간에서 조건 평가 실패·표시 공백이 발생하지 않음
|
||||
- history_list_renders # 다운로드 기록 목록이 실제로 렌더된다 (iteration 선언 형태)
|
||||
|
||||
test_files:
|
||||
- modules/_bundled/sirsoft-ecommerce/resources/js/__tests__/layouts/excel-download-history-modal-fallback.test.tsx
|
||||
|
||||
validation:
|
||||
audit_rule: frontend-change-requires-e2e
|
||||
browser_check: Chrome MCP # 관리자 화면 실측(정밀 점검 매트릭스 T9)으로 브라우저 검증 대체
|
||||
note: |
|
||||
레이아웃 JSON 은 헤더 주석을 가질 수 없어 `e2e:allow` 를 붙일 수 없다. 표시식의 옵셔널/폴백
|
||||
유무는 정적 구조로 판정 가능하므로 레이아웃 정적 가드 테스트가 두 selection_state 를 모두
|
||||
떠받치고, 실제 모달 열기 전/후 화면은 Chrome MCP 정밀 점검이 확인한다.
|
||||
Reference in new issue
Block a user