Skip to content

[Test/#269] metricsToKpis · METRIC_REGISTRY 단위 테스트 추가 - #316

Merged
Seojegyeong merged 1 commit into
developfrom
feature/#269
Jul 26, 2026
Merged

Seojegyeong merged 1 commit into
developfrom
feature/#269

Conversation

@Seojegyeong

@Seojegyeong Seojegyeong commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

🚨 관련 이슈

#269

✨ 변경사항

  • 🐞 BugFix Something isn't working
  • 💻 CrossBrowsing Browser compatibility
  • 🌏 Deploy Deploy
  • 🎨 Design Markup & styling
  • 📃 Docs Documentation writing and editing (README.md, etc.)
  • ✨ Feature Feature
  • 🔨 Refactor Code refactoring
  • ⚙️ Setting Development environment setup
  • ✅ Test Test related (storybook, jest, etc.)

✏️ 작업 내용

  • Vitest 환경 구축
  • metricRegistry.test.ts — 포맷 함수 단위 테스트 (32 케이스)
    • 통화 포맷 (Math.round 후 ₩ + 천 단위 콤마)
    • 비율 포맷 (toFixed(2)%)
    • delta 포맷 (Math.abs 적용으로 항상 절댓값, 부호는 direction으로 분리)
    • getMetricKpiTitle: conversion만 kpiLabel 사용, 나머지는 label 사용
  • metricsToKpis.test.ts — API 응답 → KPI Props 변환 단위 테스트 (19 케이스)
    • 4개 KPI 순서(clicks / impressions / conversion / roas) 및 title / value / trend 검증
    • 경계값: delta = 0 → direction "up", clicks = 0 → value "0"
  • CI 파이프라인에 단위 테스트 단계 추가 (lint → test → build)

🧪 테스트 결과

 RUN  v4.1.10 /Users/Project/whereyouad_FE

 ✓ src/utils/dashboard/__tests__/metricsToKpis.test.ts (19 tests) 39ms
 ✓ src/utils/dashboard/__tests__/metricRegistry.test.ts (32 tests) 38ms

 Test Files  2 passed (2)
      Tests  51 passed (51)
   Start at  21:40:30
   Duration  244ms (transform 87ms, setup 0ms, import 117ms, tests 77ms, environment 0ms)

😅 미완성 작업

N/A

📢 논의 사항 및 참고 사항

N/A

💬 리뷰어 가이드 (P-Rules)
P1: 필수 반영 (Critical) - 버그 가능성, 컨벤션 위반. 해결 전 머지 불가.
P2: 적극 권장 (Recommended) - 더 나은 대안 제시. 가급적 반영 권장.
P3: 제안 (Suggestion) - 아이디어 공유. 반영 여부는 드라이버 자율.
P4: 단순 확인/칭찬 (Nit) - 사소한 오타, 칭찬 등 피드백.

Summary by CodeRabbit

  • 테스트
    • 대시보드 KPI 지표의 라벨, 숫자·통화·퍼센트 포맷 및 변화율 표시를 검증하는 단위 테스트를 추가했습니다.
    • 클릭수, 노출수, 전환수, ROAS 등 주요 KPI의 순서와 값 매핑을 검증합니다.
    • 양수·음수·0 변화율, 0 값, 소수점 반올림 등 경계 조건을 테스트합니다.

- Vitest 환경 구축 (vitest.config.ts, @/* alias, src/__tests__ 범위 한정)
- METRIC_REGISTRY 포맷 함수 검증: 통화(₩ 올림), percent(toFixed2), delta(Math.abs)
- metricsToKpis: title/value/trend.direction/trend.value 및 경계값(delta=0, clicks=0)
- CI 파이프라인에 unit test 단계 추가 (lint → test → build)
@Seojegyeong
Seojegyeong requested review from YermIm and jjjsun July 26, 2026 12:27
@Seojegyeong Seojegyeong self-assigned this Jul 26, 2026
@Seojegyeong Seojegyeong added the ✅ Test test 관련(storybook, jest...) label Jul 26, 2026
@Seojegyeong Seojegyeong linked an issue Jul 26, 2026 that may be closed by this pull request
14 tasks
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

대시보드 metric registry와 metricsToKpis 변환 유틸에 Vitest 단위 테스트를 추가했다. KPI 포맷, 제목·바인딩 매핑, 추세 방향과 경계 조건을 검증한다.

Changes

대시보드 KPI 테스트

Layer / File(s) Summary
Metric registry 계약 검증
src/utils/dashboard/__tests__/metricRegistry.test.ts
metric별 라벨, 값·delta 포맷, KPI 제목 매핑, overview 바인딩 개수와 순서를 검증한다.
Metrics-to-KPI 변환 검증
src/utils/dashboard/__tests__/metricsToKpis.test.ts
4개 KPI의 제목·값·추세 포맷과 부호 처리, 0 delta, 0 clicks, ROAS 반올림 경계 조건을 검증한다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • #269metricsToKpisMETRIC_REGISTRY의 Vitest 단위 테스트 추가 목표를 직접 다룬다.

Suggested reviewers: jjjsun, yermim

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed 제목이 metricsToKpis와 METRIC_REGISTRY 단위 테스트 추가라는 핵심 변경을 간결하게 잘 요약합니다.
Description check ✅ Passed 이슈, 변경사항, 작업 내용, 미완성 작업, 논의 사항, 테스트 결과가 포함되어 템플릿을 대부분 충족합니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/#269

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

📚 Storybook 배포 완료

항목 링크
📖 Storybook https://69a147b60a56365d9e2185ef-okoijqkfxz.chromatic.com/
🔍 Chromatic https://www.chromatic.com/build?appId=69a147b60a56365d9e2185ef&number=429

@jjjsun jjjsun left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4: 확인했습니다!

@Seojegyeong
Seojegyeong merged commit 1e56d5f into develop Jul 26, 2026
3 checks passed
@Seojegyeong
Seojegyeong deleted the feature/#269 branch July 26, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✅ Test test 관련(storybook, jest...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ [Feature] metricsToKpis + METRIC_REGISTRY 단위 테스트 추가

2 participants