From 6791ea22b2276ce7f4b4285d14c79e23141abd55 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Fri, 3 Apr 2026 16:52:40 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20complete=20feedback=20button=20?= =?UTF-8?q?=E2=80=94=20status=20probe,=20requests=20dep,=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - feedback.py: add GET /feedback/status endpoint (returns {enabled: bool}) so frontend can probe on mount instead of optimistic-enable; remove unused get_db import - FeedbackButton.vue: probe /feedback/status on mount, start hidden; drop redundant 503-hide path (status probe makes it redundant) - pyproject.toml: declare requests>=2.31 (used by feedback.py Forgejo calls) - tests/api/test_feedback.py: 7 tests — status endpoint (no-token, token, demo mode), POST 503/403, happy path with mocked Forgejo, 502 on error --- app/api/endpoints/feedback.py | 11 +- frontend/src/components/FeedbackButton.vue | 20 ++-- pyproject.toml | 3 +- tests/api/test_feedback.py | 111 +++++++++++++++++++++ 4 files changed, 133 insertions(+), 12 deletions(-) create mode 100644 tests/api/test_feedback.py diff --git a/app/api/endpoints/feedback.py b/app/api/endpoints/feedback.py index a992b9f..8609073 100644 --- a/app/api/endpoints/feedback.py +++ b/app/api/endpoints/feedback.py @@ -12,11 +12,10 @@ from pathlib import Path from typing import Literal import requests -from fastapi import APIRouter, Depends, HTTPException +from fastapi import APIRouter, HTTPException from pydantic import BaseModel from app.core.config import settings -from app.db.store import get_db router = APIRouter() @@ -118,7 +117,13 @@ class FeedbackResponse(BaseModel): issue_url: str -# ── Route ────────────────────────────────────────────────────────────────────── +# ── Routes ───────────────────────────────────────────────────────────────────── + +@router.get("/status") +def feedback_status() -> dict: + """Return whether feedback submission is configured on this instance.""" + return {"enabled": bool(os.environ.get("FORGEJO_API_TOKEN")) and not settings.DEMO_MODE} + @router.post("", response_model=FeedbackResponse) def submit_feedback(payload: FeedbackRequest) -> FeedbackResponse: diff --git a/frontend/src/components/FeedbackButton.vue b/frontend/src/components/FeedbackButton.vue index a55464d..9373256 100644 --- a/frontend/src/components/FeedbackButton.vue +++ b/frontend/src/components/FeedbackButton.vue @@ -136,12 +136,21 @@