mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-28 01:56:47 +00:00
5167d8f49e
* feat(ui): add themed startup splash with deferred window show Show a theme-aware loading splash before the Vite bundle mounts, hide the native window until it paints, and use per-theme logo gradient colors. * docs: note startup splash in CHANGELOG and credits for PR #1030 * docs: attribute PR #1030 startup splash to cucadmuh
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import {
|
|
STARTUP_SPLASH_ID,
|
|
configureStartupSplash,
|
|
dismissStartupSplash,
|
|
} from './startupSplash';
|
|
|
|
vi.mock('./windowKind', () => ({
|
|
getWindowKind: vi.fn(() => 'main'),
|
|
}));
|
|
|
|
vi.mock('../utils/themes/startupThemeAppearance', () => ({
|
|
applyStartupSplashThemeFromStorage: vi.fn(() => 'mocha'),
|
|
}));
|
|
|
|
vi.mock('@tauri-apps/api/webviewWindow', () => ({
|
|
getCurrentWebviewWindow: vi.fn(() => ({ show: vi.fn(() => Promise.resolve()) })),
|
|
}));
|
|
|
|
import { getWindowKind } from './windowKind';
|
|
import { applyStartupSplashThemeFromStorage } from '../utils/themes/startupThemeAppearance';
|
|
|
|
describe('startupSplash', () => {
|
|
beforeEach(() => {
|
|
document.body.innerHTML = `<div id="${STARTUP_SPLASH_ID}"></div><div id="root"></div>`;
|
|
vi.mocked(getWindowKind).mockReturnValue('main');
|
|
vi.mocked(applyStartupSplashThemeFromStorage).mockClear();
|
|
});
|
|
|
|
afterEach(() => {
|
|
document.body.innerHTML = '';
|
|
});
|
|
|
|
it('removes splash on mini player webview', () => {
|
|
vi.mocked(getWindowKind).mockReturnValue('mini');
|
|
configureStartupSplash();
|
|
expect(document.getElementById(STARTUP_SPLASH_ID)).toBeNull();
|
|
});
|
|
|
|
it('re-applies theme from storage on main window', () => {
|
|
configureStartupSplash();
|
|
expect(applyStartupSplashThemeFromStorage).toHaveBeenCalled();
|
|
});
|
|
|
|
it('fades out and removes splash', () => {
|
|
vi.useFakeTimers();
|
|
dismissStartupSplash();
|
|
expect(document.getElementById(STARTUP_SPLASH_ID)?.classList.contains('app-startup-splash--hide')).toBe(true);
|
|
vi.runAllTimers();
|
|
expect(document.getElementById(STARTUP_SPLASH_ID)).toBeNull();
|
|
vi.useRealTimers();
|
|
});
|
|
});
|