This commit is contained in:
2026-05-01 00:33:39 +08:00
parent 61969c5116
commit fe02603ba1
68 changed files with 4586 additions and 748 deletions

View File

@@ -4,15 +4,17 @@ import { act, render, screen } from '@testing-library/react';
import { createElement } from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { RouteImageReadyGate } from './RouteImageReadyGate';
import {
collectRouteImageUrls,
extractCssImageUrls,
normalizePreloadImageUrl,
} from './routeImageReadyGateUtils';
import { RouteImageReadyGate } from './RouteImageReadyGate';
import { RouteLoadingScreen } from './RouteLoadingScreen';
afterEach(() => {
vi.useRealTimers();
window.localStorage.clear();
});
describe('RouteImageReadyGate image url helpers', () => {
@@ -84,4 +86,27 @@ describe('RouteImageReadyGate image url helpers', () => {
expect(visibilityGate?.getAttribute('aria-hidden')).toBe('false');
expect(visibilityGate?.style.visibility).toBe('visible');
});
it('uses the saved platform theme tokens for the route loading screen', () => {
window.localStorage.setItem(
'tavernrealms.settings.v1',
JSON.stringify({
version: 1,
musicVolume: 0.42,
platformTheme: 'dark',
}),
);
const { container } = render(
createElement(RouteLoadingScreen, {
eyebrow: '正在载入游戏',
text: '正在载入冒险...',
}),
);
const shell = container.firstElementChild;
expect(shell?.classList.contains('platform-theme')).toBe(true);
expect(shell?.classList.contains('platform-theme--dark')).toBe(true);
expect(shell?.className).toContain('bg-[image:var(--platform-body-fill)]');
});
});