# Bug Hunt Report — Admin Web

**Review date:** 2026-11-29  
**Scope:** `admin-web/` and its NestJS API contracts. Backend, PostgreSQL, and Flutter were mapped for integration context; this was not an exhaustive audit of those separate applications.

## Project overview

- **Admin frontend/BFF:** Next.js 16 App Router, React 19, TypeScript, Tailwind CSS. Route handlers in `src/app/api/` proxy requests to the backend and hold access/refresh credentials in an encrypted HttpOnly session cookie.
- **API:** NestJS 12 at the configured `API_BASE_URL` (documented default `/api/v1`), with response envelopes and JWT/rotating refresh tokens.
- **Database:** PostgreSQL 17 through Prisma 7; admin data and operations are served by backend modules.
- **Mobile:** Flutter client in the parent repository; out of source-review scope.
- **Auth and authorization:** Login/logout/refresh routes; BFF catch-all proxy; backend bearer-token and permission checks.
- **Build and checks:** npm workspace, Next.js, TypeScript, ESLint, Vitest. Admin web has five Vitest files.

## Methodology and skills

Used the installed `bug-hunter` skill. Mapped the repository and its API boundaries, inspected BFF/auth/session handling, reviewed page state and date formatting, traced frontend behavior to current routes and the settings policy, and ran available typecheck, lint, test, and build commands. The auth/API review was independently delegated as requested. No database writes, migrations, or production operations were performed.

## Confirmed findings

### BUG-01 — Institutional timestamps vary with each viewer's timezone

- **Severity:** P2 (medium)
- **Status:** Fixed; post-fix runtime verification blocked by disk exhaustion
- **Affected files/functions:** `src/components/dashboard-overview.tsx` (`DashboardOverview` audit event rendering); `src/app/assignments/page.tsx` (assignment due date rendering); `src/app/results/page.tsx` (exam date rendering)
- **Root cause:** These UTC instants were rendered with `toLocaleString()` / `toLocaleDateString()` without a `timeZone`, so the browser silently used its local timezone. Settings identifies Asia/Dhaka as the default display timezone.
- **Impact:** Staff using devices configured outside Bangladesh could see different audit times, assignment deadlines, or exam dates for the same records.
- **Reproduction:** Set the browser timezone to UTC or America/New_York, then compare displayed dates with an Asia/Dhaka-configured browser for identical backend UTC values.
- **Fix:** Set `timeZone: 'Asia/Dhaka'` on all three date formatting calls. Exam dates are stored as UTC timestamps, so they use the same explicit display zone.
- **Verification:** TypeScript passed before this fix. A test run before the fix exposed the route-test issue below. After both fixes, test and build reruns were blocked immediately by `ENOSPC`; the timezone behavior is not claimed as runtime-verified.

### BUG-02 — Dashboard test rendered the public landing page

- **Severity:** P3 (low; stale regression coverage)
- **Status:** Fixed in test source; rerun blocked by disk exhaustion
- **Affected file/function:** `src/components/phase3-pages.test.tsx`, dashboard rendering test
- **Root cause:** The test imported `src/app/page.tsx` and named it `HomePage`, although the dashboard is now `src/app/dashboard/page.tsx` and `/` is a public institutional landing page.
- **Impact:** The dashboard metrics/audit test failed against unrelated landing-page content and no longer covered the actual dashboard route.
- **Reproduction:** `npm test` failed expecting dashboard metric `42`; the rendered DOM was the public landing page.
- **Fix:** Changed the test to render `DashboardPage` from `src/app/dashboard/page.tsx`.
- **Verification:** The original failure was reproduced. The corrected test could not be rerun because npm reported no disk space (`ENOSPC`).

## Other review results

- **Confirmed auth/API bugs:** None found. Admin login, refresh, logout, response envelopes, backend endpoint suffixes, and bearer logout were traced and found consistent with backend contracts.
- **Likely bugs:** None confirmed.
- **Unverified risk:** `withSingleFlightRefresh` deduplicates token refreshes only within one server process. Multiple app instances could race a rotating refresh token, but deployment topology and backend behavior under that deployment were unavailable; this is not classified as a bug.
- **Remaining known test/environment issues:** The modified route makes the existing dashboard test target current behavior. Post-fix verification is outstanding due disk exhaustion. Lint also failed before source analysis because `eslint-config-prettier` is missing from the installed dependency tree.

## Changes made

- Added explicit Asia/Dhaka timezone formatting for audit, assignment, and exam timestamps.
- Updated the dashboard test to target `/dashboard` rather than the public `/` page.
- No backend, database, dependency, or production configuration changes.

## Verification results

| Check | Result |
|---|---|
| Admin TypeScript (`npm run typecheck`) | Passed before the source fixes; post-fix run unavailable |
| Admin Vitest (`npm test`) | Before fixes: 23 passed, 1 failed due test importing landing page. After fixes: blocked immediately by `ENOSPC` |
| Admin lint (`npm run lint`) | Blocked: installed dependency `eslint-config-prettier` not found |
| Admin build (`npm run build`) | Blocked immediately by `ENOSPC`; build not verified |
| Backend/database integration | Not run; no isolated DB verification was requested or available |

## Files modified by this bug hunt

- `src/components/dashboard-overview.tsx`
- `src/app/assignments/page.tsx`
- `src/app/results/page.tsx`
- `src/components/phase3-pages.test.tsx`

Other pre-existing working-tree changes were left untouched.

## Recommendations

1. Free disk space using the project owner’s normal cleanup process, then run admin tests, typecheck, lint, and production build again.
2. Restore the declared dependency tree from the existing lockfile so ESLint can run.
3. If the admin app deploys to multiple instances, validate refresh-token rotation behavior across instances or provide shared refresh coordination.
