Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions internal/api/smoke_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package api

import (
"context"
"net"
"net/http"
"testing"
"time"
)

// TestSmoke_ServerStartsAndResponds verifies the server starts on a random port
// and key API endpoints respond. This is the smoke-level test (QG-1 gate):
// "server starts and responds without panicking".
func TestSmoke_ServerStartsAndResponds(t *testing.T) {
s, _ := setupTestServer(t)

// Replace the address with a random free port.
ln, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatalf("listen: %v", err)
}
addr := ln.Addr().String()
s.httpServer.Addr = addr
ln.Close()

// Start the server in a goroutine.
go func() {
_ = s.Start()
}()

// Give it a moment to bind.
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
for {
conn, err := net.DialTimeout("tcp", addr, 100*time.Millisecond)
if err == nil {
conn.Close()
break
}
select {
case <-ctx.Done():
t.Fatalf("server did not start within 3s: %v", err)
case <-time.After(50 * time.Millisecond):
}
}
defer s.Shutdown(context.Background())

baseURL := "http://" + addr
client := &http.Client{Timeout: 5 * time.Second}

// Smoke: GET /api/features should return 200 with a JSON array.
resp, err := client.Get(baseURL + "/api/features")
if err != nil {
t.Fatalf("GET /api/features: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
t.Errorf("GET /api/features: status = %d, want 200", resp.StatusCode)
}

// Smoke: GET /api/repos should return 200.
resp2, err := client.Get(baseURL + "/api/repos")
if err != nil {
t.Fatalf("GET /api/repos: %v", err)
}
defer resp2.Body.Close()
if resp2.StatusCode != http.StatusOK {
t.Errorf("GET /api/repos: status = %d, want 200", resp2.StatusCode)
}

// Smoke: GET /api/settings/defaults should return 200.
resp3, err := client.Get(baseURL + "/api/settings/defaults")
if err != nil {
t.Fatalf("GET /api/settings/defaults: %v", err)
}
defer resp3.Body.Close()
if resp3.StatusCode != http.StatusOK {
t.Errorf("GET /api/settings/defaults: status = %d, want 200", resp3.StatusCode)
}

// Smoke: GET /api/config/providers should return 200 (multi-provider feature).
resp4, err := client.Get(baseURL + "/api/config/providers")
if err != nil {
t.Fatalf("GET /api/config/providers: %v", err)
}
defer resp4.Body.Close()
if resp4.StatusCode != http.StatusOK {
t.Errorf("GET /api/config/providers: status = %d, want 200", resp4.StatusCode)
}
}
67 changes: 67 additions & 0 deletions ui/e2e/providers.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { test, expect } from '@playwright/test';

// Multi-provider LLM configuration E2E — covers the AdminProvidersPage
// (feature multi-provider-llm-configuration).
// Tests run against the running devteam server (same target as admin.spec.ts).

test.describe('Admin Providers UI', () => {

test('providers page renders with effect-timing banner', async ({ page }) => {
await page.goto('/admin/providers');

await expect(page.locator('[data-testid="admin-providers-page"]')).toBeVisible();
await expect(page.locator('[data-testid="effect-timing-banner"]')).toBeVisible();
await expect(page.locator('[data-testid="effect-timing-banner"]')).toContainText(
'Config changes take effect at the next agent dispatch'
);
});

test('operator section shows add-provider button', async ({ page }) => {
await page.goto('/admin/providers');

const operatorSection = page.locator('[data-testid="operator-section"]');
await expect(operatorSection).toBeVisible();

const addBtn = page.locator('[data-testid="add-provider-modal"]');
if (await addBtn.isVisible()) {
await addBtn.click();
await expect(page.locator('[data-testid="add-provider-confirm"]')).toBeVisible();
}
});

test('tier matrix is visible when providers are enabled', async ({ page }) => {
await page.goto('/admin/providers');

// The tier matrix may or may not be visible depending on whether
// providers are configured. Just verify the container exists.
const tierMatrix = page.locator('[data-testid="tier-matrix"]');
const isVisible = await tierMatrix.isVisible().catch(() => false);
if (isVisible) {
// If visible, at least one tier row should be present.
const tierRows = page.locator('[data-testid^="tier-row-"]');
await expect(tierRows.first()).toBeVisible();
}
});

test('role overrides editor section exists', async ({ page }) => {
await page.goto('/admin/providers');

// The role overrides editor may be empty but the container should exist.
const overridesEditor = page.locator('[data-testid="role-overrides-editor"]');
await expect(overridesEditor).toBeVisible();
});

test('navigating to /admin/providers from admin shell', async ({ page }) => {
await page.goto('/admin');

// The admin shell should have a link or tab to the providers page.
// PR #94 added /admin/providers as a separate route.
// Check if there's a link to /admin/providers.
const providersLink = page.locator('a[href="/admin/providers"]');
if (await providersLink.count() > 0) {
await providersLink.click();
await expect(page).toHaveURL(/\/admin\/providers/);
await expect(page.locator('[data-testid="admin-providers-page"]')).toBeVisible();
}
});
});
Loading