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:
40
backend/internal/server/server_test.go
Normal file
40
backend/internal/server/server_test.go
Normal file
@ -0,0 +1,40 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/tradarr/backend/internal/ai"
|
||||
"github.com/tradarr/backend/internal/auth"
|
||||
"github.com/tradarr/backend/internal/config"
|
||||
"github.com/tradarr/backend/internal/generation"
|
||||
"github.com/tradarr/backend/internal/indices"
|
||||
)
|
||||
|
||||
type fakeGeneration struct{}
|
||||
|
||||
func (fakeGeneration) Generate(context.Context, string) (generation.Result, error) {
|
||||
return generation.Result{Outcome: generation.GenerationOutcome{Status: "no_results"}}, nil
|
||||
}
|
||||
|
||||
type fakeSearch struct{ calls int }
|
||||
|
||||
func (f *fakeSearch) Search(context.Context, string, int) ([]indices.Index, error) {
|
||||
f.calls++
|
||||
return []indices.Index{}, nil
|
||||
}
|
||||
func TestInjectableCompositionDoesNotStartSchedulerOrNeedDatabase(t *testing.T) {
|
||||
search := &fakeSearch{}
|
||||
factoryCalls := 0
|
||||
app := New(nil, &config.Config{JWTSecret: "composition-test"}, Dependencies{IndexSearcher: search, GenerationFactory: func(*ai.Pipeline) generation.UseCase { factoryCalls++; return fakeGeneration{} }, EnableScheduler: false})
|
||||
defer app.Close()
|
||||
token, _ := auth.GenerateToken("owner", "owner@example.test", "user", "composition-test")
|
||||
request := httptest.NewRequest("GET", "/api/indices/search?q=test", nil)
|
||||
request.Header.Set("Authorization", "Bearer "+token)
|
||||
response := httptest.NewRecorder()
|
||||
app.Router.ServeHTTP(response, request)
|
||||
if response.Code != 200 || search.calls != 1 || factoryCalls != 1 {
|
||||
t.Fatalf("status=%d search=%d factory=%d", response.Code, search.calls, factoryCalls)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user