@tbox.cn/app-module-promotion 1.0.0-alpha.16 → 1.0.0-alpha.18

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.
@@ -285,6 +285,16 @@ describe('promotion 确定性意图路由', () => {
285
285
  expect(otherProvider.cards[0]?.cardType).toBe('promotion-activity-list');
286
286
  });
287
287
 
288
+ it('指代不明时不取第一场活动,不分流去首页的联单活动', async () => {
289
+ const server = createServerContext();
290
+ const tools = createPromotionTools({ getCtx: () => server });
291
+ for (const tool of [tools.getActivityDetail, tools.listActivitySessions, tools.getParticipationGuide]) {
292
+ const result = await tool.execute!({ keyword: '这个活动' } as never, createToolExecContext(testRequestContext()) as never);
293
+ expect(result).toMatchObject({ found: false, needsSelection: true });
294
+ expect(result).not.toHaveProperty('cards');
295
+ }
296
+ });
297
+
288
298
  it('活动工具在专属策略下先分流,不依赖 promotion service 解析', async () => {
289
299
  const ctx = createServerContext();
290
300
  const alipayActivityHandler = {
@@ -400,6 +410,32 @@ describe('promotion 确定性意图路由', () => {
400
410
  },
401
411
  );
402
412
 
413
+ it.each([false, true])('卡包入口在空券和有券时随同一张权益卡返回(有券=%s)', async (hasCoupon) => {
414
+ const service = new InMemoryPromotionService();
415
+ if (hasCoupon) {
416
+ await service.acquire(q, { offerRef: 'demo:coupon:1001', externalMemberRef: 'm', idempotencyKey: 'wallet' });
417
+ }
418
+ const page = await service.listEntitlements(q, {});
419
+ vi.spyOn(service, 'listEntitlements').mockResolvedValue({ ...page, showAlipayWallet: true });
420
+ const search = vi.spyOn(service, 'searchOffers');
421
+ mockAllSlotsPersist(service);
422
+ const ctx = createPromotionTestContext();
423
+ const req = testRequestContext();
424
+ const exec = createToolExecContext(req) as never;
425
+ const tools = createPromotionTools({ getCtx: () => ctx });
426
+ expect(matchIntent(PROMOTION_TEST_ROUTES, '我有什么卡券')?.handlerId).toBe('promotion');
427
+ const expected = { cards: [{ cardType: 'promotion-entitlement-list', data: {
428
+ items: hasCoupon ? [expect.objectContaining({ title: '满 100 减 20 元券' })] : [],
429
+ showAlipayWallet: true,
430
+ } }] };
431
+ const direct = await createPromotionIntentHandler(ctx).handle('intent', { content: '我有什么卡券' }, ctx, req);
432
+ expect(direct).toMatchObject(expected);
433
+ expect(direct.text).toContain('支付宝卡包');
434
+ expect(await tools.listEntitlements.execute!({} as never, exec)).toMatchObject(expected);
435
+ expect(await tools.listCoupons.execute!({ mode: 'OWNED' } as never, exec)).toMatchObject(expected);
436
+ expect(search).not.toHaveBeenCalled();
437
+ });
438
+
403
439
  it('“有什么优惠可以领取”直达可领取券列表,不查询已领取券包', async () => {
404
440
  const service = new InMemoryPromotionService();
405
441
  const listEntitlements = vi.spyOn(service, 'listEntitlements');