mirror of
https://github.com/unraid/api.git
synced 2026-04-27 18:51:05 -05:00
af5ca11860
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Introduced Docker management UI components: Overview, Logs, Console, Preview, and Edit. - Added responsive Card/Detail layouts with grouping, bulk actions, and tabs. - New UnraidToaster component and global toaster configuration. - Component auto-mounting improved with async loading and multi-selector support. - UI/UX - Overhauled theme system (light/dark tokens, primary/orange accents) and added theme variants. - Header OS version now includes integrated changelog modal. - Registration displays warning states; multiple visual polish updates. - API - CPU load now includes percentGuest and percentSteal metrics. - Chores - Migrated web app to Vite; updated artifacts and manifests. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: mdatelle <mike@datelle.net> Co-authored-by: Michael Datelle <mdatelle@icloud.com>
90 lines
1.9 KiB
TypeScript
90 lines
1.9 KiB
TypeScript
import { ref } from 'vue';
|
|
|
|
import { vi } from 'vitest';
|
|
|
|
// Types for mock data
|
|
export interface MockLogFile {
|
|
content: string;
|
|
totalLines: number;
|
|
startLine: number;
|
|
}
|
|
|
|
export interface MockQueryResult {
|
|
logFile: MockLogFile;
|
|
}
|
|
|
|
/**
|
|
* Creates a mock useQuery return value with optional result data
|
|
* Using unknown return type to avoid complex Apollo type issues in tests
|
|
*/
|
|
export function createMockUseQuery<TData = unknown>(
|
|
resultData: TData | null = null,
|
|
options: {
|
|
loading?: boolean;
|
|
error?: unknown;
|
|
} = {}
|
|
): unknown {
|
|
return {
|
|
result: ref(resultData),
|
|
loading: ref(options.loading ?? false),
|
|
error: ref(options.error ?? null),
|
|
refetch: vi.fn(() =>
|
|
Promise.resolve({
|
|
data: resultData || {},
|
|
loading: false,
|
|
networkStatus: 7,
|
|
stale: false,
|
|
error: undefined,
|
|
})
|
|
),
|
|
subscribeToMore: vi.fn(),
|
|
networkStatus: ref(7),
|
|
start: vi.fn(),
|
|
stop: vi.fn(),
|
|
restart: vi.fn(),
|
|
forceDisabled: ref(false),
|
|
document: ref(null),
|
|
variables: ref({}),
|
|
options: {},
|
|
query: ref(null),
|
|
fetchMore: vi.fn(),
|
|
updateQuery: vi.fn(),
|
|
onResult: vi.fn(),
|
|
onError: vi.fn(),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a mock useQuery specifically for log file data
|
|
*/
|
|
export function createMockLogFileQuery(
|
|
content: string,
|
|
totalLines: number,
|
|
startLine: number = 1
|
|
): unknown {
|
|
const result: MockQueryResult = {
|
|
logFile: {
|
|
content,
|
|
totalLines,
|
|
startLine,
|
|
},
|
|
};
|
|
|
|
return createMockUseQuery(result);
|
|
}
|
|
|
|
/**
|
|
* Factory function to create the mock module object for @vue/apollo-composable
|
|
* Call this at the top level of test files: vi.mock('@vue/apollo-composable', () => apolloComposableMockFactory())
|
|
*/
|
|
export function apolloComposableMockFactory() {
|
|
return {
|
|
useApolloClient: vi.fn(() => ({
|
|
client: {
|
|
query: vi.fn(),
|
|
},
|
|
})),
|
|
useQuery: vi.fn(() => createMockUseQuery()),
|
|
};
|
|
}
|