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
fix(gates): the service-support check runs where its subject compiles
esengine79a835ba9926
diff --git a/pipeline/tests/service-support.test.ts b/pipeline/tests/service-support.test.tsindex 711025969..96ce18cce 100644--- a/pipeline/tests/service-support.test.ts+++ b/pipeline/tests/service-support.test.ts@@ -1,20 +1,15 @@// SPDX-License-Identifier: Apache-2.0// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team/**- * What the build dialog says a target can do has to stay true to the adapter- * that target will install and to the vendor declaration it cites. Both are in- * this checkout, so a `yes` names members the vendor's own typings declare, and- * Douyin's "sells nothing" is read off the profile's empty `pay` slot.+ * A `yes` in the build dialog names members the vendor's own typings declare.+ * The other half — that the table matches the adapter and profile a build will+ * install — is in `sdk/tests/service-support.test.ts`, beside its subject.*/import { describe, it, expect } from 'vitest';import { readFileSync } from 'node:fs';import { createRequire } from 'node:module';import { BUILTIN_PLATFORMS } from '../src/project/platforms';-import { GAME_SERVICES, builtinServiceSupport, type GameService } from '../src/project/serviceSupport';-import { douyinProfile } from '../../sdk/src/platform/douyin/profile';--const supportOf = (platform: string, service: GameService): string | undefined =>- builtinServiceSupport(platform).find((s) => s.service === service)?.support;+import { GAME_SERVICES, builtinServiceSupport } from '../src/project/serviceSupport';/** WeChat's own published API declaration, as depended on by the SDK. */const wechatTypings = (): string => {@@ -35,14 +30,6 @@ describe('service support', () => {expect(builtinServiceSupport('acme-tv')).toEqual([]);});- it('reports purchase on Douyin exactly as the profile decides it', () => {- // The family's payment is WeChat's call with WeChat's rules, so a vendor- // that has not filled `pay` sells nothing — fill it and this goes red,- // which is the point: the dialog would still be saying "no".- expect(douyinProfile.pay === undefined).toBe(supportOf('douyin', 'purchase') === 'no');- expect(supportOf('douyin', 'purchase')).toBe('no');- });-it('claims yes only for members WeChat itself declares', () => {const typings = wechatTypings();let checked = 0;@@ -63,18 +50,4 @@ describe('service support', () => {// at all would pass every assertion above and check nothing.expect(checked).toBeGreaterThanOrEqual(4);});-- it('says no host above the game wherever the adapter declares no such method', async () => {- const { webAdapter } = await import('../../sdk/src/platform/web');- const declared = {- ads: webAdapter.createRewardedAd !== undefined,- share: webAdapter.share !== undefined,- signIn: webAdapter.login !== undefined,- purchase: webAdapter.requestPayment !== undefined,- };- for (const [service, present] of Object.entries(declared)) {- expect(present, `the web adapter declares ${service}`).toBe(false);- expect(supportOf('web', service as GameService)).toBe('no');- }- });});diff --git a/sdk/tests/service-support.test.ts b/sdk/tests/service-support.test.tsnew file mode 100644index 000000000..a9f026320--- /dev/null+++ b/sdk/tests/service-support.test.ts@@ -0,0 +1,41 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team++// Here rather than beside the table it checks: the subject is the adapter and+// the profile a build installs, and reaching them from the pipeline drags the+// whole platform layer into the pipeline's type program.+import { describe, it, expect } from 'vitest';+import { builtinServiceSupport, type GameService } from '../../pipeline/src/project/serviceSupport';+import { douyinProfile } from '../src/platform/douyin/profile';+import { webAdapter } from '../src/platform/web';+import type { PlatformAdapter } from '../src/platform/types';++const supportOf = (platform: string, service: GameService): string | undefined =>+ builtinServiceSupport(platform).find((s) => s.service === service)?.support;++describe('what the build dialog promises matches what will be installed', () => {+ it('reports purchase on Douyin exactly as the profile decides it', () => {+ // The family's payment is WeChat's call with WeChat's rules, so a vendor+ // that has not filled `pay` sells nothing — fill it and this goes red,+ // which is the point: the dialog would still be saying "no".+ expect(douyinProfile.pay === undefined).toBe(supportOf('douyin', 'purchase') === 'no');+ expect(supportOf('douyin', 'purchase')).toBe('no');+ });++ it('says no host above the game wherever the adapter declares no such method', () => {+ // Read through `PlatformAdapter`, where these are DECLARED optional:+ // asking the concrete class is a question the compiler answers for us,+ // and the names would stop being the interface's.+ const adapter: PlatformAdapter = webAdapter;+ const declared: Record<GameService | string, boolean> = {+ ads: adapter.createRewardedAd !== undefined,+ share: adapter.share !== undefined,+ signIn: adapter.login !== undefined,+ purchase: adapter.requestPayment !== undefined,+ };+ for (const [service, present] of Object.entries(declared)) {+ expect(present, `the web adapter declares ${service}`).toBe(false);+ expect(supportOf('web', service as GameService)).toBe('no');+ }+ });+});