mirror of
https://github.com/unraid/api.git
synced 2026-01-01 06:01:18 -06:00
- Introduced a new PostCSS plugin, `scopeTailwindToUnapi`, to scope Tailwind CSS classes to specific elements. - Updated Vite configuration to include the new PostCSS plugin for CSS processing. - Enhanced theme management in the theme store to apply scoped classes and dynamic CSS variables to multiple targets, including the document root and elements with the `.unapi` class. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Scoped styling for embedded (.unapi) contexts and a PostCSS plugin to automate it. * Theme refresh after mount to propagate CSS variables to embedded roots. * Exposed idempotent restart action for the Unraid API when offline. * **Bug Fixes** * Consistent dark mode and theme variable application across main and embedded views. * Interactive element and SSO styles now apply in embedded contexts. * Simplified changelog iframe with a reliable fallback renderer; improved logs styling scope. * **Tests** * New unit tests for the scoping plugin, changelog iframe, and related components. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { ref } from 'vue';
|
|
import { createPinia, setActivePinia } from 'pinia';
|
|
|
|
import { beforeEach, vi } from 'vitest';
|
|
|
|
vi.mock('@vue/apollo-composable', async () => {
|
|
const actual =
|
|
await vi.importActual<typeof import('@vue/apollo-composable')>('@vue/apollo-composable');
|
|
|
|
const useQueryMock = vi.fn(() => ({
|
|
result: ref(null),
|
|
loading: ref(false),
|
|
onResult: vi.fn(),
|
|
onError: vi.fn(),
|
|
}));
|
|
|
|
return {
|
|
...actual,
|
|
useQuery: useQueryMock,
|
|
};
|
|
});
|
|
|
|
// Mock WebSocket for test environment
|
|
if (!global.WebSocket) {
|
|
const mockWebSocket = vi.fn().mockImplementation(() => ({
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
close: vi.fn(),
|
|
send: vi.fn(),
|
|
readyState: 1,
|
|
CONNECTING: 0,
|
|
OPEN: 1,
|
|
CLOSING: 2,
|
|
CLOSED: 3,
|
|
}));
|
|
|
|
// Add static properties to match WebSocket interface
|
|
Object.defineProperty(mockWebSocket, 'CONNECTING', { value: 0 });
|
|
Object.defineProperty(mockWebSocket, 'OPEN', { value: 1 });
|
|
Object.defineProperty(mockWebSocket, 'CLOSING', { value: 2 });
|
|
Object.defineProperty(mockWebSocket, 'CLOSED', { value: 3 });
|
|
|
|
global.WebSocket = mockWebSocket as unknown as typeof WebSocket;
|
|
}
|
|
|
|
beforeEach(() => {
|
|
const pinia = createPinia();
|
|
setActivePinia(pinia);
|
|
});
|