A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
test(editor): fix stale entityTemplates imports missed in the E2 rename
esenginea3f6f59e82ae
diff --git a/desktop/tests/create-catalog.test.ts b/desktop/tests/create-catalog.test.tsindex fb92f2a3d..8394b138b 100644--- a/desktop/tests/create-catalog.test.ts+++ b/desktop/tests/create-catalog.test.ts@@ -1,41 +1,36 @@// SPDX-License-Identifier: Apache-2.0// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Teamimport { describe, it, expect } from 'vitest';-import { flattenCatalog, matchCatalog } from '@/engine/entityTemplates';+import { ENTITY_SOURCES, matchSources } from '@/engine/entitySources';-describe('Create catalog (searchable template list)', () => {+describe('Create catalog (searchable source registry)', () => {it('spans Basic / 2D / UI, preserving order + carrying category', () => {- const all = flattenCatalog();- expect(all.map((e) => e.template.label)).toEqual(+ expect(ENTITY_SOURCES.map((s) => s.label)).toEqual(expect.arrayContaining(['Empty', 'Sprite', 'Camera', 'Canvas', 'Button', 'Slider']),);- expect(new Set(all.map((e) => e.category))).toEqual(new Set(['Basic', '2D', 'UI']));+ expect(new Set(ENTITY_SOURCES.map((s) => s.category))).toEqual(new Set(['Basic', '2D', 'UI']));});- it('builds one-entity presets from the registered component defaults', () => {- const all = flattenCatalog();- const camera = all.find((e) => e.template.label === 'Camera')!.template.prefab.entities[0];+ it('builds one-entity presets from the registered component defaults', async () => {+ const camera = (await ENTITY_SOURCES.find((s) => s.label === 'Camera')!.build({ parent: null })).entities[0];expect(camera.components.map((c) => c.type)).toEqual(['Transform', 'Camera']);const cam = camera.components.find((c) => c.type === 'Camera')!.data as Record<string, unknown>;expect(cam.isActive).toBe(true); // orthographic + active come from Camera's defaults- const empty = all.find((e) => e.template.label === 'Empty')!.template.prefab.entities[0];+ const empty = (await ENTITY_SOURCES.find((s) => s.label === 'Empty')!.build({ parent: null })).entities[0];expect(empty.components.map((c) => c.type)).toEqual(['Transform']);});it('matches on item label, case-insensitively', () => {- const all = flattenCatalog();- expect(matchCatalog(all, 'CAM').map((e) => e.template.label)).toEqual(['Camera']);+ expect(matchSources(ENTITY_SOURCES, 'CAM').map((s) => s.label)).toEqual(['Camera']);});it('matches on category label', () => {- const all = flattenCatalog();- expect(matchCatalog(all, '2d').map((e) => e.template.label)).toEqual(['Sprite', 'Camera', 'Particles', 'Light']);+ expect(matchSources(ENTITY_SOURCES, '2d').map((s) => s.label)).toEqual(['Sprite', 'Camera', 'Particles', 'Light']);});it('empty query returns everything; no match returns nothing', () => {- const all = flattenCatalog();- expect(matchCatalog(all, ' ')).toEqual(all);- expect(matchCatalog(all, 'zzzzz')).toEqual([]);+ expect(matchSources(ENTITY_SOURCES, ' ')).toEqual(ENTITY_SOURCES);+ expect(matchSources(ENTITY_SOURCES, 'zzzzz')).toEqual([]);});});diff --git a/desktop/tests/engine-commands.test.ts b/desktop/tests/engine-commands.test.tsindex 89bce481f..c615c2eb8 100644--- a/desktop/tests/engine-commands.test.ts+++ b/desktop/tests/engine-commands.test.ts@@ -32,7 +32,7 @@ vi.mock('@/engine/EngineHost', () => ({}));import { EditorSession } from '@/engine/EditorSession';-import { flattenCatalog } from '@/engine/entityTemplates';+import { ENTITY_SOURCES } from '@/engine/entitySources';import type { SceneData } from 'esengine';const emptyScene = (): SceneData =>@@ -209,9 +209,9 @@ describe.skipIf(!HAS_WASM)('SceneCommands / SceneQuery (headless World)', () =>expect(host.world.valid(ce)).toBe(false);});- it('a non-UI catalog preset (Sprite) instantiates into the World', () => {- const sprite = flattenCatalog().find((c) => c.template.label === 'Sprite')!;- const id = S.commands.createFromTemplate(sprite.template.prefab, null)!;+ it('a non-UI catalog preset (Sprite) instantiates into the World', async () => {+ const sprite = ENTITY_SOURCES.find((s) => s.label === 'Sprite')!;+ const id = S.commands.createFromTemplate(await sprite.build({ parent: null }), null)!;expect(id).not.toBeNull();expect(host.world.has(rt(id), Sprite)).toBe(true);});