| name | test-data-seeder |
| description | Use when the user asks to add, remove, or modify test data injected by the dev-only ๐งช button โ triggers on phrases like "ํ
์คํธ ๋ฐ์ดํฐ ์ถ๊ฐ", "์๋ ๋ฐ์ดํฐ ์์ ", "test data seeder", "์ฃผ์
๋๋ ๋ฐ์ดํฐ", or any request touching `src/dev/testDataSeeder.ts`, `src/components/dev/TestDataSeederButton.tsx`, or the dev-env data injection flow |
Test Data Seeder
๋ก์ปฌ npm run dev์์๋ง ๋
ธ์ถ๋๋ ๐งช ๋ฒํผ์ผ๋ก, ํ๋ก์ ํธ ์ ์ฒด ๊ธฐ๋ฅ ๊ฒ์ฆ์ฉ ๋ฐ์ดํฐ์
์ ๋ฉฑ๋ฑํ๊ฒ ์ฌ์ฃผ์
ํ๋ ๊ธฐ๋ฅ. ์ด ์คํฌ์ ๊ทธ ๊ตฌ์กฐ๋ฅผ ๋น ๋ฅด๊ฒ ๋ณต๊ตฌํด ์์ ์์ฒญ์ ์ฒ๋ฆฌํ๊ธฐ ์ํจ.
Files
src/dev/testDataSeeder.ts โ ๋จ์ผ ์์ค. ํ๊ทธ/todo/์ผ์ /foremost/done todo ์ ์์ cleanupยทseed ์ํธ๋ฆฌ.
src/components/dev/TestDataSeederButton.tsx โ UI(๐งช ๋ฒํผ), cleanupโseed ์คํ + ์คํ ์ด ์ ์ฒด ์ฌ์กฐํ.
src/components/TopToolbar.tsx โ import.meta.env.DEV && <TestDataSeederButton /> ๊ฐ๋๋ก ์ฐ์ธก ํด๋ฌ์คํฐ(Refresh ์)์ ๋ฐฐ์น.
Core Convention
TEST_PREFIX = '[TEST] ' โ ์์ฑ๋๋ ๋ชจ๋ ์ํฐํฐ ์ด๋ฆ(tag/todo/schedule/done todo) ์์ ๋ถ์ฌ์ผ cleanup์ ์กํ. ํ๋ฆฌํฝ์ค ์์ด ๋ง๋ค๋ฉด ์๊ตฌ ์์กด.
- cleanup ์ ๋ต: foremost ํด์ โ ํ๋ฆฌํฝ์ค ํ๊ทธ
deleteTagAndEvents cascade โ ํ๊ทธ ์๋ ์์ฌ todo/schedule/done todo ๊ฐ๋ณ ์ญ์ .
- cleanup ์กฐํ ๋ฒ์๋ ์ค๋ ๊ธฐ์ค ยฑ730์ผ. ์์ฑ ๋ ์ง๊ฐ ์ด ๋ฒ์๋ฅผ ๋ฒ์ด๋๋ฉด cleanup์ ์ ์กํ๋ฏ๋ก ์ฃผ์.
- ๋ชจ๋ API ํธ์ถ์
safe(label, errors, fn) ๋ํผ + Promise.allSettled๋ก ๊ฐ์ธ ๋ถ๋ถ ์คํจํด๋ ์งํ.
Where to Edit for Common Asks
| ์์ฒญ | ํธ์ง ์์น |
|---|
| ํ๊ทธ ์ถ๊ฐ/์ญ์ /์์ ๋ณ๊ฒฝ | testDataSeeder.ts์ TAGS: SeederTag[] ๋ฐฐ์ด |
| todo ์ผ์ด์ค ์ถ๊ฐ (ํ์ฌ/์๊ฐ์ง์ /๋ฐ๋ณต/์๋ฆผ ๋ฑ) | seedTestData() ์์ todoDefs ๋ฐฐ์ด |
| ์ผ์ ์ผ์ด์ค ์ถ๊ฐ | seedTestData() ์์ scheduleDefs ๋ฐฐ์ด |
| foremost ์ง์ ๋์ ๋ณ๊ฒฝ | todoDefs ์ํธ๋ฆฌ์ setForemost: true ํ๋๊ทธ ์ด๋ |
| ์๋ฃ ๊ธฐ๋ก(done todo) ๊ฐ์/๋ด์ฉ | seedTestData() ๋๋ถ๋ถ์ doneDefs ๋ฐฐ์ด |
| ํ๋ฆฌํฝ์ค ๋ณ๊ฒฝ | TEST_PREFIX ์์ ํ๋ (์์ฑยทcleanup ์๋ ์ผ๊ด) |
| ๋ฒํผ ์์น/์์ด์ฝ/๋ ์ด๋ธ | TestDataSeederButton.tsx + TopToolbar.tsx ์ฝ์
์์น |
Helper Utilities (์ด๋ฏธ ์กด์ฌํ๋ ์ฌ์ฌ์ฉ)
testDataSeeder.ts ๋ด๋ถ ํฌํผ โ ์ ์ผ์ด์ค ์์ฑ ์ ์ด๊ฑธ๋ก ์กฐ๋ฆฝ:
- ์๊ฐ ๊ธฐ์ค:
dateAt(offsetDays, hour, minute?) โ ์ค๋ ๊ธฐ์ค ยฑoffset์ผ์ ํน์ ์๊ฐ Date
- EventTime ๋น๋:
at(date) / period(start, end) / allday(offsetStartDays, offsetEndDays?)
- Repeating ๋น๋:
everyDay(start) / everyWeek(start, dayOfWeek[]) / everyMonthOnDays(start, days[])
- ์๋ฆผ:
notifyMinutesBefore(minutes) โ NotificationOption
- ํ์์กด:
tz() (Intl ๊ธฐ๋ฐ), GMT offset: secondsFromGmt() (allday ์์ฑ ์ ์๋ ์ฌ์ฉ)
Invariants (๊นจ๋จ๋ฆฌ์ง ๋ง ๊ฒ)
- ์๋ก ์ถ๊ฐํ๋ ๋ชจ๋ ์ํฐํฐ
name์ TEST_PREFIX ํ์.
- ํ์์คํฌํ๋ Unix ์ด ๋จ์ (
Math.floor(date.getTime()/1000)). dateAt + ๋น๋ ํฌํผ๋ฅผ ์ฐ๋ฉด ์๋ ์ฒ๋ฆฌ.
- ๋ฐ๋ณต ๊ท์น์๋ ํญ์
timeZone: tz() ์ ๋ฌ (๋ชจ๋ธ ์๊ตฌ).
- ์์ ํ cleanup์ด ์ฌ์ ํ ์์ ๋์ ํญ๋ชฉ์ ์ ๋ถ ์ก์๋ด๋์ง ํ์ธ โ prefix ๋น ์ง ํญ๋ชฉ, ยฑ730์ผ ๋ฒ์ ๋ฐ ๋ ์ง ํ์ธ.
- ์ ์ํฐํฐ ์ข
๋ฅ(์: ์๋ก ์ถ๊ฐ๋ ๋๋ฉ์ธ ๋ชจ๋ธ)๋ฅผ ์๋ฉํ๋ ค๋ฉด, ํด๋น ์คํ ์ด์
fetch/refresh ํธ์ถ๋ TestDataSeederButton.tsx์ ์ฃผ์
ํ ์ฌ์กฐํ ๋ชฉ๋ก์ ์ถ๊ฐํด์ผ ํ๋ฉด ๋ฐ์๋จ.
Dev-Environment Gate
- ๋ฒํผ์
import.meta.env.DEV์ผ ๋๋ง TopToolbar์์ ๋ ๋. ํ๋ก๋์
๋น๋๋ Vite๊ฐ ์์ false๋ก tree-shake.
- ์ปดํฌ๋ํธ ๋ด๋ถ์์ ์กฐ๊ฑด๋ถ early-return +
useState๋ React rules ์๋ฐ ์ํ์ด ์์ด, ๊ฐ๋๋ ๋ฐ๋์ ๋ถ๋ชจ(TopToolbar)์์ ์ฒ๋ฆฌ.
Quick Sanity Check
์์ ํ:
npx tsc --noEmit ํต๊ณผ
npm run dev โ ๋ก์ปฌ์์ ๐งช ๋ฒํผ ๋ณด์ด๋์ง
- ํด๋ฆญ โ ํ ์คํธ "์๋ฃ" + ํ๊ทธ/์ผ์ /todo ์นด์ดํธ ์ผ์น
- ํ ๋ฒ ๋ ํด๋ฆญ โ cleanup์ด ์ด์ ๋ฐ์ดํฐ ์น ์ง์ฐ๊ณ ๊ฐ์ ์นด์ดํธ ์ฌ์ฃผ์
(๋์ X)