mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-05 16:44:22 +00:00
Fixed broken webui tests
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { API_BASE } from '@/lib/api'
|
|
||||||
import { type ReactNode, createContext, useCallback, useContext, useEffect, useState } from 'react'
|
import { type ReactNode, createContext, useCallback, useContext, useEffect, useState } from 'react'
|
||||||
|
|
||||||
interface AuthContextState {
|
interface AuthContextState {
|
||||||
@@ -63,7 +62,7 @@ export const AuthProvider = ({ children }: AuthProviderProps) => {
|
|||||||
// Validate API key by making a test request
|
// Validate API key by making a test request
|
||||||
const validateApiKey = async (key: string): Promise<boolean> => {
|
const validateApiKey = async (key: string): Promise<boolean> => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(API_BASE + '/instances', {
|
const response = await fetch(document.baseURI + 'api/v1/instances', {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${key}`,
|
'Authorization': `Bearer ${key}`,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
||||||
import { instancesApi } from '@/lib/api'
|
import { instancesApi } from '@/lib/api'
|
||||||
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
|
||||||
// Mock fetch globally
|
// Mock fetch globally
|
||||||
const mockFetch = vi.fn()
|
const mockFetch = vi.fn()
|
||||||
@@ -53,7 +53,9 @@ describe('API Error Handling', () => {
|
|||||||
await instancesApi.getLogs('test-instance', 100)
|
await instancesApi.getLogs('test-instance', 100)
|
||||||
|
|
||||||
expect(mockFetch).toHaveBeenCalledWith(
|
expect(mockFetch).toHaveBeenCalledWith(
|
||||||
'/api/v1/instances/test-instance/logs?lines=100',
|
expect.stringMatching(
|
||||||
|
/^https?:\/\/[^/]+\/api\/v1\/instances\/test-instance\/logs\?lines=100$/
|
||||||
|
),
|
||||||
expect.any(Object)
|
expect.any(Object)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user