@tbox.cn/app-provider-mock 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -35
- package/dist/server/index.d.ts +44 -46
- package/dist/server/index.js +64 -88
- package/package.json +6 -6
- package/src/server/index.ts +31 -20
- package/src/server/mall-info.ts +11 -13
- package/src/server/member.ts +13 -18
- package/src/server/mock-enroll-route.ts +12 -11
- package/src/server/parking.ts +20 -25
- package/src/server/promotion.ts +11 -16
- package/src/server/shopping.ts +11 -16
- package/tbox.module.json +27 -42
- package/tests/integrations-e2e.test.ts +50 -110
- package/tests/mall-info.test.ts +0 -9
- package/tests/mock-impl.test.ts +18 -121
- package/tsup.config.ts +2 -1
- package/schemas/mall-info.config.json +0 -11
- package/schemas/member.config.json +0 -13
- package/schemas/parking.config.json +0 -19
- package/schemas/promotion.config.json +0 -13
- package/schemas/shopping.config.json +0 -12
- package/src/server/config.ts +0 -26
- package/tests/config-schema.test.ts +0 -92
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* mock 实现经槽位轴产出(demo ref 厂商中立)。
|
|
6
6
|
*/
|
|
7
7
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
8
|
-
import { createIntegrationsRegistry, createAuthStrategyRegistry, createEnvironmentSecretProvider, createServerContext } from '@tbox.cn/app-sdk
|
|
9
|
-
import { serverModule,
|
|
8
|
+
import { createIntegrationsRegistry, createAuthStrategyRegistry, createEnvironmentSecretProvider, createServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
9
|
+
import { serverModule, enrollMockMember, logoutMockMember, __resetMockMemberState } from '../src/server/index';
|
|
10
10
|
import { mallControlPlaneOf } from '@tbox.cn/app-contracts-mall/server';
|
|
11
11
|
import type { IntegrationsConfig } from '@tbox.cn/app-contracts';
|
|
12
12
|
import type { RequestContext } from '@tbox.cn/app-contracts';
|
|
@@ -49,16 +49,17 @@ const catalog = {
|
|
|
49
49
|
|
|
50
50
|
function requestContext(mallId = 'mall-demo'): RequestContext {
|
|
51
51
|
return {
|
|
52
|
-
identity: { userId: '
|
|
53
|
-
credentials: { provider: '
|
|
52
|
+
identity: { userId: 'local_u1', source: 'local' },
|
|
53
|
+
credentials: { provider: 'mock', token: 't' },
|
|
54
54
|
attributes: { mall: { mallId } },
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function fixtureCtx(integrationsOverride?: IntegrationsConfig) {
|
|
58
|
+
function fixtureCtx(integrationsOverride?: IntegrationsConfig, ownerOf?: Record<string, string>) {
|
|
59
59
|
const registry = createIntegrationsRegistry({
|
|
60
60
|
integrations: integrationsOverride ?? integrations,
|
|
61
61
|
catalog,
|
|
62
|
+
...(ownerOf ? { ownerOf } : {}),
|
|
62
63
|
authStrategies: createAuthStrategyRegistry(),
|
|
63
64
|
secretProvider: createEnvironmentSecretProvider({ source: {}, production: false }),
|
|
64
65
|
instanceIdOf: (scope) => scope.mallId ?? '',
|
|
@@ -169,136 +170,75 @@ describe('C5:scoped mock 换码器(入会闭环身份供给)', () => {
|
|
|
169
170
|
it('未选择商场(无 mallId)→ exchangeByCode 抛 AUTH_NOT_CONFIGURED 未选择商场', async () => {
|
|
170
171
|
const { ctx } = fixtureCtx();
|
|
171
172
|
const exchanger = ctx.authExchanges.get('alipay')!;
|
|
172
|
-
await expect(exchanger.exchangeByCode('any-authcode'
|
|
173
|
+
await expect(exchanger.exchangeByCode({ code: 'any-authcode' })).rejects.toThrow(/未选择商场/);
|
|
173
174
|
});
|
|
174
175
|
|
|
175
|
-
it('GUEST
|
|
176
|
+
it('随机访客身份 + GUEST 形态(T17):guest_<32hex> 每次新随机;token="" + openid 键控', async () => {
|
|
176
177
|
const { ctx } = fixtureCtx();
|
|
177
178
|
const exchanger = ctx.authExchanges.get('alipay', { mall: { mallId: 'mall-demo' } })!;
|
|
178
|
-
const
|
|
179
|
-
expect(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
const r1 = await exchanger.exchangeByCode({ code: 'c1', context: { mall: { mallId: 'mall-demo' } } });
|
|
180
|
+
expect(r1.identity.source).toBe('guest');
|
|
181
|
+
expect(r1.identity.userId).toMatch(/^guest_[0-9a-f]{32}$/);
|
|
182
|
+
expect(r1.credentials).toEqual({ token: '', provider: 'mock', attributes: { openid: `demo:openid:${r1.identity.userId}` } });
|
|
183
|
+
// 每次冷登新随机(无 previousIdentity)
|
|
184
|
+
const r2 = await exchanger.exchangeByCode({ code: 'c2', context: { mall: { mallId: 'mall-demo' } } });
|
|
185
|
+
expect(r2.identity.userId).not.toBe(r1.identity.userId);
|
|
183
186
|
});
|
|
184
187
|
|
|
185
|
-
it('
|
|
186
|
-
enrollMockMember(MOCK_SHELL_USER_ID);
|
|
188
|
+
it('previousIdentity 复用轨:guest 同 sub 续签(enroll 后 MEMBER 形态、会话归属连续)', async () => {
|
|
187
189
|
const { ctx } = fixtureCtx();
|
|
188
190
|
const exchanger = ctx.authExchanges.get('alipay', { mall: { mallId: 'mall-demo' } })!;
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
const first = await exchanger.exchangeByCode({ code: 'c1', context: { mall: { mallId: 'mall-demo' } } });
|
|
192
|
+
enrollMockMember(first.identity.userId);
|
|
193
|
+
const renewed = await exchanger.exchangeByCode({
|
|
194
|
+
code: 'c2',
|
|
195
|
+
context: { mall: { mallId: 'mall-demo' } },
|
|
196
|
+
previousIdentity: { userId: first.identity.userId, source: 'guest' },
|
|
197
|
+
});
|
|
198
|
+
expect(renewed.identity).toEqual({ userId: first.identity.userId, source: 'guest' });
|
|
199
|
+
expect(renewed.credentials).toEqual({
|
|
200
|
+
token: `demo:token:${first.identity.userId}`,
|
|
201
|
+
provider: 'mock',
|
|
202
|
+
attributes: { memberId: first.identity.userId },
|
|
193
203
|
});
|
|
194
204
|
});
|
|
195
205
|
|
|
196
|
-
it('
|
|
206
|
+
it('声明 allowsGuestLogin(browser 轴 auto 档 → guest 签发)', () => {
|
|
197
207
|
const { ctx } = fixtureCtx();
|
|
198
|
-
const exchanger = ctx.authExchanges.get('alipay', { mall: { mallId: 'mall-demo' } })
|
|
199
|
-
|
|
200
|
-
expect(
|
|
208
|
+
const exchanger = ctx.authExchanges.get('alipay', { mall: { mallId: 'mall-demo' } })!;
|
|
209
|
+
expect(typeof (exchanger as { allowsGuestLogin?: unknown }).allowsGuestLogin).toBe('function');
|
|
210
|
+
expect((exchanger as { allowsGuestLogin: () => boolean }).allowsGuestLogin()).toBe(true);
|
|
201
211
|
});
|
|
202
212
|
|
|
203
213
|
it('登出态换码降级 GUEST 形态(对齐真实档 silentLogin 非 200 → 访客结果,2026-09-02 真机实测)', async () => {
|
|
204
|
-
enrollMockMember(MOCK_SHELL_USER_ID);
|
|
205
|
-
logoutMockMember(MOCK_SHELL_USER_ID);
|
|
206
214
|
const { ctx } = fixtureCtx();
|
|
207
215
|
const exchanger = ctx.authExchanges.get('alipay', { mall: { mallId: 'mall-demo' } })!;
|
|
208
|
-
const
|
|
209
|
-
|
|
216
|
+
const first = await exchanger.exchangeByCode({ code: 'c1', context: { mall: { mallId: 'mall-demo' } } });
|
|
217
|
+
const userId = first.identity.userId;
|
|
218
|
+
enrollMockMember(userId);
|
|
219
|
+
logoutMockMember(userId);
|
|
220
|
+
const degraded = await exchanger.exchangeByCode({
|
|
221
|
+
code: 'c2',
|
|
222
|
+
context: { mall: { mallId: 'mall-demo' } },
|
|
223
|
+
previousIdentity: { userId, source: 'guest' },
|
|
224
|
+
});
|
|
225
|
+
expect(degraded.identity).toEqual({ userId, source: 'guest' });
|
|
210
226
|
expect(degraded.credentials).toEqual({
|
|
211
227
|
token: '',
|
|
212
228
|
provider: 'mock',
|
|
213
|
-
attributes: { openid:
|
|
229
|
+
attributes: { openid: `demo:openid:${userId}` },
|
|
214
230
|
});
|
|
215
231
|
// 重登录(enroll 清登出态)后恢复 MEMBER 形态——H5 半屏成功登录后冷登即恢复
|
|
216
|
-
enrollMockMember(
|
|
217
|
-
const result = await exchanger.exchangeByCode(
|
|
218
|
-
|
|
232
|
+
enrollMockMember(userId);
|
|
233
|
+
const result = await exchanger.exchangeByCode({
|
|
234
|
+
code: 'c3',
|
|
235
|
+
context: { mall: { mallId: 'mall-demo' } },
|
|
236
|
+
previousIdentity: { userId, source: 'guest' },
|
|
237
|
+
});
|
|
238
|
+
expect(result.credentials?.token).toBe(`demo:token:${userId}`);
|
|
219
239
|
});
|
|
220
240
|
});
|
|
221
241
|
|
|
222
|
-
describe('F2 端到端:config 级联(resolveService 全链——五层浅合并消费)', () => {
|
|
223
|
-
it('槽级 config 流入:parking.query.config.feeCents=200 → 报价同源', async () => {
|
|
224
|
-
const override: IntegrationsConfig = {
|
|
225
|
-
...integrations,
|
|
226
|
-
services: {
|
|
227
|
-
...integrations.services,
|
|
228
|
-
'parking.query': { ...integrations.services['parking.query'], config: { feeCents: 200 } },
|
|
229
|
-
},
|
|
230
|
-
};
|
|
231
|
-
const { ctx } = fixtureCtx(override);
|
|
232
|
-
const parking = (await ctx.integrations!.resolveService({
|
|
233
|
-
service: 'parking.query',
|
|
234
|
-
scope: { mallId: 'mall-demo' },
|
|
235
|
-
request: requestContext(),
|
|
236
|
-
})) as { queryFee(q: unknown, input: { plateNo: string }): Promise<Array<{ totalCents: number; payableCents: number }>> };
|
|
237
|
-
const quotes = await parking.queryFee({ scope: {} } as never, { plateNo: 'demo-plate' });
|
|
238
|
-
expect(quotes[0]?.totalCents).toBe(200);
|
|
239
|
-
expect(quotes[0]?.payableCents).toBe(200);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it('root config 级联:根 config.cardName → member 槽实例同源', async () => {
|
|
243
|
-
const override: IntegrationsConfig = { ...integrations, config: { cardName: 'Root 卡' } };
|
|
244
|
-
const { ctx } = fixtureCtx(override);
|
|
245
|
-
const member = (await ctx.integrations!.resolveService({
|
|
246
|
-
service: 'member.account',
|
|
247
|
-
scope: { mallId: 'mall-demo' },
|
|
248
|
-
request: requestContext(),
|
|
249
|
-
})) as { queryPoints(u: string): Promise<{ membershipLabel: string }> };
|
|
250
|
-
await expect(member.queryPoints('u1')).resolves.toMatchObject({ membershipLabel: 'Root 卡' });
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it('浅合并键级覆盖:root 共享键 + slot 差异键并行生效(面板分层配置语义)', async () => {
|
|
254
|
-
const override: IntegrationsConfig = {
|
|
255
|
-
...integrations,
|
|
256
|
-
config: { parkName: 'RootP' },
|
|
257
|
-
services: {
|
|
258
|
-
...integrations.services,
|
|
259
|
-
'parking.query': { ...integrations.services['parking.query'], config: { feeCents: 200 } },
|
|
260
|
-
},
|
|
261
|
-
};
|
|
262
|
-
const { ctx } = fixtureCtx(override);
|
|
263
|
-
const parking = (await ctx.integrations!.resolveService({
|
|
264
|
-
service: 'parking.query',
|
|
265
|
-
scope: { mallId: 'mall-demo' },
|
|
266
|
-
request: requestContext(),
|
|
267
|
-
})) as {
|
|
268
|
-
queryFee(q: unknown, input: { plateNo: string }): Promise<Array<{ totalCents: number }>>;
|
|
269
|
-
queryParkingInfo(q: unknown, kind: string): Promise<{ title: string }>;
|
|
270
|
-
};
|
|
271
|
-
const quotes = await parking.queryFee({ scope: {} } as never, { plateNo: 'demo-plate' });
|
|
272
|
-
expect(quotes[0]?.totalCents).toBe(200); // slot 差异键
|
|
273
|
-
const info = await parking.queryParkingInfo({ scope: {} } as never, 'chargeRules');
|
|
274
|
-
expect(info.title).toBe('RootP'); // root 共享键
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('domain 层级联 + slot 胜 domain:域级键流入 + 槽级同名键覆盖(键级层序)', async () => {
|
|
278
|
-
const override: IntegrationsConfig = {
|
|
279
|
-
...integrations,
|
|
280
|
-
domains: { parking: { config: { parkName: 'DomainP', remainingSpaces: 99 } } },
|
|
281
|
-
services: {
|
|
282
|
-
...integrations.services,
|
|
283
|
-
'parking.query': { ...integrations.services['parking.query'], config: { feeCents: 250, parkName: 'SlotP' } },
|
|
284
|
-
},
|
|
285
|
-
};
|
|
286
|
-
const { ctx } = fixtureCtx(override);
|
|
287
|
-
const parking = (await ctx.integrations!.resolveService({
|
|
288
|
-
service: 'parking.query',
|
|
289
|
-
scope: { mallId: 'mall-demo' },
|
|
290
|
-
request: requestContext(),
|
|
291
|
-
})) as {
|
|
292
|
-
queryFee(q: unknown, input: { plateNo: string }): Promise<Array<{ totalCents: number }>>;
|
|
293
|
-
queryParkingInfo(q: unknown, kind: string): Promise<{ title: string; entries: Array<{ label: string; value: string }> }>;
|
|
294
|
-
};
|
|
295
|
-
const quotes = await parking.queryFee({ scope: {} } as never, { plateNo: 'demo-plate' });
|
|
296
|
-
expect(quotes[0]?.totalCents).toBe(250); // 槽级差异键
|
|
297
|
-
const info = await parking.queryParkingInfo({ scope: {} } as never, 'chargeRules');
|
|
298
|
-
expect(info.title).toBe('SlotP'); // slot 胜 domain(同名键)
|
|
299
|
-
expect(info.entries).toContainEqual({ label: '剩余车位', value: '99' }); // 域级键流入(槽未覆盖)
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
242
|
|
|
303
243
|
// ── 隐式默认单实例声明(零拓扑兜底——provider-mock declareProviderInstances) ──
|
|
304
244
|
|
package/tests/mall-info.test.ts
CHANGED
|
@@ -44,13 +44,4 @@ describe('mockMallInfoFactory:请求形状守卫', () => {
|
|
|
44
44
|
expect(MOCK_MALL_INFO_PROVIDER).toBe('mock');
|
|
45
45
|
expect(MOCK_MALL_INFO_IMPL).toBe('mock-mall-info@1');
|
|
46
46
|
});
|
|
47
|
-
|
|
48
|
-
it('config 驱动:name 直出 / 空串回退动态别名 / 分式经纬度合法', async () => {
|
|
49
|
-
const named = makePort({ name: '星河 Mock 小镇' });
|
|
50
|
-
await expect(named.getMallInfo('1102588')).resolves.toMatchObject({ name: '星河 Mock 小镇' });
|
|
51
|
-
const fallback = makePort({ name: '', latitude: 31.2304 });
|
|
52
|
-
const info = await fallback.getMallInfo('1102588');
|
|
53
|
-
expect(info?.name).toBe('示例商场(1102588)');
|
|
54
|
-
expect((info as { latitude?: number })?.latitude).toBe(31.2304);
|
|
55
|
-
});
|
|
56
47
|
});
|
package/tests/mock-impl.test.ts
CHANGED
|
@@ -281,20 +281,20 @@ describe('provider-mock:入会闭环共享 store(C5)', () => {
|
|
|
281
281
|
|
|
282
282
|
describe('provider-mock:mock 入会落地路由(resolveMockEnroll 纯决策)', () => {
|
|
283
283
|
|
|
284
|
-
it('有身份 + 无参 →
|
|
285
|
-
const outcome = resolveMockEnroll({ body: {}, identity: { source: '
|
|
286
|
-
expect(outcome).toEqual({ status: 200, body: { state: 'active', memberRef: 'demo:member:
|
|
287
|
-
expect(isMockMemberEnrolled('
|
|
284
|
+
it('有身份 + 无参 → 缺省调用方身份翻状态返 200(T11 收口:固定 demo-user 缺省退役)', () => {
|
|
285
|
+
const outcome = resolveMockEnroll({ body: {}, identity: { source: 'guest', userId: 'guest_a1' } });
|
|
286
|
+
expect(outcome).toEqual({ status: 200, body: { state: 'active', memberRef: 'demo:member:guest_a1' } });
|
|
287
|
+
expect(isMockMemberEnrolled('guest_a1')).toBe(true);
|
|
288
288
|
});
|
|
289
289
|
|
|
290
|
-
it('定向 userId(
|
|
291
|
-
const outcome = resolveMockEnroll({ body: { userId: '
|
|
292
|
-
expect(outcome).toEqual({ status: 200, body: { state: 'active', memberRef: 'demo:member:
|
|
293
|
-
expect(isMockMemberEnrolled('
|
|
290
|
+
it('定向 userId(gate 页经 query 透传 H5 身份 / curl 调试声明主体)', () => {
|
|
291
|
+
const outcome = resolveMockEnroll({ body: { userId: 'guest_h5' }, identity: { source: 'guest', userId: 'guest_caller' } });
|
|
292
|
+
expect(outcome).toEqual({ status: 200, body: { state: 'active', memberRef: 'demo:member:guest_h5' } });
|
|
293
|
+
expect(isMockMemberEnrolled('guest_h5')).toBe(true);
|
|
294
294
|
});
|
|
295
295
|
|
|
296
296
|
it('幂等:同 userId 两次均 200', () => {
|
|
297
|
-
const identity = { source: '
|
|
297
|
+
const identity = { source: 'local' as const };
|
|
298
298
|
expect(resolveMockEnroll({ body: {}, identity }).status).toBe(200);
|
|
299
299
|
expect(resolveMockEnroll({ body: {}, identity }).status).toBe(200);
|
|
300
300
|
});
|
|
@@ -306,29 +306,29 @@ describe('provider-mock:mock 入会落地路由(resolveMockEnroll 纯决策
|
|
|
306
306
|
});
|
|
307
307
|
|
|
308
308
|
it('NODE_ENV=production → 503(mock 不进生产装配,双保险)', () => {
|
|
309
|
-
expect(resolveMockEnroll({ body: {}, identity: { source: '
|
|
309
|
+
expect(resolveMockEnroll({ body: {}, identity: { source: 'local' }, nodeEnv: 'production' }).status).toBe(503);
|
|
310
310
|
expect(isMockMemberEnrolled('demo-user')).toBe(false);
|
|
311
311
|
});
|
|
312
312
|
});
|
|
313
313
|
|
|
314
314
|
describe('provider-mock:登出态(logout 路由 + 换码降级 GUEST 形态 + getAccount 感知)', () => {
|
|
315
|
-
it('resolveMockLogout:有身份 → 200
|
|
315
|
+
it('resolveMockLogout:有身份 → 200 翻登出态(缺省调用方);enroll 清除登出态', () => {
|
|
316
316
|
__resetMockMemberState();
|
|
317
|
-
enrollMockMember('
|
|
318
|
-
expect(isMockMemberLoggedOut('
|
|
319
|
-
const outcome = resolveMockLogout({ body: {}, identity: { source: '
|
|
317
|
+
enrollMockMember('guest_a1');
|
|
318
|
+
expect(isMockMemberLoggedOut('guest_a1')).toBe(false);
|
|
319
|
+
const outcome = resolveMockLogout({ body: {}, identity: { source: 'guest', userId: 'guest_a1' } });
|
|
320
320
|
expect(outcome).toEqual({ status: 200, body: { state: 'logged_out' } });
|
|
321
|
-
expect(isMockMemberLoggedOut('
|
|
321
|
+
expect(isMockMemberLoggedOut('guest_a1')).toBe(true);
|
|
322
322
|
// 重登录(enroll)清除登出态——与真实链同构(gate 页登录成功后厂商侧登录态恢复)
|
|
323
|
-
enrollMockMember('
|
|
324
|
-
expect(isMockMemberLoggedOut('
|
|
323
|
+
enrollMockMember('guest_a1');
|
|
324
|
+
expect(isMockMemberLoggedOut('guest_a1')).toBe(false);
|
|
325
325
|
});
|
|
326
326
|
|
|
327
327
|
it('resolveMockLogout:匿名/无身份 → 401;production → 503(与 enroll 同形)', () => {
|
|
328
328
|
__resetMockMemberState();
|
|
329
329
|
expect(resolveMockLogout({ body: {}, identity: null }).status).toBe(401);
|
|
330
330
|
expect(resolveMockLogout({ body: {}, identity: { source: 'anonymous' } }).status).toBe(401);
|
|
331
|
-
expect(resolveMockLogout({ body: {}, identity: { source: '
|
|
331
|
+
expect(resolveMockLogout({ body: {}, identity: { source: 'local' }, nodeEnv: 'production' }).status).toBe(503);
|
|
332
332
|
expect(isMockMemberLoggedOut('demo-user')).toBe(false);
|
|
333
333
|
});
|
|
334
334
|
|
|
@@ -346,106 +346,3 @@ describe('provider-mock:登出态(logout 路由 + 换码降级 GUEST 形态
|
|
|
346
346
|
await expect(member.getAccount(MOCK_SHELL_USER_ID)).resolves.toMatchObject({ state: 'active' });
|
|
347
347
|
});
|
|
348
348
|
});
|
|
349
|
-
|
|
350
|
-
describe('provider-mock:config 驱动(fail-soft 快照)', () => {
|
|
351
|
-
const enroll = (member: MockMemberServiceImpl, userId: string) =>
|
|
352
|
-
member.enroll({ userId, identity: 'enrollment_submission', fieldValues: {}, acceptedConsentIds: [], idempotencyKey: `k-${userId}` });
|
|
353
|
-
|
|
354
|
-
it('member 全字段:卡名/初值积分/等级/名称/深链/流水同源', async () => {
|
|
355
|
-
const member = new MockMemberServiceImpl({}, { cardName: '黑金卡', initialPoints: 800, levelName: '金卡', memberName: '张三' });
|
|
356
|
-
await enroll(member, 'u1');
|
|
357
|
-
await expect(member.getCard('u1')).resolves.toMatchObject({ cardDisplay: '黑金卡', levelName: '金卡' });
|
|
358
|
-
await expect(member.queryPoints('u1')).resolves.toMatchObject({ balance: 800, membershipLabel: '黑金卡' });
|
|
359
|
-
await expect(member.getProfile('u1')).resolves.toMatchObject({ labels: [{ labelRef: 'demo:label:1', name: '张三' }] });
|
|
360
|
-
const usage = await member.listPointUsage('u1', 1, 10);
|
|
361
|
-
expect(usage.items[0].amount).toBe('+800');
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
it('member 非法值回退缺省:类型族/空串/NaN/分式整数(intKeys)', async () => {
|
|
365
|
-
const member = new MockMemberServiceImpl({}, { initialPoints: 'x', cardName: '', enrollUrl: '', levelName: '' });
|
|
366
|
-
await enroll(member, 'u1');
|
|
367
|
-
await expect(member.queryPoints('u1')).resolves.toMatchObject({ balance: 300, membershipLabel: '示例会员卡' });
|
|
368
|
-
const card = (await member.getCard('u1'))!;
|
|
369
|
-
expect('levelName' in card).toBe(false);
|
|
370
|
-
expect(member.enrollUrl).toMatch(/^alipays:\/\//);
|
|
371
|
-
const nan = new MockMemberServiceImpl({}, { initialPoints: Number.NaN });
|
|
372
|
-
await enroll(nan, 'u2');
|
|
373
|
-
await expect(nan.queryPoints('u2')).resolves.toMatchObject({ balance: 300 });
|
|
374
|
-
const fractional = new MockMemberServiceImpl({}, { initialPoints: 1500.5 });
|
|
375
|
-
await enroll(fractional, 'u3');
|
|
376
|
-
await expect(fractional.queryPoints('u3')).resolves.toMatchObject({ balance: 300 });
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
it('member 余额惰性读:入会不写种子 + 显式增减单源(queryPoints ≡ getBenefits)', async () => {
|
|
380
|
-
const member = new MockMemberServiceImpl({}, { initialPoints: 500 });
|
|
381
|
-
await expect(member.queryPoints('nobody')).resolves.toMatchObject({ balance: 0 });
|
|
382
|
-
await enroll(member, 'u1');
|
|
383
|
-
await expect(member.queryPoints('u1')).resolves.toMatchObject({ balance: 500 });
|
|
384
|
-
await expect(member.getBenefits('u1')).resolves.toMatchObject({ availablePoints: 500 });
|
|
385
|
-
await expect(member.deductPoints('u1', 100, 'd1')).resolves.toBe(true);
|
|
386
|
-
await expect(member.deductPoints('u1', 1000, 'd2')).resolves.toBe(false);
|
|
387
|
-
await expect(member.getBenefits('u1')).resolves.toMatchObject({ availablePoints: 400 });
|
|
388
|
-
await expect(member.awardPoints('u1', 50)).resolves.toBe(true);
|
|
389
|
-
await expect(member.refundPoints('u1', 25, 'r1')).resolves.toBe(true);
|
|
390
|
-
await expect(member.queryPoints('u1')).resolves.toMatchObject({ balance: 475 });
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
it('parking 驱动:费用/权益开关/开票开关/信息/记录/寻车同源', async () => {
|
|
394
|
-
const parking = new MockParkingServiceImpl('mall-demo', {
|
|
395
|
-
feeCents: 200, parkName: 'P2 停车场', memberBenefitEnabled: false, invoiceEnabled: false, remainingSpaces: 56, vehicleSpaceNo: 'C-9',
|
|
396
|
-
});
|
|
397
|
-
const quote = (await parking.queryFee(parkCtx, { plateNo: 'demo-plate' }))[0];
|
|
398
|
-
expect(quote).toMatchObject({ totalCents: 200, payableCents: 200 });
|
|
399
|
-
expect(quote.feeItems[0]).toEqual({ name: '停车费(3 小时)', amountCents: 200 });
|
|
400
|
-
const benefits = await parking.queryApplicableBenefits(parkCtx, 'demo-plate');
|
|
401
|
-
expect(benefits).toHaveLength(1);
|
|
402
|
-
expect(benefits[0].kind).toBe('points');
|
|
403
|
-
await expect(parking.getInvoiceSettings()).resolves.toEqual({ parkingInvoiceEnabled: false });
|
|
404
|
-
const info = await parking.queryParkingInfo(parkCtx, 'chargeRules');
|
|
405
|
-
expect(info.title).toBe('P2 停车场');
|
|
406
|
-
expect(info.entries).toContainEqual({ label: '剩余车位', value: '56' });
|
|
407
|
-
expect(info.entries).toContainEqual({ label: '会员权益', value: '—' });
|
|
408
|
-
await expect(parking.getOrderInfo(parkCtx, 'r')).resolves.toMatchObject({ payableFeeCents: 200 });
|
|
409
|
-
const records = await parking.listPaymentRecords(parkCtx, 1, 10);
|
|
410
|
-
expect(records.items[0]).toMatchObject({ parkName: 'P2 停车场', amountCents: 200 });
|
|
411
|
-
expect((await parking.locateVehicle(parkCtx, 'demo-plate'))?.spaceNo).toBe('C-9');
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
it('promotion 驱动:券标题/面额/门槛 + 团购开关 + 资产/活动派生', async () => {
|
|
415
|
-
const promotion = new MockPromotionServiceImpl({
|
|
416
|
-
couponTitle: '满 200 减 50 元券', couponValueCents: 5000, couponThresholdCents: 20000, couponValidityDays: 7, grouponEnabled: false, activityTitle: '周年庆',
|
|
417
|
-
});
|
|
418
|
-
const page = await promotion.searchOffers(promoCtx, { keyword: '' });
|
|
419
|
-
expect(page.items).toHaveLength(1);
|
|
420
|
-
expect(page.items[0].title).toBe('满 200 减 50 元券');
|
|
421
|
-
expect(page.items[0].facets[0]).toMatchObject({ value: 5000, thresholdCents: 20000 });
|
|
422
|
-
const ents = await promotion.listEntitlements(promoCtx, {});
|
|
423
|
-
expect(ents.items[0].title).toBe('满 200 减 50 元券');
|
|
424
|
-
const acts = await promotion.listActivities();
|
|
425
|
-
expect(acts.items[0].title).toBe('周年庆');
|
|
426
|
-
await expect(promotion.getOfferDetail(promoCtx, { offerRef: 'demo:coupon:1001' })).resolves.toMatchObject({ title: '满 200 减 50 元券' });
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
it('shopping 驱动:追加门店进列表/类目/楼层目录', async () => {
|
|
430
|
-
const impl = new MockShoppingServiceImpl(undefined, {
|
|
431
|
-
extraShopName: '新店', extraShopFloor: '2 楼', extraShopCategory: '文创', extraShopUnit: '203', extraShopOpen: false,
|
|
432
|
-
});
|
|
433
|
-
const page = await impl.searchShops({ ctx: shopCtx, page: 1, pageSize: 20 });
|
|
434
|
-
expect(page.total).toBe(13);
|
|
435
|
-
const extra = page.items.find((s) => s.merchantId === 'demo-shop-1013');
|
|
436
|
-
expect(extra).toMatchObject({ name: '新店', location: { floorName: '2 楼', unitName: '203' }, status: { code: 'disabled', label: '休息中' } });
|
|
437
|
-
const cats = await impl.listCategories(shopCtx);
|
|
438
|
-
expect(cats.find((c) => c.name === '文创')?.merchantCount).toBe(1);
|
|
439
|
-
const dir = await impl.getDirectory(shopCtx);
|
|
440
|
-
expect(dir?.buildings[0].floors.find((f) => f.floorName === '2 楼')?.merchantCount).toBe(3);
|
|
441
|
-
expect((await impl.searchShops({ ctx: shopCtx, page: 1, pageSize: 20, floorCode: '2 楼' })).total).toBe(3);
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
it('shopping 消费点守卫:空白名不追加 + 未知楼层回退 3 楼', async () => {
|
|
445
|
-
const blank = new MockShoppingServiceImpl(undefined, { extraShopName: ' ' });
|
|
446
|
-
expect((await blank.searchShops({ ctx: shopCtx, page: 1, pageSize: 20 })).total).toBe(12);
|
|
447
|
-
const badFloor = new MockShoppingServiceImpl(undefined, { extraShopName: 'X 店', extraShopFloor: '5 楼' });
|
|
448
|
-
const page = await badFloor.searchShops({ ctx: shopCtx, page: 1, pageSize: 20, floorCode: '3 楼' });
|
|
449
|
-
expect(page.items.some((s) => s.merchantId === 'demo-shop-1013')).toBe(true);
|
|
450
|
-
});
|
|
451
|
-
});
|
package/tsup.config.ts
CHANGED
|
@@ -15,7 +15,8 @@ export default defineConfig({
|
|
|
15
15
|
// 声明产物一次性构建无需增量——仅 dts 关闭,typecheck 的增量缓存不受影响。
|
|
16
16
|
dts: { compilerOptions: { incremental: false } },
|
|
17
17
|
external: [
|
|
18
|
-
'@tbox.cn/app-sdk',
|
|
18
|
+
'@tbox.cn/app-agent-sdk-client',
|
|
19
|
+
'@tbox.cn/app-agent-sdk-server',
|
|
19
20
|
'@tbox.cn/app-contracts',
|
|
20
21
|
'@tbox.cn/app-contracts-mall',
|
|
21
22
|
// mock-enroll-route 挂 express Router(devDep 不自动外部化——沿 module-member 先例显式声明,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"title": "Mock 商场基础信息实例配置",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"name": { "type": "string", "title": "商场名称(空串 = 动态别名「示例商场(mallId)」回退)", "default": "" },
|
|
7
|
-
"address": { "type": "string", "title": "商场地址", "default": "示例商场地址(demo)" },
|
|
8
|
-
"latitude": { "type": "number", "minimum": -90, "maximum": 90, "title": "纬度(分式合法)", "default": 30 },
|
|
9
|
-
"longitude": { "type": "number", "minimum": -180, "maximum": 180, "title": "经度(分式合法)", "default": 120 }
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"title": "Mock 会员域实例配置",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"memberName": { "type": "string", "title": "会员名称(资料标签展示)", "default": "示例会员" },
|
|
7
|
-
"cardName": { "type": "string", "title": "会员卡名称(卡面 + 积分标签)", "default": "示例会员卡" },
|
|
8
|
-
"levelName": { "type": "string", "title": "等级名称(空串 = 不展示等级区)", "default": "" },
|
|
9
|
-
"initialPoints": { "type": "integer", "minimum": 0, "title": "初始积分(入会后余额;流水金额同源派生)", "default": 300 },
|
|
10
|
-
"enrollUrl": { "type": "string", "title": "入会落地页深链(alipays:// 或 H5)", "default": "alipays://platformapi/startapp?appId=demo&page=v/index/index" },
|
|
11
|
-
"loginUrl": { "type": "string", "title": "登录页深链(alipays:// 或 H5)", "default": "alipays://platformapi/startapp?appId=demo&page=v/login/index" }
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"title": "Mock 停车域实例配置",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"parkName": { "type": "string", "title": "停车场名称(信息卡标题 + 缴费记录)", "default": "示例停车场" },
|
|
7
|
-
"feeName": { "type": "string", "title": "费用项名称", "default": "停车费(3 小时)" },
|
|
8
|
-
"feeCents": { "type": "integer", "minimum": 0, "title": "停车费(分)", "default": 1500 },
|
|
9
|
-
"remainingSpaces": { "type": "integer", "minimum": 0, "title": "剩余车位", "default": 128 },
|
|
10
|
-
"firstHourRate": { "type": "string", "title": "首小时费率文案", "default": "免费" },
|
|
11
|
-
"memberBenefitEnabled": { "type": "boolean", "title": "会员折扣权益开关(关闭 = 权益列表少一项 + reprice 不变)", "default": true },
|
|
12
|
-
"memberBenefitDiscountCents": { "type": "integer", "minimum": 0, "title": "会员折扣权益预估减免(分)", "default": 75 },
|
|
13
|
-
"pointsBenefitEnabled": { "type": "boolean", "title": "积分抵扣权益开关", "default": true },
|
|
14
|
-
"invoiceEnabled": { "type": "boolean", "title": "开票入口开关(关闭 = 缴费卡无开票按钮)", "default": true },
|
|
15
|
-
"vehicleFloor": { "type": "string", "title": "寻车楼层", "default": "B1" },
|
|
16
|
-
"vehicleZone": { "type": "string", "title": "寻车区域", "default": "A 区" },
|
|
17
|
-
"vehicleSpaceNo": { "type": "string", "title": "寻车车位号", "default": "A-128" }
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"title": "Mock 营销域实例配置",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"couponTitle": { "type": "string", "title": "券标题(列表/详情/资产同源)", "default": "满 100 减 20 元券" },
|
|
7
|
-
"couponValueCents": { "type": "integer", "minimum": 0, "title": "券面额(分)", "default": 2000 },
|
|
8
|
-
"couponThresholdCents": { "type": "integer", "minimum": 0, "title": "券门槛(分)", "default": 10000 },
|
|
9
|
-
"couponValidityDays": { "type": "integer", "minimum": 1, "maximum": 365, "title": "券有效期(天)", "default": 30 },
|
|
10
|
-
"grouponEnabled": { "type": "boolean", "title": "团购演示项开关(关闭 = 优惠列表仅券)", "default": true },
|
|
11
|
-
"activityTitle": { "type": "string", "title": "活动标题", "default": "示例商场周年庆" }
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"title": "Mock 导购域实例配置",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"extraShopName": { "type": "string", "title": "追加门店名(空串 = 不追加)", "default": "" },
|
|
7
|
-
"extraShopCategory": { "type": "string", "title": "追加门店类目", "default": "餐饮" },
|
|
8
|
-
"extraShopFloor": { "type": "string", "enum": ["B1", "1 楼", "2 楼", "3 楼", "4 楼"], "title": "追加门店楼层", "default": "3 楼" },
|
|
9
|
-
"extraShopUnit": { "type": "string", "title": "追加门店铺位号", "default": "304" },
|
|
10
|
-
"extraShopOpen": { "type": "boolean", "title": "追加门店营业状态", "default": true }
|
|
11
|
-
}
|
|
12
|
-
}
|
package/src/server/config.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mock 实例配置快照(fail-soft 单源):provider-mock 全部 config 消费的唯一读取面。
|
|
3
|
-
* - 只透出 defaults 键(构造性防死字段);defaults 键 ≡ 被消费键;
|
|
4
|
-
* - 非法回退缺省:类型族不符 / NaN / intKeys 键非整数 / 空串(统一「空串 = 缺省」语义);
|
|
5
|
-
* - intKeys 显式列举而非按 default 值推断(JS 中 30.0 === 30,推断式必误拒分式经纬度);
|
|
6
|
-
* - schema 是表单引导非门禁——守卫在消费侧(五层浅合并由平台侧完成,本层零合并逻辑)。
|
|
7
|
-
* 双锁测试(tests/config-schema.test.ts)保证 schema.properties ≡ DEFAULTS 键集与 default 值。
|
|
8
|
-
*/
|
|
9
|
-
export type CfgDefaults = Readonly<Record<string, string | number | boolean>>;
|
|
10
|
-
|
|
11
|
-
export function resolveConfig<T extends CfgDefaults>(
|
|
12
|
-
raw: unknown,
|
|
13
|
-
defaults: T,
|
|
14
|
-
intKeys: readonly string[] = [],
|
|
15
|
-
): T {
|
|
16
|
-
const src = raw && typeof raw === 'object' ? (raw as Record<string, unknown>) : {};
|
|
17
|
-
const out: Record<string, string | number | boolean> = {};
|
|
18
|
-
for (const [key, fallback] of Object.entries(defaults)) {
|
|
19
|
-
const value = src[key];
|
|
20
|
-
const ok = typeof value === typeof fallback
|
|
21
|
-
&& (typeof value !== 'number' || (Number.isFinite(value) && (!intKeys.includes(key) || Number.isInteger(value))))
|
|
22
|
-
&& (typeof value !== 'string' || value !== '');
|
|
23
|
-
out[key] = ok ? (value as string | number | boolean) : fallback;
|
|
24
|
-
}
|
|
25
|
-
return out as T;
|
|
26
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* config schema 双锁(供给面 ↔ 消费面一致性):
|
|
3
|
-
* ① 键集双向锁(schema.properties ≡ DEFAULTS——死字段/漏字段一次全拦)
|
|
4
|
-
* ② default 漂移锁(schema 表单缺省 ≡ 实现缺省——面板不改动时的运行时真值)
|
|
5
|
-
* ③ 整数对偶锁(schema type:'integer' ⟺ INT_KEYS——消费点整数守卫与表单引导同源)
|
|
6
|
-
* ④ manifest 分发面锁(17 槽 configSchema 引用齐全 + 文件随包存在 + 槽→域文件映射)
|
|
7
|
-
* ⑤ 楼层白名单同值锁(shopping enum ≡ SHOPPING_FLOORS——消费点守卫与引导同源)
|
|
8
|
-
*/
|
|
9
|
-
import { describe, expect, it } from 'vitest';
|
|
10
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
11
|
-
import path from 'node:path';
|
|
12
|
-
import { fileURLToPath } from 'node:url';
|
|
13
|
-
import { MEMBER_CFG_DEFAULTS, MEMBER_CFG_INT_KEYS } from '../src/server/member';
|
|
14
|
-
import { PARKING_CFG_DEFAULTS, PARKING_CFG_INT_KEYS } from '../src/server/parking';
|
|
15
|
-
import { PROMOTION_CFG_DEFAULTS, PROMOTION_CFG_INT_KEYS } from '../src/server/promotion';
|
|
16
|
-
import { SHOPPING_CFG_DEFAULTS, SHOPPING_CFG_INT_KEYS, SHOPPING_FLOORS } from '../src/server/shopping';
|
|
17
|
-
import { MALL_INFO_CFG_DEFAULTS, MALL_INFO_CFG_INT_KEYS } from '../src/server/mall-info';
|
|
18
|
-
|
|
19
|
-
const pkgRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
20
|
-
|
|
21
|
-
interface SchemaProperty { type?: string; default?: unknown; enum?: readonly string[] }
|
|
22
|
-
interface SchemaFile { properties: Record<string, SchemaProperty> }
|
|
23
|
-
|
|
24
|
-
interface DomainCase {
|
|
25
|
-
name: string;
|
|
26
|
-
file: string;
|
|
27
|
-
defaults: Readonly<Record<string, string | number | boolean>>;
|
|
28
|
-
intKeys: readonly string[];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const DOMAINS: readonly DomainCase[] = [
|
|
32
|
-
{ name: 'member', file: 'member.config.json', defaults: MEMBER_CFG_DEFAULTS, intKeys: MEMBER_CFG_INT_KEYS },
|
|
33
|
-
{ name: 'parking', file: 'parking.config.json', defaults: PARKING_CFG_DEFAULTS, intKeys: PARKING_CFG_INT_KEYS },
|
|
34
|
-
{ name: 'promotion', file: 'promotion.config.json', defaults: PROMOTION_CFG_DEFAULTS, intKeys: PROMOTION_CFG_INT_KEYS },
|
|
35
|
-
{ name: 'shopping', file: 'shopping.config.json', defaults: SHOPPING_CFG_DEFAULTS, intKeys: SHOPPING_CFG_INT_KEYS },
|
|
36
|
-
{ name: 'mall-info', file: 'mall-info.config.json', defaults: MALL_INFO_CFG_DEFAULTS, intKeys: MALL_INFO_CFG_INT_KEYS },
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
const readSchema = (file: string): SchemaFile =>
|
|
40
|
-
JSON.parse(readFileSync(path.join(pkgRoot, 'schemas', file), 'utf8')) as SchemaFile;
|
|
41
|
-
|
|
42
|
-
describe('provider-mock:config schema 双锁(供给面 ≡ 消费面)', () => {
|
|
43
|
-
it('① 键集双向锁:schema.properties ≡ DEFAULTS 键集', () => {
|
|
44
|
-
for (const d of DOMAINS) {
|
|
45
|
-
const schema = readSchema(d.file);
|
|
46
|
-
expect(Object.keys(schema.properties).sort(), `${d.name} 键集`).toEqual(Object.keys(d.defaults).sort());
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('② default 漂移锁:schema 缺省 ≡ 实现缺省', () => {
|
|
51
|
-
for (const d of DOMAINS) {
|
|
52
|
-
const schema = readSchema(d.file);
|
|
53
|
-
for (const [key, value] of Object.entries(d.defaults)) {
|
|
54
|
-
expect(schema.properties[key]?.default, `${d.name}.${key} default 漂移`).toEqual(value);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('③ 整数对偶锁:schema type=integer ⟺ INT_KEYS(分式字段不得入 intKeys)', () => {
|
|
60
|
-
for (const d of DOMAINS) {
|
|
61
|
-
const schema = readSchema(d.file);
|
|
62
|
-
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
63
|
-
expect(prop.type === 'integer', `${d.name}.${key} 整数对偶`).toBe(d.intKeys.includes(key));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('④ manifest 分发面锁:17 槽引用齐全 + 槽→域映射 + 文件随包', () => {
|
|
69
|
-
const manifest = JSON.parse(readFileSync(path.join(pkgRoot, 'tbox.module.json'), 'utf8')) as {
|
|
70
|
-
contributes: { providers: { slots: Array<{ service: string; configSchema?: string }> } };
|
|
71
|
-
};
|
|
72
|
-
const slots = manifest.contributes.providers.slots;
|
|
73
|
-
expect(slots).toHaveLength(17);
|
|
74
|
-
const fileOfPrefix: Record<string, string> = {
|
|
75
|
-
member: 'member.config.json',
|
|
76
|
-
parking: 'parking.config.json',
|
|
77
|
-
promotion: 'promotion.config.json',
|
|
78
|
-
'shopping-guide': 'shopping.config.json',
|
|
79
|
-
mall: 'mall-info.config.json',
|
|
80
|
-
};
|
|
81
|
-
for (const slot of slots) {
|
|
82
|
-
const prefix = slot.service.slice(0, slot.service.indexOf('.'));
|
|
83
|
-
expect(slot.configSchema, `${slot.service} configSchema 缺失`).toBe(`schemas/${fileOfPrefix[prefix]}`);
|
|
84
|
-
expect(existsSync(path.join(pkgRoot, slot.configSchema!)), `${slot.service} schema 文件不存在`).toBe(true);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('⑤ 楼层 enum ≡ SHOPPING_FLOORS(消费点守卫与表单引导同源)', () => {
|
|
89
|
-
const schema = readSchema('shopping.config.json');
|
|
90
|
-
expect(schema.properties.extraShopFloor?.enum).toEqual([...SHOPPING_FLOORS]);
|
|
91
|
-
});
|
|
92
|
-
});
|