3.7 KiB
You are a Senior Full Stack Engineer and QA Engineer.
Project: Training Management System (TMS)
Current status: Sprint 1-6 completed. Pre-UAT Readiness Review completed. Before starting Sprint 7, fix all remaining important issues.
Current task: Implement Sprint 6.5: Pre-Sprint 7 Hardening.
Important constraints:
- Do NOT add new business features.
- Do NOT change folder structure.
- Do NOT migrate ORM unless absolutely necessary.
- Do NOT rename tables or columns.
- Do NOT break existing routes.
- Reuse existing Auth.js.
- Reuse existing Drizzle ORM.
- Keep Thai UI.
- Keep responsive/mobile behavior.
- Minimal-impact changes only.
Priority 1: Notification Pagination Optimization
Problem: Notification listing currently loads all matching rows, filters in memory, then slices for pagination.
Requirements:
- Move notification pagination to database query level.
- Use WHERE, ORDER BY, LIMIT, OFFSET at SQL/Drizzle level.
- Keep existing search, read/unread filter, and type filter behavior.
- Keep ownership check:
- organizationId
- userId
- Preserve unread count accuracy.
- Preserve header notification popover behavior.
- Do not break Notification Center page.
Files likely involved:
- src/features/notifications/server/notification-data.ts
- src/app/api/notifications/route.ts
- src/features/notifications/api/types.ts
- src/features/notifications/api/service.ts
Priority 2: Announcement Route Loading/Error Coverage
Problem: Announcement route segment does not have route-level loading.tsx and error.tsx.
Requirements:
- Add route-level loading and error pages:
- src/app/dashboard/announcements/loading.tsx
- src/app/dashboard/announcements/error.tsx
- src/app/dashboard/announcements/[id]/loading.tsx
- src/app/dashboard/announcements/[id]/error.tsx
- Use Thai UI.
- Follow existing loading/error pattern from other dashboard modules.
- Keep responsive layout.
Priority 3: RBAC Documentation Update
Problem: docs/nav-rbac.md is outdated and still references Clerk/client-side authorization.
Requirements:
- Update docs/nav-rbac.md to reflect current architecture:
- Auth.js
- Server-side authorization
- requireOrganizationAccess()
- requireHRD()
- requireEmployeeDashboardAccess()
- role-based sidebar filtering
- proxy.ts route protection
- Remove outdated Clerk references.
- Document:
- Employee access
- HRD access
- API protection
- direct URL protection
- file download protection
- Keep the document clear and suitable for maintenance.
Priority 4: Browser Smoke Test Checklist
Create a smoke test checklist for:
- Chrome
- Microsoft Edge
Test areas: Employee:
- Login
- View dashboard
- Create training record
- Upload certificate
- Open/download certificate
- Edit pending training record
- Delete pending training record
- View notification
- View announcement
HRD:
- Login
- Open dashboard
- Review pending training
- Approve training
- Reject training
- Create announcement
- Open/download announcement attachment
- Import employee
- Master review approve/reject
- View audit logs
- Export audit log CSV
Priority 5: Output Review File
Create:
docs/sprint-6-5-pre-sprint-7-hardening-review.md
The file must include:
- Summary
- Files Changed
- Issues Fixed
- Notification Pagination Optimization
- Announcement Loading/Error Coverage
- RBAC Documentation Update
- Browser Smoke Test Checklist
- Validation Result
- Remaining Risks
- Sprint 7 Readiness Score
Validation:
- Run typecheck
- Run lint
- Confirm no new migration is required unless changed
- Confirm existing routes still work
Return:
- Complete code changes with file paths
- Content of docs/sprint-6-5-pre-sprint-7-hardening-review.md
- Any remaining issues