Skip to content

feat: add admin preview endpoint with tests#882

Open
shravanithouta108 wants to merge 7 commits into
imDarshanGK:mainfrom
shravanithouta108:feat/admin-preview-endpoint
Open

feat: add admin preview endpoint with tests#882
shravanithouta108 wants to merge 7 commits into
imDarshanGK:mainfrom
shravanithouta108:feat/admin-preview-endpoint

Conversation

@shravanithouta108

@shravanithouta108 shravanithouta108 commented Jun 6, 2026

Copy link
Copy Markdown

Description

Implements a POST /admin/preview/ endpoint that allows admins to preview how prompt templates render with placeholder variables before running full analyses. Optionally returns a mock provider response.

Related Issue

Fixes #651

Type of change

  • Bug fix
  • New feature / enhancement
  • Documentation update
  • Test addition
  • Refactor

Checklist

  • I have read CONTRIBUTING.md
  • My branch is up to date with main
  • I have run pytest -v and all tests pass
  • I have not introduced duplicate issues or features
  • My PR title follows the format: feat/fix/docs/test: short description
  • I have added tests for new features
  • No hardcoded secrets or API keys in my code
  • This PR is linked to a GSSoC 2026 issue

Test evidence

tests/test_preview.py::test_preview_basic PASSED
tests/test_preview.py::test_preview_missing_variable PASSED
tests/test_preview.py::test_preview_with_mock_response PASSED
tests/test_preview.py::test_preview_unauthorized PASSED
4 passed

##Demo

Demo

Tested via Swagger UI at POST /admin/preview/:

  • ✅ Template renders correctly with variables
  • ✅ Mock provider response returned
  • ✅ Variables found/missing tracked correctly
  • ✅ Unauthorized access blocked (403)
demo.mp4

@shravanithouta108

Copy link
Copy Markdown
Author

Hi @imDarshanGK! 👋

Just following up on this PR — it's been a few days and I wanted to check if you've had a chance to look at it.

All 4 tests are passing and the branch can be cleanly merged. Happy to make any changes based on your feedback!

Thank you for your time. 🙏

@imDarshanGK

Copy link
Copy Markdown
Owner

@shravanithouta108 add demo

@shravanithouta108

Copy link
Copy Markdown
Author

Hi @imDarshanGK! 👋

Added the demo video showing the POST /admin/preview/ endpoint working via Swagger UI.

Also fixed the lint issues:

  • Removed unused Depends import from preview.py
  • Removed trailing whitespace in main.py

All 4 tests still passing. Ready for review!

@imDarshanGK

Copy link
Copy Markdown
Owner

@shravanithouta108
image

@shravanithouta108

Copy link
Copy Markdown
Author

Hi @imDarshanGK! 👋

Following up on PR #882 — it's been a few days since your last comment. I've applied black formatting as requested and all 4 tests are still passing ✅.

The only remaining issue is the merge conflict in backend/app/main.py and backend/app/routers/analyze.py — I'll resolve those right away and push an update.

Could you please take another look once that's done? Happy to make any other changes you need. 🙏

@imDarshanGK

Copy link
Copy Markdown
Owner

@shravanithouta108 resolve conflicts

@shravanithouta108

Copy link
Copy Markdown
Author

Resolved merge conflicts in main.py and analyze.py. Ready for review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add endpoint to preview prompt templates

2 participants