mirror of
https://github.com/Zakkaus/doona.git
synced 2026-12-05 16:02:03 +00:00
apps/lite is a separate Vite app (Astryx, React 19, StyleX) on the same honk API, for people who want to switch nodes and edit groups, subscriptions, nodes, routing and DNS without the observability pages. Every change goes into a draft and one review dialog shows it in plain words before it is written; dae syntax stays in the text editor. It has light and dark themes and a demo mode backed by an in-browser mock. Browser, motion and performance checks in apps/lite/scripts run under Playwright, CI runs `pnpm -C apps/lite check`, and the UI rules are in apps/lite/UI-RULES.md. It is linted with the repository config.
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import {afterEach, expect, test, vi} from 'vitest';
|
|
|
|
const loads = vi.hoisted(() => ({mock: 0}));
|
|
vi.mock('../src/demo/createMockApi', () => {
|
|
loads.mock++;
|
|
return {createMockApi: () => {}};
|
|
});
|
|
|
|
afterEach(() => vi.unstubAllGlobals());
|
|
|
|
test('the sign-in page does not load the demo mock while idle', async () => {
|
|
const idle: Array<() => void> = [];
|
|
vi.stubGlobal('window', {requestIdleCallback: (run: () => void) => idle.push(run), setTimeout});
|
|
vi.stubGlobal('document', {fonts: {ready: Promise.resolve()}, querySelector: () => null});
|
|
vi.stubGlobal('requestAnimationFrame', (run: () => void) => (run(), 0));
|
|
vi.stubGlobal('cancelAnimationFrame', () => {});
|
|
vi.stubGlobal('cancelIdleCallback', () => {});
|
|
const {warmGlyphsDuringIdle} = await import('../src/preload');
|
|
const stop = warmGlyphsDuringIdle('Loading');
|
|
for (let quiet = 0; quiet < 20 && !loads.mock;) {
|
|
await new Promise(resolve => setTimeout(resolve, 5));
|
|
const run = idle.shift();
|
|
if (run) {
|
|
quiet = 0;
|
|
run();
|
|
} else quiet++;
|
|
}
|
|
stop();
|
|
expect(loads.mock).toBe(0);
|
|
});
|