diff --git a/backend/internal/api/handlers/handlers_test.go b/backend/internal/api/handlers/handlers_test.go index 3a0a9ce4..0625d74d 100644 --- a/backend/internal/api/handlers/handlers_test.go +++ b/backend/internal/api/handlers/handlers_test.go @@ -18,7 +18,7 @@ import ( ) func setupTestDB() *gorm.DB { - db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{}) + db, err := gorm.Open(sqlite.Open("file::memory:"), &gorm.Config{}) if err != nil { panic("failed to connect to test database") } diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index fea68f28..ce8ee4d2 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -4,6 +4,7 @@ version: '3.9' services: app: + image: ghcr.io/wikid82/caddyproxymanagerplus:dev # Development: expose Caddy admin API externally for debugging ports: - "80:80" diff --git a/docker-compose.yml b/docker-compose.yml index f600a82d..559c1ec7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,7 @@ version: '3.9' services: app: - build: - context: . - dockerfile: Dockerfile + image: ghcr.io/wikid82/caddyproxymanagerplus:latest container_name: caddyproxymanagerplus restart: unless-stopped ports: diff --git a/frontend/src/hooks/__tests__/useProxyHosts.test.ts b/frontend/src/hooks/__tests__/useProxyHosts.test.ts index 6be5b47f..893733c7 100644 --- a/frontend/src/hooks/__tests__/useProxyHosts.test.ts +++ b/frontend/src/hooks/__tests__/useProxyHosts.test.ts @@ -75,7 +75,9 @@ describe('useProxyHosts', () => { await result.current.createHost(newHost) expect(api.proxyHostsAPI.create).toHaveBeenCalledWith(newHost) - expect(api.proxyHostsAPI.list).toHaveBeenCalledTimes(2) // Initial load + reload after create + await waitFor(() => { + expect(result.current.hosts).toContainEqual(createdHost) + }) }) it('updates an existing proxy host', async () => { @@ -94,7 +96,9 @@ describe('useProxyHosts', () => { await result.current.updateHost('1', { domain_names: 'updated.com' }) expect(api.proxyHostsAPI.update).toHaveBeenCalledWith('1', { domain_names: 'updated.com' }) - expect(api.proxyHostsAPI.list).toHaveBeenCalledTimes(2) + await waitFor(() => { + expect(result.current.hosts[0].domain_names).toBe('updated.com') + }) }) it('deletes a proxy host', async () => { @@ -114,7 +118,10 @@ describe('useProxyHosts', () => { await result.current.deleteHost('1') expect(api.proxyHostsAPI.delete).toHaveBeenCalledWith('1') - expect(api.proxyHostsAPI.list).toHaveBeenCalledTimes(2) + await waitFor(() => { + expect(result.current.hosts).toHaveLength(1) + expect(result.current.hosts[0].uuid).toBe('2') + }) }) it('handles create errors', async () => { diff --git a/frontend/src/hooks/__tests__/useRemoteServers.test.ts b/frontend/src/hooks/__tests__/useRemoteServers.test.ts index 1b122a05..4a917831 100644 --- a/frontend/src/hooks/__tests__/useRemoteServers.test.ts +++ b/frontend/src/hooks/__tests__/useRemoteServers.test.ts @@ -99,7 +99,9 @@ describe('useRemoteServers', () => { await result.current.createServer(newServer) expect(api.remoteServersAPI.create).toHaveBeenCalledWith(newServer) - expect(api.remoteServersAPI.list).toHaveBeenCalledTimes(2) + await waitFor(() => { + expect(result.current.servers).toContainEqual(createdServer) + }) }) it('updates an existing remote server', async () => { @@ -118,7 +120,9 @@ describe('useRemoteServers', () => { await result.current.updateServer('1', { name: 'Updated Server' }) expect(api.remoteServersAPI.update).toHaveBeenCalledWith('1', { name: 'Updated Server' }) - expect(api.remoteServersAPI.list).toHaveBeenCalledTimes(2) + await waitFor(() => { + expect(result.current.servers[0].name).toBe('Updated Server') + }) }) it('deletes a remote server', async () => { @@ -138,7 +142,10 @@ describe('useRemoteServers', () => { await result.current.deleteServer('1') expect(api.remoteServersAPI.delete).toHaveBeenCalledWith('1') - expect(api.remoteServersAPI.list).toHaveBeenCalledTimes(2) + await waitFor(() => { + expect(result.current.servers).toHaveLength(1) + expect(result.current.servers[0].uuid).toBe('2') + }) }) it('tests server connection', async () => { diff --git a/frontend/src/hooks/useRemoteServers.ts b/frontend/src/hooks/useRemoteServers.ts index 0382837a..02c6de8f 100644 --- a/frontend/src/hooks/useRemoteServers.ts +++ b/frontend/src/hooks/useRemoteServers.ts @@ -66,13 +66,25 @@ export function useRemoteServers() { } } + const testConnection = async (uuid: string) => { + try { + return await remoteServersAPI.test(uuid) + } catch (err) { + throw new Error(err instanceof Error ? err.message : 'Failed to test connection') + } + } + + const enabledServers = servers.filter(s => s.enabled) + return { servers, + enabledServers, loading, error, refresh: fetchServers, createServer, updateServer, deleteServer, + testConnection, } }