mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-26 08:58:40 +09:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97f1a7640b | ||
|
|
2d687064b8 |
No files matched your search
@@ -60,6 +60,30 @@ This single command:
|
||||
|
||||
**All tests must pass.** Don't dismiss failures as "pre-existing" - investigate and fix them.
|
||||
|
||||
### Testing in Production (for Agents)
|
||||
|
||||
When asked to "test it yourself in prod" or verify a fix in production:
|
||||
|
||||
```bash
|
||||
# Get admin token
|
||||
export KARAOKE_ADMIN_TOKEN=$(gcloud secrets versions access latest --secret=admin-tokens --project=nomadkaraoke | cut -d',' -f1)
|
||||
|
||||
# Option 1: Use the debug template directly
|
||||
cd frontend && node e2e/helpers/debug-prod-template.mjs
|
||||
|
||||
# Option 2: Copy template for customization (gitignored)
|
||||
cp frontend/e2e/helpers/debug-prod-template.mjs frontend/test-my-issue.local.mjs
|
||||
# Edit the script, then run it
|
||||
node test-my-issue.local.mjs
|
||||
|
||||
# Option 3: Run existing production E2E tests
|
||||
KARAOKE_ADMIN_TOKEN=$KARAOKE_ADMIN_TOKEN npx playwright test e2e/production/admin-dashboard.spec.ts
|
||||
```
|
||||
|
||||
Files matching `test-*.local.*` and `debug-*.local.*` are gitignored - you can hardcode tokens in them safely.
|
||||
|
||||
See `docs/TESTING.md` § "Ad-Hoc Production Debugging" for full details.
|
||||
|
||||
### Version Bumping
|
||||
- Bump `tool.poetry.version` in `pyproject.toml` for code changes
|
||||
- Skip for docs-only changes
|
||||
|
||||
+37
-21
@@ -808,23 +808,35 @@ def _extract_files_recursive(
|
||||
expiration_minutes=expiration_minutes,
|
||||
)
|
||||
files.extend(nested_files)
|
||||
elif isinstance(value, str) and value.startswith("gs://"):
|
||||
# GCS path - generate signed URL
|
||||
try:
|
||||
signed_url = storage.generate_signed_url(value, expiration_minutes=expiration_minutes)
|
||||
# Extract filename from path
|
||||
name = value.split("/")[-1] if "/" in value else value
|
||||
files.append(FileInfo(
|
||||
name=name,
|
||||
path=value,
|
||||
download_url=signed_url,
|
||||
category=category,
|
||||
file_key=key,
|
||||
))
|
||||
except Exception as e:
|
||||
# Log but don't fail - file might not exist
|
||||
logger.warning(f"Failed to generate signed URL for {value}: {e}")
|
||||
# Skip non-GCS values (e.g., youtube URLs, video IDs)
|
||||
elif isinstance(value, str):
|
||||
# Check if it's a GCS path (gs:// URI or relative path starting with "jobs/")
|
||||
# Skip non-GCS values like YouTube URLs, video IDs, etc.
|
||||
blob_path = None
|
||||
if value.startswith("gs://"):
|
||||
# Full GCS URI - extract blob path after bucket name
|
||||
# Format: gs://bucket-name/path/to/file
|
||||
parts = value.replace("gs://", "").split("/", 1)
|
||||
if len(parts) > 1:
|
||||
blob_path = parts[1]
|
||||
elif value.startswith("jobs/"):
|
||||
# Relative path within bucket - use directly
|
||||
blob_path = value
|
||||
|
||||
if blob_path:
|
||||
try:
|
||||
signed_url = storage.generate_signed_url(blob_path, expiration_minutes=expiration_minutes)
|
||||
# Extract filename from path
|
||||
name = blob_path.split("/")[-1] if "/" in blob_path else blob_path
|
||||
files.append(FileInfo(
|
||||
name=name,
|
||||
path=value,
|
||||
download_url=signed_url,
|
||||
category=category,
|
||||
file_key=key,
|
||||
))
|
||||
except Exception as e:
|
||||
# Log but don't fail - file might not exist
|
||||
logger.warning(f"Failed to generate signed URL for {value}: {e}")
|
||||
|
||||
return files
|
||||
|
||||
@@ -858,10 +870,14 @@ async def get_job_files(
|
||||
raise HTTPException(status_code=404, detail=f"Job {job_id} not found")
|
||||
|
||||
# Extract all files with signed URLs
|
||||
storage = StorageService()
|
||||
file_urls = job.file_urls or {}
|
||||
|
||||
files = _extract_files_recursive(file_urls, storage)
|
||||
try:
|
||||
storage = StorageService()
|
||||
file_urls = job.file_urls or {}
|
||||
files = _extract_files_recursive(file_urls, storage)
|
||||
except Exception as e:
|
||||
# Log but don't fail - return empty list if file extraction fails
|
||||
logger.error(f"Failed to extract files for job {job_id}: {e}")
|
||||
files = []
|
||||
|
||||
return JobFilesResponse(
|
||||
job_id=job.job_id,
|
||||
|
||||
@@ -76,6 +76,8 @@ For faster iteration, run subsets:
|
||||
|
||||
TESTING.md covers: test types, CI requirements, Playwright usage, mocking guidelines, and coverage enforcement.
|
||||
|
||||
**For ad-hoc production debugging**, see the "Ad-Hoc Production Debugging" section in TESTING.md. Use the template at `frontend/e2e/helpers/debug-prod-template.mjs`.
|
||||
|
||||
## Deployment
|
||||
|
||||
### Automatic (CI/CD)
|
||||
|
||||
@@ -402,6 +402,86 @@ The production tests cover:
|
||||
- Final encoding and download
|
||||
- Admin dashboard functionality
|
||||
|
||||
## Ad-Hoc Production Debugging (for Agents)
|
||||
|
||||
When asked to "test it yourself in prod" or debug a specific production issue, use the debug script template:
|
||||
|
||||
### Quick Start
|
||||
|
||||
```bash
|
||||
# Copy the template (the .local suffix is gitignored)
|
||||
cp frontend/e2e/helpers/debug-prod-template.mjs frontend/test-my-issue.local.mjs
|
||||
|
||||
# Edit the script to customize what you're testing
|
||||
# You can hardcode tokens in .local files - they won't be committed
|
||||
|
||||
# Run it
|
||||
cd frontend && node test-my-issue.local.mjs
|
||||
```
|
||||
|
||||
### With Environment Variables (Preferred)
|
||||
|
||||
```bash
|
||||
# Get admin token from Secret Manager
|
||||
export KARAOKE_ADMIN_TOKEN=$(gcloud secrets versions access latest --secret=admin-tokens --project=nomadkaraoke | cut -d',' -f1)
|
||||
|
||||
# Run the template directly
|
||||
cd frontend && node e2e/helpers/debug-prod-template.mjs
|
||||
|
||||
# Or with a specific job
|
||||
DEBUG_JOB_ID=abc123 node e2e/helpers/debug-prod-template.mjs
|
||||
```
|
||||
|
||||
### What the Template Provides
|
||||
|
||||
- Playwright browser automation against production
|
||||
- Auth token injection (via localStorage)
|
||||
- Console error capture
|
||||
- HTTP error capture (4xx, 5xx responses)
|
||||
- Screenshot capability
|
||||
- Customizable debug steps
|
||||
|
||||
### Gitignore Patterns
|
||||
|
||||
Files matching these patterns are gitignored in `frontend/`:
|
||||
- `test-*.local.*` - Ad-hoc test scripts
|
||||
- `debug-*.local.*` - Debug scripts
|
||||
|
||||
**Never commit tokens.** Use env vars or `.local` files only.
|
||||
|
||||
### When to Use What
|
||||
|
||||
| Scenario | Approach |
|
||||
|----------|----------|
|
||||
| Quick one-off debugging | Copy template → `.local` file |
|
||||
| Reusable production test | Add to `e2e/production/` with env var auth |
|
||||
| Regression test (mocked) | Add to `e2e/regression/` |
|
||||
|
||||
### Example: Debug a Specific Job's Review Page
|
||||
|
||||
```javascript
|
||||
// frontend/test-review-debug.local.mjs
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const TOKEN = 'your-token-here'; // OK in .local files
|
||||
const JOB_ID = '26391a79';
|
||||
|
||||
async function debug() {
|
||||
const browser = await chromium.launch({ headless: false }); // See the browser
|
||||
const page = await browser.newContext().then(c => c.newPage());
|
||||
|
||||
await page.addInitScript(t => localStorage.setItem('karaoke_access_token', t), TOKEN);
|
||||
await page.goto(`https://gen.nomadkaraoke.com/app/jobs/${JOB_ID}/review/`);
|
||||
|
||||
// Debug interactively - the browser stays open
|
||||
await page.pause(); // Opens Playwright inspector
|
||||
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
debug();
|
||||
```
|
||||
|
||||
## Running Tests Locally
|
||||
|
||||
```bash
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
playwright-report-prod/
|
||||
|
||||
# Local debug scripts (may contain tokens - never commit)
|
||||
# Use this pattern for ad-hoc testing: test-*.local.{js,cjs,mjs,ts}
|
||||
test-*.local.*
|
||||
debug-*.local.*
|
||||
+171
-133
@@ -546,6 +546,42 @@ function AdminJobsPageContent() {
|
||||
return `${mins}m${secs}s`
|
||||
}
|
||||
|
||||
const formatDurationLong = (ms: number) => {
|
||||
if (ms === 0) return "0s"
|
||||
if (ms < 1000) return `${ms}ms`
|
||||
const hours = Math.floor(ms / 3600000)
|
||||
const mins = Math.floor((ms % 3600000) / 60000)
|
||||
const secs = Math.floor((ms % 60000) / 1000)
|
||||
if (hours > 0) return `${hours}h ${mins}m ${secs}s`
|
||||
if (mins > 0) return `${mins}m ${secs}s`
|
||||
return `${secs}s`
|
||||
}
|
||||
|
||||
// Calculate job timing stats from timeline
|
||||
const getJobTimingStats = (job: Job) => {
|
||||
if (!job?.timeline || job.timeline.length < 2) {
|
||||
return { total: 0, processing: 0, waiting: 0 }
|
||||
}
|
||||
|
||||
const firstTime = new Date(job.timeline[0].timestamp).getTime()
|
||||
const lastTime = new Date(job.timeline[job.timeline.length - 1].timestamp).getTime()
|
||||
const total = lastTime - firstTime
|
||||
|
||||
// Calculate waiting time (awaiting_* and in_review states)
|
||||
let waiting = 0
|
||||
for (let i = 0; i < job.timeline.length - 1; i++) {
|
||||
const status = job.timeline[i].status
|
||||
if (status.includes("awaiting") || status === "in_review") {
|
||||
const start = new Date(job.timeline[i].timestamp).getTime()
|
||||
const end = new Date(job.timeline[i + 1].timestamp).getTime()
|
||||
waiting += end - start
|
||||
}
|
||||
}
|
||||
|
||||
const processing = total - waiting
|
||||
return { total, processing, waiting }
|
||||
}
|
||||
|
||||
// Get timeline stage color based on status
|
||||
const getTimelineStageColor = (status: string, isCurrent: boolean) => {
|
||||
if (status === "complete" || status === "prep_complete") {
|
||||
@@ -646,6 +682,7 @@ function AdminJobsPageContent() {
|
||||
|
||||
const jobSource = getJobSource(selectedJob)
|
||||
const stageDurations = getStageDurations(selectedJob)
|
||||
const timingStats = getJobTimingStats(selectedJob)
|
||||
const SourceIcon = jobSource.icon
|
||||
const canDeleteOutputs = ["complete", "prep_complete", "failed", "cancelled"].includes(selectedJob.status)
|
||||
|
||||
@@ -801,7 +838,7 @@ function AdminJobsPageContent() {
|
||||
|
||||
{/* ===== HORIZONTAL TIMELINE ===== */}
|
||||
<div className="py-3 border-b">
|
||||
<div className="flex items-start gap-0 overflow-x-auto pb-2">
|
||||
<div className="flex flex-wrap items-start gap-y-2">
|
||||
{stageDurations.map((stage, i) => {
|
||||
const isLast = i === stageDurations.length - 1
|
||||
const isCurrent = isLast
|
||||
@@ -812,7 +849,7 @@ function AdminJobsPageContent() {
|
||||
const time = formatTimeOnly(stage.startTime)
|
||||
|
||||
return (
|
||||
<div key={i} className="flex items-start shrink-0">
|
||||
<div key={i} className="flex items-start">
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div
|
||||
@@ -853,7 +890,7 @@ function AdminJobsPageContent() {
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
{!isLast && (
|
||||
<ChevronRight className="w-3 h-3 text-muted-foreground/30 mx-0.5 mt-2 shrink-0" />
|
||||
<ChevronRight className="w-3 h-3 text-muted-foreground/40 mx-0.5 mt-2" />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
@@ -862,7 +899,7 @@ function AdminJobsPageContent() {
|
||||
</div>
|
||||
|
||||
{/* ===== JOB INFO GRID ===== */}
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4 py-3">
|
||||
<div className="grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-4 py-3">
|
||||
<div className="space-y-1">
|
||||
<p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider">User</p>
|
||||
<p className="text-sm truncate" title={selectedJob.user_email || "Unknown"}>
|
||||
@@ -882,12 +919,6 @@ function AdminJobsPageContent() {
|
||||
{formatDateCompact(selectedJob.created_at)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider">Updated</p>
|
||||
<p className="text-sm" title={formatDate(selectedJob.updated_at)}>
|
||||
{formatDateCompact(selectedJob.updated_at)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider">Progress</p>
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -900,6 +931,19 @@ function AdminJobsPageContent() {
|
||||
<span className="text-sm font-medium">{selectedJob.progress}%</span>
|
||||
</div>
|
||||
</div>
|
||||
{/* Timing stats */}
|
||||
<div className="space-y-1">
|
||||
<p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider">Total Time</p>
|
||||
<p className="text-sm font-mono">{formatDurationLong(timingStats.total) || "—"}</p>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider">Processing</p>
|
||||
<p className="text-sm font-mono text-blue-600 dark:text-blue-400">{formatDurationLong(timingStats.processing) || "—"}</p>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider">Waiting</p>
|
||||
<p className="text-sm font-mono text-amber-600 dark:text-amber-400">{formatDurationLong(timingStats.waiting) || "—"}</p>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider">Theme</p>
|
||||
<p className="text-sm truncate">{selectedJob.theme_id || "default"}</p>
|
||||
@@ -907,26 +951,124 @@ function AdminJobsPageContent() {
|
||||
</div>
|
||||
|
||||
{/* ===== TABBED CONTENT SECTIONS ===== */}
|
||||
<Tabs defaultValue="files" className="w-full">
|
||||
<Tabs defaultValue="overview" className="w-full">
|
||||
<TabsList className="w-full justify-start h-9 bg-muted/50">
|
||||
<TabsTrigger value="overview" className="text-xs">
|
||||
<Settings className="w-3 h-3 mr-1" />
|
||||
Overview
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="files" className="text-xs">
|
||||
<Download className="w-3 h-3 mr-1" />
|
||||
Files ({files.length})
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="config" className="text-xs">
|
||||
<Settings className="w-3 h-3 mr-1" />
|
||||
Config
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="metadata" className="text-xs">
|
||||
<FileText className="w-3 h-3 mr-1" />
|
||||
Metadata
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="debug" className="text-xs">
|
||||
<Terminal className="w-3 h-3 mr-1" />
|
||||
Debug
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
{/* Overview Tab - Config + Metadata side by side */}
|
||||
<TabsContent value="overview" className="mt-3">
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{/* Config Section */}
|
||||
<Card>
|
||||
<CardHeader className="py-2 px-3 bg-muted/30">
|
||||
<CardTitle className="text-xs font-medium">Configuration</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="pt-3 space-y-2">
|
||||
{[
|
||||
{ key: "artist", label: "Artist", value: selectedJob.artist },
|
||||
{ key: "title", label: "Title", value: selectedJob.title },
|
||||
{ key: "user_email", label: "User Email", value: selectedJob.user_email },
|
||||
{ key: "theme_id", label: "Theme", value: selectedJob.theme_id || "default" },
|
||||
{ key: "brand_prefix", label: "Brand Prefix", value: selectedJob.brand_prefix },
|
||||
{ key: "customer_email", label: "Customer Email", value: selectedJob.customer_email },
|
||||
].map(({ key, label, value }) => (
|
||||
<div key={key} className="flex items-center gap-2 group">
|
||||
<span className="text-[10px] font-medium text-muted-foreground uppercase w-20 shrink-0">{label}</span>
|
||||
{editingField === key ? (
|
||||
<div className="flex items-center gap-1 flex-1">
|
||||
<Input
|
||||
value={editValue}
|
||||
onChange={(e) => setEditValue(e.target.value)}
|
||||
onKeyDown={(e) => handleEditKeyPress(e, key)}
|
||||
className="h-6 text-xs"
|
||||
autoFocus
|
||||
/>
|
||||
<Button variant="ghost" size="icon" className="h-6 w-6" onClick={() => saveField(key)} disabled={saving}>
|
||||
{saving ? <Loader2 className="w-3 h-3 animate-spin" /> : <Check className="w-3 h-3 text-green-600" />}
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" className="h-6 w-6" onClick={cancelEditing} disabled={saving}>
|
||||
<X className="w-3 h-3 text-red-600" />
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center gap-1 flex-1 min-w-0">
|
||||
<span className="text-xs truncate flex-1">{value || "—"}</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-5 w-5 opacity-0 group-hover:opacity-100"
|
||||
onClick={() => startEditing(key, value || "")}
|
||||
>
|
||||
<Pencil className="w-2.5 h-2.5" />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Metadata Section */}
|
||||
<Card>
|
||||
<CardHeader className="py-2 px-3 bg-muted/30">
|
||||
<CardTitle className="text-xs font-medium">Request Metadata</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="pt-3 space-y-2">
|
||||
{selectedJob.request_metadata && Object.keys(selectedJob.request_metadata).length > 0 ? (
|
||||
<>
|
||||
{selectedJob.request_metadata.environment && (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-[10px] font-medium text-muted-foreground uppercase w-20 shrink-0">Environment</span>
|
||||
<span className="text-xs">{selectedJob.request_metadata.environment}</span>
|
||||
</div>
|
||||
)}
|
||||
{selectedJob.request_metadata.client_ip && (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-[10px] font-medium text-muted-foreground uppercase w-20 shrink-0">Client IP</span>
|
||||
<span className="text-xs font-mono">{selectedJob.request_metadata.client_ip}</span>
|
||||
</div>
|
||||
)}
|
||||
{selectedJob.request_metadata.user_agent && (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-[10px] font-medium text-muted-foreground uppercase w-20 shrink-0">User Agent</span>
|
||||
<span className="text-xs truncate" title={selectedJob.request_metadata.user_agent}>
|
||||
{selectedJob.request_metadata.user_agent}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{selectedJob.request_metadata.server_version && (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-[10px] font-medium text-muted-foreground uppercase w-20 shrink-0">Server Ver</span>
|
||||
<span className="text-xs font-mono">{selectedJob.request_metadata.server_version}</span>
|
||||
</div>
|
||||
)}
|
||||
{selectedJob.request_metadata.created_from && (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-[10px] font-medium text-muted-foreground uppercase w-20 shrink-0">Created From</span>
|
||||
<span className="text-xs">{selectedJob.request_metadata.created_from}</span>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<p className="text-muted-foreground text-xs">No metadata available</p>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
{/* Files Tab */}
|
||||
<TabsContent value="files" className="mt-3">
|
||||
{filesLoading ? (
|
||||
@@ -934,7 +1076,16 @@ function AdminJobsPageContent() {
|
||||
<Loader2 className="w-5 h-5 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
) : files.length === 0 ? (
|
||||
<p className="text-muted-foreground text-sm py-4">No files available</p>
|
||||
<div className="text-center py-8">
|
||||
<p className="text-muted-foreground text-sm">No files available</p>
|
||||
<p className="text-muted-foreground text-xs mt-1">
|
||||
{selectedJob.outputs_deleted_at
|
||||
? `Outputs were deleted on ${formatDateCompact(selectedJob.outputs_deleted_at)}`
|
||||
: selectedJob.status === "complete" || selectedJob.status === "prep_complete"
|
||||
? "Files may have been cleaned up or deleted"
|
||||
: "Files will appear once the job progresses"}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{Object.entries(groupFilesByCategory(files)).map(([category, categoryFiles]) => (
|
||||
@@ -971,119 +1122,6 @@ function AdminJobsPageContent() {
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
{/* Config Tab */}
|
||||
<TabsContent value="config" className="mt-3">
|
||||
<Card>
|
||||
<CardContent className="pt-4 space-y-3">
|
||||
{[
|
||||
{ key: "artist", label: "Artist", value: selectedJob.artist },
|
||||
{ key: "title", label: "Title", value: selectedJob.title },
|
||||
{ key: "user_email", label: "User Email", value: selectedJob.user_email },
|
||||
{ key: "theme_id", label: "Theme", value: selectedJob.theme_id || "default" },
|
||||
{ key: "brand_prefix", label: "Brand Prefix", value: selectedJob.brand_prefix },
|
||||
{ key: "customer_email", label: "Customer Email", value: selectedJob.customer_email },
|
||||
].map(({ key, label, value }) => (
|
||||
<div key={key} className="flex items-center gap-3">
|
||||
<span className="text-xs font-medium text-muted-foreground w-24 shrink-0">{label}</span>
|
||||
{editingField === key ? (
|
||||
<div className="flex items-center gap-2 flex-1">
|
||||
<Input
|
||||
value={editValue}
|
||||
onChange={(e) => setEditValue(e.target.value)}
|
||||
onKeyDown={(e) => handleEditKeyPress(e, key)}
|
||||
className="h-7 text-sm"
|
||||
autoFocus
|
||||
/>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={() => saveField(key)}
|
||||
disabled={saving}
|
||||
>
|
||||
{saving ? (
|
||||
<Loader2 className="w-3 h-3 animate-spin" />
|
||||
) : (
|
||||
<Check className="w-3 h-3 text-green-600" />
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={cancelEditing}
|
||||
disabled={saving}
|
||||
>
|
||||
<X className="w-3 h-3 text-red-600" />
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center gap-2 flex-1 min-w-0">
|
||||
<span className="text-sm truncate flex-1">
|
||||
{value || "—"}
|
||||
</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-6 w-6 opacity-0 group-hover:opacity-100 hover:opacity-100"
|
||||
onClick={() => startEditing(key, value || "")}
|
||||
>
|
||||
<Pencil className="w-3 h-3" />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
{/* Metadata Tab */}
|
||||
<TabsContent value="metadata" className="mt-3">
|
||||
<Card>
|
||||
<CardContent className="pt-4">
|
||||
{selectedJob.request_metadata && Object.keys(selectedJob.request_metadata).length > 0 ? (
|
||||
<div className="grid grid-cols-2 gap-x-6 gap-y-2 text-sm">
|
||||
{selectedJob.request_metadata.environment && (
|
||||
<>
|
||||
<span className="text-muted-foreground text-xs">Environment</span>
|
||||
<span className="text-xs">{selectedJob.request_metadata.environment}</span>
|
||||
</>
|
||||
)}
|
||||
{selectedJob.request_metadata.client_ip && (
|
||||
<>
|
||||
<span className="text-muted-foreground text-xs">Client IP</span>
|
||||
<span className="text-xs font-mono">{selectedJob.request_metadata.client_ip}</span>
|
||||
</>
|
||||
)}
|
||||
{selectedJob.request_metadata.user_agent && (
|
||||
<>
|
||||
<span className="text-muted-foreground text-xs">User Agent</span>
|
||||
<span className="text-xs truncate" title={selectedJob.request_metadata.user_agent}>
|
||||
{selectedJob.request_metadata.user_agent}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
{selectedJob.request_metadata.server_version && (
|
||||
<>
|
||||
<span className="text-muted-foreground text-xs">Server Version</span>
|
||||
<span className="text-xs font-mono">{selectedJob.request_metadata.server_version}</span>
|
||||
</>
|
||||
)}
|
||||
{selectedJob.request_metadata.created_from && (
|
||||
<>
|
||||
<span className="text-muted-foreground text-xs">Created From</span>
|
||||
<span className="text-xs">{selectedJob.request_metadata.created_from}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-muted-foreground text-sm">No metadata available</p>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
{/* Debug Tab */}
|
||||
<TabsContent value="debug" className="mt-3">
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
|
||||
@@ -149,7 +149,7 @@ export default function AdminLayout({
|
||||
</Label>
|
||||
</div>
|
||||
</header>
|
||||
<main className="flex-1 p-4 md:p-6">{children}</main>
|
||||
<main className="flex-1 p-4 md:p-6 min-w-0 overflow-hidden">{children}</main>
|
||||
</SidebarInset>
|
||||
</SidebarProvider>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* Production Debug Script Template
|
||||
*
|
||||
* Use this template when you need to quickly test/debug something in production.
|
||||
* Copy this file and rename it with the .local suffix so it won't be committed:
|
||||
*
|
||||
* cp frontend/e2e/helpers/debug-prod-template.mjs frontend/test-my-issue.local.mjs
|
||||
*
|
||||
* Then customize and run:
|
||||
* cd frontend && node test-my-issue.local.mjs
|
||||
*
|
||||
* IMPORTANT: Files matching test-*.local.* and debug-*.local.* are gitignored,
|
||||
* so you can safely put tokens in them for quick debugging.
|
||||
*
|
||||
* For proper reusable tests, use the existing E2E infrastructure instead:
|
||||
* - frontend/e2e/production/ - Production E2E tests with env var auth
|
||||
* - See docs/TESTING.md for guidance
|
||||
*
|
||||
* Environment variables (set these or hardcode in your .local copy):
|
||||
* KARAOKE_ADMIN_TOKEN - Admin user token (for admin pages)
|
||||
* KARAOKE_ACCESS_TOKEN - Regular user token (for user pages)
|
||||
* DEBUG_JOB_ID - Job ID to test (if applicable)
|
||||
*/
|
||||
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
// ============================================================================
|
||||
// CONFIGURATION - Customize these for your debugging session
|
||||
// ============================================================================
|
||||
|
||||
const BASE_URL = 'https://gen.nomadkaraoke.com';
|
||||
const API_URL = 'https://api.nomadkaraoke.com';
|
||||
|
||||
// Get tokens from environment (recommended) or hardcode in your .local copy
|
||||
const ADMIN_TOKEN = process.env.KARAOKE_ADMIN_TOKEN || process.env.KARAOKE_ACCESS_TOKEN;
|
||||
const JOB_ID = process.env.DEBUG_JOB_ID || null;
|
||||
|
||||
// What page to test - customize this
|
||||
const TARGET_PAGE = JOB_ID
|
||||
? `${BASE_URL}/app/jobs/${JOB_ID}`
|
||||
: `${BASE_URL}/app`;
|
||||
|
||||
// ============================================================================
|
||||
// DEBUG SCRIPT
|
||||
// ============================================================================
|
||||
|
||||
async function debug() {
|
||||
if (!ADMIN_TOKEN) {
|
||||
console.error('ERROR: No token found.');
|
||||
console.error('Set KARAOKE_ADMIN_TOKEN or KARAOKE_ACCESS_TOKEN environment variable,');
|
||||
console.error('or hardcode a token in your .local copy of this script.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('\n=== Production Debug Session ===\n');
|
||||
console.log(`Target: ${TARGET_PAGE}`);
|
||||
console.log(`Token: ${ADMIN_TOKEN.substring(0, 8)}...`);
|
||||
if (JOB_ID) console.log(`Job ID: ${JOB_ID}`);
|
||||
console.log('');
|
||||
|
||||
const browser = await chromium.launch({
|
||||
headless: true, // Set to false to see the browser
|
||||
});
|
||||
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
|
||||
// Collect errors for summary
|
||||
const consoleErrors = [];
|
||||
const httpErrors = [];
|
||||
|
||||
// Capture console errors
|
||||
page.on('console', (msg) => {
|
||||
const text = msg.text();
|
||||
const type = msg.type();
|
||||
if (type === 'error' || text.toLowerCase().includes('error')) {
|
||||
consoleErrors.push({ type, text: text.substring(0, 300) });
|
||||
}
|
||||
});
|
||||
|
||||
// Capture HTTP errors (4xx, 5xx)
|
||||
page.on('response', (response) => {
|
||||
const status = response.status();
|
||||
if (status >= 400) {
|
||||
httpErrors.push({
|
||||
url: response.url(),
|
||||
status,
|
||||
statusText: response.statusText(),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// Set auth token before navigation
|
||||
await page.addInitScript((token) => {
|
||||
localStorage.setItem('karaoke_access_token', token);
|
||||
}, ADMIN_TOKEN);
|
||||
|
||||
// Navigate to target page
|
||||
console.log('1. Navigating to page...');
|
||||
await page.goto(TARGET_PAGE, { waitUntil: 'networkidle', timeout: 30000 });
|
||||
console.log(` URL: ${page.url()}`);
|
||||
|
||||
// Wait for any async loading
|
||||
await page.waitForTimeout(3000);
|
||||
|
||||
// ========================================================================
|
||||
// CUSTOMIZE YOUR DEBUG STEPS HERE
|
||||
// ========================================================================
|
||||
|
||||
// Example: Check what's on the page
|
||||
const bodyText = await page.evaluate(() => document.body.innerText);
|
||||
console.log('\n2. Page content (first 500 chars):');
|
||||
console.log(bodyText.substring(0, 500));
|
||||
console.log('...');
|
||||
|
||||
// Example: List all buttons
|
||||
const buttons = await page.getByRole('button').allTextContents();
|
||||
console.log('\n3. Buttons on page:', buttons.slice(0, 10).join(', '));
|
||||
|
||||
// Example: List all links
|
||||
const links = await page.evaluate(() =>
|
||||
Array.from(document.querySelectorAll('a'))
|
||||
.slice(0, 10)
|
||||
.map((a) => ({ href: a.href, text: a.innerText.trim().substring(0, 30) }))
|
||||
);
|
||||
console.log('\n4. Links on page:', JSON.stringify(links, null, 2));
|
||||
|
||||
// Example: Take a screenshot
|
||||
await page.screenshot({ path: 'debug-screenshot.png', fullPage: true });
|
||||
console.log('\n5. Screenshot saved to debug-screenshot.png');
|
||||
|
||||
// Example: Click something (uncomment and customize)
|
||||
// const btn = page.getByRole('button', { name: /some button/i });
|
||||
// if (await btn.isVisible()) {
|
||||
// await btn.click();
|
||||
// await page.waitForTimeout(2000);
|
||||
// console.log('Clicked button, new URL:', page.url());
|
||||
// }
|
||||
|
||||
// ========================================================================
|
||||
// END CUSTOM STEPS
|
||||
// ========================================================================
|
||||
|
||||
} catch (e) {
|
||||
console.error('\nERROR:', e.message);
|
||||
}
|
||||
|
||||
// Summary
|
||||
console.log('\n--- Console Errors ---');
|
||||
if (consoleErrors.length === 0) {
|
||||
console.log('None');
|
||||
} else {
|
||||
consoleErrors.forEach((err, i) => {
|
||||
console.log(`${i + 1}. [${err.type}] ${err.text}`);
|
||||
});
|
||||
}
|
||||
|
||||
console.log('\n--- HTTP Errors ---');
|
||||
if (httpErrors.length === 0) {
|
||||
console.log('None');
|
||||
} else {
|
||||
httpErrors.forEach((err, i) => {
|
||||
console.log(`${i + 1}. ${err.status} ${err.statusText}: ${err.url}`);
|
||||
});
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
console.log('\n=== Debug session complete ===\n');
|
||||
}
|
||||
|
||||
debug().catch(console.error);
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "karaoke-gen"
|
||||
version = "0.108.6"
|
||||
version = "0.108.7"
|
||||
description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens."
|
||||
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
|
||||
license = "MIT"
|
||||
|
||||
Reference in new issue
Block a user