feat: productionize learning engine and classroom

This commit is contained in:
inman
2026-08-16 21:44:52 +08:00
parent 2d04197f3f
commit ba35adfbfa
124 changed files with 9071 additions and 796 deletions

View File

@@ -0,0 +1,33 @@
// @vitest-environment jsdom
import { afterEach, describe, expect, it, vi } from 'vitest';
import {
emitMakelorePlaybackProgress,
MAKELORE_PLAYBACK_PROGRESS_EVENT,
} from '@/lib/makelore-runtime/progress-events';
afterEach(() => {
delete window.__MAKELORE_OFFLINE_PLAYER__;
vi.restoreAllMocks();
});
describe('offline player playback progress events', () => {
it('publishes action-level and completion state only in the offline player', () => {
const listener = vi.fn();
window.addEventListener(MAKELORE_PLAYBACK_PROGRESS_EVENT, listener);
const detail = {
sceneId: 'scene-2',
sceneOrder: 2,
actionIndex: 4,
completed: true,
};
emitMakelorePlaybackProgress(detail);
expect(listener).not.toHaveBeenCalled();
window.__MAKELORE_OFFLINE_PLAYER__ = true;
emitMakelorePlaybackProgress(detail);
expect(listener).toHaveBeenCalledOnce();
expect((listener.mock.calls[0]![0] as CustomEvent).detail).toEqual(detail);
window.removeEventListener(MAKELORE_PLAYBACK_PROGRESS_EVENT, listener);
});
});