From 55a5d93a915a52560ccb46f73fbee9fafdd6e436 Mon Sep 17 00:00:00 2001 From: Ichitux Date: Sun, 28 Jun 2026 13:06:56 +0200 Subject: [PATCH] fix(frontend): restore PublicView back-compat for tests + CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The lifted screen-state refactor in PublicView broke App.test.jsx (5 failures): when no `onScreenChange` prop was passed, the click handler called a no-op, so the screen never advanced from 'home' to 'search' and the search input was never rendered. Fix: make screen state uncontrolled-by-default. PublicView owns its own `useState('home')` and uses the lifted props only when App.jsx provides them. Same back-compat shape as before, BottomNav still drives the screen via controlled props in the real app. Also: vitest defaults to watch mode, which hangs the CI test step forever. Updated docker.yaml to pass `--run --reporter=basic` so the job exits with a real pass/fail signal. Local verification: `npm test -- --run` → 6/6 passing. Co-Authored-By: Claude --- .gitea/workflows/docker.yaml | 4 ++-- frontend/src/views/PublicView.jsx | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/docker.yaml b/.gitea/workflows/docker.yaml index 619750a..41a9811 100644 --- a/.gitea/workflows/docker.yaml +++ b/.gitea/workflows/docker.yaml @@ -14,7 +14,7 @@ jobs: - name: Install dependencies run: cd backend && npm ci - name: Run tests - run: cd backend && npm test + run: cd backend && npm test -- --run --reporter=basic test-frontend: runs-on: ubuntu-latest @@ -23,7 +23,7 @@ jobs: - name: Install dependencies run: cd frontend && npm ci - name: Run tests - run: cd frontend && npm test + run: cd frontend && npm test -- --run --reporter=basic build-backend: needs: [ test-backend, test-frontend ] diff --git a/frontend/src/views/PublicView.jsx b/frontend/src/views/PublicView.jsx index 3fd76d2..a323aff 100644 --- a/frontend/src/views/PublicView.jsx +++ b/frontend/src/views/PublicView.jsx @@ -14,9 +14,11 @@ function PublicView({ screen: screenProp, onScreenChange, }) { - // ponytail: screen state lifted to App.jsx so BottomNav can switch directly. - const screen = screenProp ?? 'home'; - const setScreen = onScreenChange ?? (() => {}); + // ponytail: uncontrolled by default (own state); controlled when App.jsx passes props + // so BottomNav can drive the inner screen directly. No-op fallback breaks tests. + const [internalScreen, setInternalScreen] = useState('home'); + const screen = screenProp ?? internalScreen; + const setScreen = onScreenChange ?? setInternalScreen; const [searchQuery, setSearchQuery] = useState(''); const [medicines, setMedicines] = useState([]);