Skip to content

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.

fix: resolve remaining CI failures in glad loader and editor tests

esengine3fa56c8f9836
diff --git a/editor/src/__tests__/PlayModeService.test.ts b/editor/src/__tests__/PlayModeService.test.ts
index 24665ed43..be5adc60a 100644
--- a/editor/src/__tests__/PlayModeService.test.ts
+++ b/editor/src/__tests__/PlayModeService.test.ts
@@ -108,6 +108,13 @@ vi.mock('../container/EditorContainer', () => ({
setEditorContainer: vi.fn(),
}));
+vi.mock('../services/ScriptInjector', () => ({
+ ScriptInjector: vi.fn().mockImplementation(() => ({
+ inject: vi.fn(),
+ dispose: vi.fn(),
+ })),
+}));
+
vi.mock('../asset', () => ({
getAssetDatabase: vi.fn(() => ({
getAllEntries: vi.fn(() => mockDbEntries[Symbol.iterator]()),
@@ -116,13 +123,16 @@ vi.mock('../asset', () => ({
}));
import { getPlayModeService, PlayModeService } from '../services/PlayModeService';
-import { PLAY_MODE_SERVICE } from '../container/tokens';
+import { PLAY_MODE_SERVICE, SCRIPT_SERVICE } from '../container/tokens';
describe('PlayModeService — SceneManager integration', () => {
let service: ReturnType<typeof getPlayModeService>;
beforeEach(() => {
vi.clearAllMocks();
+ mockContainer.provide(SCRIPT_SERVICE, 'default', {
+ getCompiledScripts: vi.fn(() => null),
+ });
mockContainer.provide(PLAY_MODE_SERVICE, 'default', new PlayModeService());
service = getPlayModeService();
});
diff --git a/editor/src/__tests__/asset/AssetTypeBehavior.test.ts b/editor/src/__tests__/asset/AssetTypeBehavior.test.ts
index 10be3f439..265913277 100644
--- a/editor/src/__tests__/asset/AssetTypeBehavior.test.ts
+++ b/editor/src/__tests__/asset/AssetTypeBehavior.test.ts
@@ -1,4 +1,5 @@
-import { describe, it, expect, beforeEach } from 'vitest';
+import { describe, it, expect, beforeEach, vi } from 'vitest';
+import { EditorContainer, setEditorContainer } from '../../container/EditorContainer';
import {
resetAssetTypeRegistry,
registerBuiltinAssetTypes,
@@ -7,6 +8,8 @@ import {
getInspectorRenderer,
} from '../../asset/AssetTypeRegistry';
+setEditorContainer(new EditorContainer());
+
describe('AssetTypeRegistry behavior dispatch', () => {
beforeEach(() => {
resetAssetTypeRegistry();
diff --git a/editor/src/__tests__/asset/AssetTypeConsumers.test.ts b/editor/src/__tests__/asset/AssetTypeConsumers.test.ts
index b213d7c47..3fea336bd 100644
--- a/editor/src/__tests__/asset/AssetTypeConsumers.test.ts
+++ b/editor/src/__tests__/asset/AssetTypeConsumers.test.ts
@@ -1,4 +1,5 @@
import { describe, it, expect, beforeEach } from 'vitest';
+import { EditorContainer, setEditorContainer } from '../../container/EditorContainer';
import {
resetAssetTypeRegistry,
registerBuiltinAssetTypes,
@@ -6,6 +7,8 @@ import {
getAssetTypeDisplayName,
getDisplayType,
} from '../../asset/AssetTypeRegistry';
+
+setEditorContainer(new EditorContainer());
import { getAssetIcon, getAssetType } from '../../panels/content-browser/ContentBrowserTypes';
describe('ContentBrowserTypes delegates to Registry', () => {
diff --git a/editor/src/__tests__/asset/AssetTypeRegistry.test.ts b/editor/src/__tests__/asset/AssetTypeRegistry.test.ts
index 355984268..315a5444d 100644
--- a/editor/src/__tests__/asset/AssetTypeRegistry.test.ts
+++ b/editor/src/__tests__/asset/AssetTypeRegistry.test.ts
@@ -1,4 +1,5 @@
import { describe, it, expect, beforeEach } from 'vitest';
+import { EditorContainer, setEditorContainer } from '../../container/EditorContainer';
import {
registerAssetType,
getAssetTypeDescriptor,
@@ -13,6 +14,8 @@ import {
type AssetTypeDescriptor,
} from '../../asset/AssetTypeRegistry';
+setEditorContainer(new EditorContainer());
+
describe('AssetTypeRegistry', () => {
beforeEach(() => {
resetAssetTypeRegistry();
diff --git a/editor/src/__tests__/panels/OutputPanel.test.ts b/editor/src/__tests__/panels/OutputPanel.test.ts
index 5284a3789..4ec6cb760 100644
--- a/editor/src/__tests__/panels/OutputPanel.test.ts
+++ b/editor/src/__tests__/panels/OutputPanel.test.ts
@@ -1,4 +1,11 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
+
+vi.mock('../../services', () => ({
+ getOutputService: vi.fn(() => ({
+ registerOutputHandler: vi.fn(() => () => {}),
+ })),
+}));
+
import { OutputPanel } from '../../panels/OutputPanel';
describe('OutputPanel', () => {
diff --git a/editor/src/__tests__/panels/TimelineCommands.test.ts b/editor/src/__tests__/panels/TimelineCommands.test.ts
index 6dd8a4287..4e4523dce 100644
--- a/editor/src/__tests__/panels/TimelineCommands.test.ts
+++ b/editor/src/__tests__/panels/TimelineCommands.test.ts
@@ -58,7 +58,7 @@ describe('TimelineCommands', () => {
const kfs = (data.tracks[0] as any).channels[0].keyframes;
expect(kfs).toHaveLength(4);
- expect(kfs[1]).toEqual({ time: 0.5, value: 0.5 });
+ expect(kfs[1]).toEqual({ time: 0.5, value: 0.5, inTangent: 0, outTangent: 0 });
});
it('should insert keyframe in sorted time order', () => {
diff --git a/editor/vitest.config.ts b/editor/vitest.config.ts
index 9d7c72ef8..2dacc877d 100644
--- a/editor/vitest.config.ts
+++ b/editor/vitest.config.ts
@@ -22,6 +22,8 @@ export default defineConfig({
},
resolve: {
alias: {
+ 'esengine/physics': path.resolve(__dirname, '../sdk/dist/physics/index.js'),
+ 'esengine/spine': path.resolve(__dirname, '../sdk/dist/spine/index.js'),
'esengine': path.resolve(__dirname, '../sdk/dist/index.js'),
},
},
diff --git a/third_party/glad/include/glad/glad.h b/third_party/glad/include/glad/glad.h
index d56fb97cd..94d1fb491 100644
--- a/third_party/glad/include/glad/glad.h
+++ b/third_party/glad/include/glad/glad.h
@@ -456,6 +456,10 @@ GLAPI PFNGLSTENCILFUNCPROC glad_glStencilFunc;
GLAPI PFNGLSTENCILOPPROC glad_glStencilOp;
GLAPI PFNGLSTENCILMASKPROC glad_glStencilMask;
+/* ReadPixels */
+typedef void (APIENTRYP PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
+GLAPI PFNGLREADPIXELSPROC glad_glReadPixels;
+
/* Framebuffer */
GLAPI PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
GLAPI PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
@@ -556,6 +560,7 @@ GLAPI PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
#define glStencilFunc glad_glStencilFunc
#define glStencilOp glad_glStencilOp
#define glStencilMask glad_glStencilMask
+#define glReadPixels glad_glReadPixels
#define glGenFramebuffers glad_glGenFramebuffers
#define glDeleteFramebuffers glad_glDeleteFramebuffers
diff --git a/third_party/glad/src/glad.c b/third_party/glad/src/glad.c
index 479c586b6..6b9696f05 100644
--- a/third_party/glad/src/glad.c
+++ b/third_party/glad/src/glad.c
@@ -110,6 +110,7 @@ PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
+PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
/* Framebuffer */
PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
@@ -226,6 +227,7 @@ int gladLoadGLLoader(GLADloadproc load) {
glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load("glStencilFunc");
glad_glStencilOp = (PFNGLSTENCILOPPROC)load("glStencilOp");
glad_glStencilMask = (PFNGLSTENCILMASKPROC)load("glStencilMask");
+ glad_glReadPixels = (PFNGLREADPIXELSPROC)load("glReadPixels");
/* Framebuffer */
glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers");