test(e2e): add isolated browser journey and cleanup supervision

Add a fake-only end-to-end stack, Firefox journey, and bounded process cleanup for normal, failed, and interrupted runs.

Refs #12

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 23:39:02 +01:00
parent 8f42c30ec6
commit 4459a81206
28 changed files with 1647 additions and 51 deletions

View File

@ -0,0 +1,51 @@
// Package server composes HTTP and optional scheduled application execution.
// Concrete retrieval/provider adapters belong to the executable's composition root.
package server
import (
"github.com/gin-gonic/gin"
"github.com/tradarr/backend/internal/ai"
"github.com/tradarr/backend/internal/api"
"github.com/tradarr/backend/internal/api/handlers"
"github.com/tradarr/backend/internal/config"
"github.com/tradarr/backend/internal/crypto"
"github.com/tradarr/backend/internal/generation"
"github.com/tradarr/backend/internal/indices"
"github.com/tradarr/backend/internal/models"
"github.com/tradarr/backend/internal/scheduler"
"github.com/tradarr/backend/internal/scraper"
"log"
)
type Dependencies struct {
Feeds map[string]scraper.Scraper
IndexSearcher indices.IndexSearcher
GenerationFactory func(*ai.Pipeline) generation.UseCase
EnableScheduler bool
}
type App struct {
Router *gin.Engine
scheduler *scheduler.Scheduler
}
func New(repo *models.Repository, cfg *config.Config, deps Dependencies) *App {
enc := crypto.New(cfg.EncryptionKey)
pipeline := ai.NewPipeline(repo, enc)
registry := scraper.NewRegistry(repo)
uc := pipeline.NewGenerationUseCase(deps.Feeds)
if deps.GenerationFactory != nil {
uc = deps.GenerationFactory(pipeline)
}
sched := scheduler.New(registry, pipeline, repo)
sched.SetGenerationUseCase(uc)
if deps.EnableScheduler {
if err := sched.Start(); err != nil {
log.Printf("scheduler: %v", err)
}
}
h := handlers.New(repo, cfg, enc, registry, pipeline, sched)
h.SetGenerationUseCase(uc)
h.SetIndexSearcher(deps.IndexSearcher)
return &App{Router: api.SetupRouter(h, cfg.JWTSecret), scheduler: sched}
}
func (a *App) Close() { a.scheduler.Stop() }