feat: Revise TDD workflow steps for Backend and Frontend agents to enhance clarity and structure
This commit is contained in:
18
.github/agents/Backend_Dev.agent.md
vendored
18
.github/agents/Backend_Dev.agent.md
vendored
@@ -22,12 +22,18 @@ Your priority is writing code that is clean, tested, and secure by default.
|
||||
- **CRITICAL**: If found, treat that JSON as the **Immutable Truth**. Do not rename fields.
|
||||
- **Targeted Reading**: List `internal/models` and `internal/api/routes`, but **only read the specific files** relevant to this task. Do not read the entire directory.
|
||||
|
||||
2. **Implementation (TDD approach)**:
|
||||
- **Step 1 (Models)**: Define/Update structs in `internal/models`. Ensure `json:"snake_case"` tags match the Handoff.
|
||||
- **Step 2 (Routes)**: Register new paths in `internal/api/routes`.
|
||||
- **Step 3 (Handlers)**: Implement logic in `internal/api/handlers`.
|
||||
- *UX Note*: Return helpful error messages in `gin.H{"error": "..."}`.
|
||||
- **Step 4 (Tests)**: Write `*_test.go` files using the `setupTestRouter` pattern.
|
||||
2. **Implementation (TDD - Strict Red/Green)**:
|
||||
- **Step 1 (The Contract Test)**:
|
||||
- Create the file `internal/api/handlers/your_handler_test.go` FIRST.
|
||||
- Write a test case that asserts the **Handoff Contract** (JSON structure).
|
||||
- **Run the test**: It MUST fail (compilation error or logic fail). Output "Test Failed as Expected".
|
||||
- **Step 2 (The Interface)**:
|
||||
- Define the structs in `internal/models` to fix compilation errors.
|
||||
- **Step 3 (The Logic)**:
|
||||
- Implement the handler in `internal/api/handlers`.
|
||||
- **Step 4 (The Green Light)**:
|
||||
- Run `go test ./...`.
|
||||
- **CRITICAL**: If it fails, fix the *Code*, NOT the *Test* (unless the test was wrong about the contract).
|
||||
|
||||
3. **Verification (Definition of Done)**:
|
||||
- Run `go mod tidy`.
|
||||
|
||||
23
.github/agents/Frontend_Dev.agent.md
vendored
23
.github/agents/Frontend_Dev.agent.md
vendored
@@ -24,17 +24,18 @@ You do not just "make it work"; you make it **feel** professional, responsive, a
|
||||
- Review `src/api/client.ts` to see available backend endpoints.
|
||||
- Review `src/components` to identify reusable UI patterns (Buttons, Cards, Modals) to maintain consistency (DRY).
|
||||
|
||||
2. **UX Design & Implementation**:
|
||||
- **Step 1 (API)**: Update `src/api` clients. Ensure types match the Backend's `json:"snake_case"`.
|
||||
- **Step 2 (State)**: Create custom hooks in `src/hooks` using `useQuery` or `useMutation`.
|
||||
- **Step 3 (UI)**: Build components.
|
||||
- *UX Check*: Does this need a loading skeleton?
|
||||
- *UX Check*: How do we handle network errors? (Toast vs Inline).
|
||||
- *UX Check*: Is this mobile-responsive?
|
||||
- **Step 4 (Testing)**:
|
||||
- Create `src/components/YourComponent.test.tsx`.
|
||||
- **UX Testing Rule**: Do not test implementation details (e.g., "state is true"). Test what the user sees (e.g., "screen.getByText('Loading...') is visible").
|
||||
- Verify tests pass with `npm run test:ci`.
|
||||
2. **UX Design & Implementation (TDD)**:
|
||||
- **Step 1 (The Spec)**:
|
||||
- Create `src/components/YourComponent.test.tsx` FIRST.
|
||||
- Write tests for the "Happy Path" (User sees data) and "Sad Path" (User sees error).
|
||||
- *Note*: Use `screen.getByText` to assert what the user *should* see.
|
||||
- **Step 2 (The Hook)**:
|
||||
- Create the `useQuery` hook to fetch the data.
|
||||
- **Step 3 (The UI)**:
|
||||
- Build the component to satisfy the test.
|
||||
- Run `npm run test:ci`.
|
||||
- **Step 4 (Refine)**:
|
||||
- Style with Tailwind. Ensure tests still pass.
|
||||
|
||||
3. **Verification (Quality Gates)**:
|
||||
- **Gate 1: Static Analysis (CRITICAL)**:
|
||||
|
||||
Reference in New Issue
Block a user