@managesome/eposmatic-toolkit 0.3.3 → 0.3.4
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.
|
@@ -160,7 +160,7 @@ export declare function convertCatalogItemToOrderEngineItem({ item, orderItem, p
|
|
|
160
160
|
export declare function hasRequiredModifier<T extends IModifier | IOrderEngineModifier>(currentModifiers: T[] | null): boolean;
|
|
161
161
|
export declare function convertItemToOrderItem(item: IItem | ISimplifiedCatalogItem, menu_id: string | null, platform: PLATFORMS_ENUM | undefined, tenantId: string, orderItemType?: ORDER_ITEM_TYPE_ENUM): IOrderItem;
|
|
162
162
|
export declare function setCheckFieldInOrderEngineItem(orderEngineItem: IOrderEngineItem, identifier: string, shouldCheck: boolean, chooseExpensiveSegmentPrice?: boolean): IOrderEngineItem;
|
|
163
|
-
export declare function setIncrementOrderEngineItemQuantity(orderEngineItem: IOrderEngineItem, increment: number): IOrderEngineItem;
|
|
163
|
+
export declare function setIncrementOrderEngineItemQuantity(orderEngineItem: IOrderEngineItem, increment: number, isAbs?: boolean): IOrderEngineItem;
|
|
164
164
|
export declare function setUpdateSelectedOrderEngineOptionQuantity(orderEngineItem: IOrderEngineItem, identifier: string, newQuantity: number, isIncrement?: boolean): IOrderEngineItem;
|
|
165
165
|
export declare function getFlattenedOrderEngineItemModifiers(modifiers: IOrderEngineModifier[], keepOptionalModifiersAtBottom?: boolean): IOrderEngineModifier[];
|
|
166
166
|
export {};
|
|
@@ -1298,8 +1298,8 @@ function setCheckFieldInOrderEngineItem(orderEngineItem, identifier, shouldCheck
|
|
|
1298
1298
|
void chooseExpensiveSegmentPrice;
|
|
1299
1299
|
return updatedOrderEngineItem;
|
|
1300
1300
|
}
|
|
1301
|
-
function setIncrementOrderEngineItemQuantity(orderEngineItem, increment) {
|
|
1302
|
-
const newQuantity = increment + orderEngineItem.quantity;
|
|
1301
|
+
function setIncrementOrderEngineItemQuantity(orderEngineItem, increment, isAbs) {
|
|
1302
|
+
const newQuantity = isAbs ? Math.abs(increment) : increment + orderEngineItem.quantity;
|
|
1303
1303
|
const item_discount_details = (0, store_1.getItemQuantityChangeResults)({
|
|
1304
1304
|
newQuantity,
|
|
1305
1305
|
prevQuantity: orderEngineItem.quantity,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
const offers_helpers_1 = require("../helpers/utils/offers-helpers");
|
|
5
|
+
const OFFER_ID = 'offer-free-burger';
|
|
6
|
+
const BURGER_ITEM_ID = 'item-burger';
|
|
7
|
+
function makeCategories(subtotal = 2000) {
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
category_id: 'category-pizza',
|
|
11
|
+
items: [
|
|
12
|
+
{
|
|
13
|
+
_id: 'cart-item-1',
|
|
14
|
+
item_id: 'item-classic',
|
|
15
|
+
name: 'Classic',
|
|
16
|
+
quantity: 1,
|
|
17
|
+
subtotal,
|
|
18
|
+
modifiers: [],
|
|
19
|
+
item_discount_details: null,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
category_id: 'category-burger',
|
|
25
|
+
items: [
|
|
26
|
+
{
|
|
27
|
+
_id: 'cart-item-burger',
|
|
28
|
+
item_id: BURGER_ITEM_ID,
|
|
29
|
+
name: 'Chicken Burger',
|
|
30
|
+
quantity: 1,
|
|
31
|
+
subtotal: 0,
|
|
32
|
+
modifiers: [],
|
|
33
|
+
item_discount_details: {
|
|
34
|
+
loyalty_discount: 100,
|
|
35
|
+
loyalty_discount_id: OFFER_ID,
|
|
36
|
+
loyalty_discount_name: 'Free Chicken Burger on First order over 1500',
|
|
37
|
+
is_loyalty_discount_percentage: true,
|
|
38
|
+
loyalty_discount_reason: 'Free Chicken Burger on First order over 1500',
|
|
39
|
+
total_discount: 360,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
function makeFreeBurgerOffer(maxUsesPerCustomer = 1) {
|
|
47
|
+
return {
|
|
48
|
+
_id: OFFER_ID,
|
|
49
|
+
name: 'Free Chicken Burger on First order over 1500',
|
|
50
|
+
active: true,
|
|
51
|
+
auto_apply: true,
|
|
52
|
+
sort_id: 1,
|
|
53
|
+
included_platforms: [constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY],
|
|
54
|
+
pathway_to_unlock_type: constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ORDERS,
|
|
55
|
+
pathway_to_unlock_type_orders: {
|
|
56
|
+
scope: constants_1.PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM.OVERALL,
|
|
57
|
+
min_num_of_orders: 0,
|
|
58
|
+
max_num_of_orders: null,
|
|
59
|
+
total_amount: 1500,
|
|
60
|
+
max_amount: null,
|
|
61
|
+
orders_between_unlocks: null,
|
|
62
|
+
max_claims: 10000,
|
|
63
|
+
max_uses_per_customer: maxUsesPerCustomer,
|
|
64
|
+
},
|
|
65
|
+
reward_type: constants_1.OFFER_REWARD_TYPE_ENUM.ITEMS,
|
|
66
|
+
reward_items: {
|
|
67
|
+
num_of_items: 1,
|
|
68
|
+
excluded_refs: [],
|
|
69
|
+
exclusive_refs: [],
|
|
70
|
+
item_ids: [BURGER_ITEM_ID],
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function makeUsedCounts(usedTimes) {
|
|
75
|
+
return {
|
|
76
|
+
[constants_1.CUSTOMER_REDEMPTION_TYPE_ENUM.USED]: { [OFFER_ID]: usedTimes },
|
|
77
|
+
[constants_1.CUSTOMER_REDEMPTION_TYPE_ENUM.ASSIGNED]: {},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function runStats(options = {}) {
|
|
81
|
+
return (0, offers_helpers_1.getOffersWithStats)({
|
|
82
|
+
offers: [makeFreeBurgerOffer(options.maxUsesPerCustomer ?? 1)],
|
|
83
|
+
customer: { total_orders: 1, loyalty_points: 0 },
|
|
84
|
+
vouchers: [],
|
|
85
|
+
giftCards: [],
|
|
86
|
+
customerOfferRedemptionCounts: options.counts === undefined ? makeUsedCounts(1) : options.counts,
|
|
87
|
+
redeemed_offers: { [OFFER_ID]: 1 },
|
|
88
|
+
platform: constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY,
|
|
89
|
+
currency_symbol: constants_1.CURRENCY_SYMBOL_ENUM.$,
|
|
90
|
+
categories: makeCategories(options.orderValue),
|
|
91
|
+
currentItemsPrice: options.orderValue ?? 2000,
|
|
92
|
+
totalDiscountApplied: 0,
|
|
93
|
+
order_discount_details: null,
|
|
94
|
+
isEdit: options.isEdit,
|
|
95
|
+
editedOrderRedeemedOffers: options.editedOrderRedeemedOffers,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
describe('getOffersWithStats — edited-order redemption baseline', () => {
|
|
99
|
+
it('keeps an applied item reward when editing the order that consumed it', () => {
|
|
100
|
+
const result = runStats({
|
|
101
|
+
counts: makeUsedCounts(1),
|
|
102
|
+
isEdit: true,
|
|
103
|
+
editedOrderRedeemedOffers: { [OFFER_ID]: 1 },
|
|
104
|
+
});
|
|
105
|
+
const { stats } = result.offersWithStats[0];
|
|
106
|
+
expect(stats.redeemed_times).toBe(1);
|
|
107
|
+
expect(stats.applicable_quantity).toBe(1);
|
|
108
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(1);
|
|
109
|
+
expect(stats.message).toContain('redeemed');
|
|
110
|
+
expect(stats.message).not.toContain('personal limit');
|
|
111
|
+
});
|
|
112
|
+
it('still exhausts the offer on a new order when the customer already used it', () => {
|
|
113
|
+
const result = runStats({ counts: makeUsedCounts(1) });
|
|
114
|
+
const { stats } = result.offersWithStats[0];
|
|
115
|
+
expect(stats.applicable_quantity).toBe(0);
|
|
116
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(0);
|
|
117
|
+
expect(stats.message).toContain('personal limit');
|
|
118
|
+
});
|
|
119
|
+
it('still exhausts the offer when editing an order with no baseline claim for it', () => {
|
|
120
|
+
const result = runStats({
|
|
121
|
+
counts: makeUsedCounts(1),
|
|
122
|
+
isEdit: true,
|
|
123
|
+
editedOrderRedeemedOffers: {},
|
|
124
|
+
});
|
|
125
|
+
const { stats } = result.offersWithStats[0];
|
|
126
|
+
expect(stats.applicable_quantity).toBe(0);
|
|
127
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(0);
|
|
128
|
+
expect(stats.message).toContain('personal limit');
|
|
129
|
+
});
|
|
130
|
+
it('keeps the previous behavior when isEdit is set but no baseline snapshot is provided', () => {
|
|
131
|
+
const result = runStats({ counts: makeUsedCounts(1), isEdit: true });
|
|
132
|
+
const { stats } = result.offersWithStats[0];
|
|
133
|
+
expect(stats.applicable_quantity).toBe(0);
|
|
134
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(0);
|
|
135
|
+
expect(stats.message).toContain('personal limit');
|
|
136
|
+
});
|
|
137
|
+
it('preserves the claim while counts are unknown if the edited order carried it', () => {
|
|
138
|
+
const result = runStats({
|
|
139
|
+
counts: null,
|
|
140
|
+
isEdit: true,
|
|
141
|
+
editedOrderRedeemedOffers: { [OFFER_ID]: 1 },
|
|
142
|
+
});
|
|
143
|
+
const { stats } = result.offersWithStats[0];
|
|
144
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(1);
|
|
145
|
+
expect(stats.message).not.toContain('personal limit');
|
|
146
|
+
});
|
|
147
|
+
it('stays fail-closed on unknown counts without baseline evidence', () => {
|
|
148
|
+
const result = runStats({
|
|
149
|
+
counts: null,
|
|
150
|
+
isEdit: true,
|
|
151
|
+
editedOrderRedeemedOffers: {},
|
|
152
|
+
});
|
|
153
|
+
const { stats } = result.offersWithStats[0];
|
|
154
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(0);
|
|
155
|
+
expect(stats.message).toContain('personal limit');
|
|
156
|
+
});
|
|
157
|
+
it("subtracts only the edited order's own claims from the lifetime count", () => {
|
|
158
|
+
const result = runStats({
|
|
159
|
+
counts: makeUsedCounts(2),
|
|
160
|
+
isEdit: true,
|
|
161
|
+
editedOrderRedeemedOffers: { [OFFER_ID]: 1 },
|
|
162
|
+
maxUsesPerCustomer: 2,
|
|
163
|
+
});
|
|
164
|
+
const { stats } = result.offersWithStats[0];
|
|
165
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(1);
|
|
166
|
+
expect(stats.message).not.toContain('personal limit');
|
|
167
|
+
});
|
|
168
|
+
it('still exhausts when other orders consumed the full lifetime budget', () => {
|
|
169
|
+
const result = runStats({
|
|
170
|
+
counts: makeUsedCounts(2),
|
|
171
|
+
isEdit: true,
|
|
172
|
+
editedOrderRedeemedOffers: {},
|
|
173
|
+
maxUsesPerCustomer: 2,
|
|
174
|
+
});
|
|
175
|
+
const { stats } = result.offersWithStats[0];
|
|
176
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(0);
|
|
177
|
+
expect(stats.message).toContain('personal limit');
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
describe('getOffersWithStats — remaining-budget clamp (Q1)', () => {
|
|
181
|
+
it('caps multi-chunk session claims at the remaining budget (counts known)', () => {
|
|
182
|
+
const result = runStats({
|
|
183
|
+
counts: makeUsedCounts(1),
|
|
184
|
+
isEdit: true,
|
|
185
|
+
editedOrderRedeemedOffers: { [OFFER_ID]: 1 },
|
|
186
|
+
orderValue: 4000,
|
|
187
|
+
maxUsesPerCustomer: 1,
|
|
188
|
+
});
|
|
189
|
+
// Two spend chunks unlock, but the customer's budget is a single use.
|
|
190
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(1);
|
|
191
|
+
expect(result.offersWithStats[0].stats.message).not.toContain('personal limit');
|
|
192
|
+
});
|
|
193
|
+
it('caps multi-chunk session claims while counts are unknown (hold window)', () => {
|
|
194
|
+
const result = runStats({
|
|
195
|
+
counts: null,
|
|
196
|
+
isEdit: true,
|
|
197
|
+
editedOrderRedeemedOffers: { [OFFER_ID]: 1 },
|
|
198
|
+
orderValue: 4000,
|
|
199
|
+
maxUsesPerCustomer: 1,
|
|
200
|
+
});
|
|
201
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(1);
|
|
202
|
+
expect(result.offersWithStats[0].stats.message).not.toContain('personal limit');
|
|
203
|
+
});
|
|
204
|
+
it('reduces multi-chunk claims to the remaining budget', () => {
|
|
205
|
+
const result = runStats({
|
|
206
|
+
counts: makeUsedCounts(1),
|
|
207
|
+
orderValue: 4000,
|
|
208
|
+
maxUsesPerCustomer: 2,
|
|
209
|
+
});
|
|
210
|
+
// Two chunks available, one lifetime use left.
|
|
211
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(1);
|
|
212
|
+
});
|
|
213
|
+
it('does not clamp below the per-order claims while budget remains', () => {
|
|
214
|
+
const result = runStats({
|
|
215
|
+
counts: makeUsedCounts(0),
|
|
216
|
+
orderValue: 4000,
|
|
217
|
+
maxUsesPerCustomer: 3,
|
|
218
|
+
});
|
|
219
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(2);
|
|
220
|
+
});
|
|
221
|
+
it('ignores non-numeric baseline counts and stays fail-closed', () => {
|
|
222
|
+
const result = runStats({
|
|
223
|
+
counts: makeUsedCounts(2),
|
|
224
|
+
isEdit: true,
|
|
225
|
+
editedOrderRedeemedOffers: { [OFFER_ID]: 'abc' },
|
|
226
|
+
maxUsesPerCustomer: 2,
|
|
227
|
+
});
|
|
228
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(0);
|
|
229
|
+
expect(result.offersWithStats[0].stats.message).toContain('personal limit');
|
|
230
|
+
});
|
|
231
|
+
it('normalizes whitespace-padded baseline keys and string counts', () => {
|
|
232
|
+
const result = runStats({
|
|
233
|
+
counts: makeUsedCounts(2),
|
|
234
|
+
isEdit: true,
|
|
235
|
+
editedOrderRedeemedOffers: { ' offer-free-burger ': '1' },
|
|
236
|
+
maxUsesPerCustomer: 2,
|
|
237
|
+
});
|
|
238
|
+
// Baseline subtracts one use: budget = 2 − (2 − 1) = 1.
|
|
239
|
+
expect(result.unlockedOffersApplicableTimes[OFFER_ID]).toBe(1);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
function makePathwayOffer(pathway) {
|
|
243
|
+
const base = {
|
|
244
|
+
_id: OFFER_ID,
|
|
245
|
+
name: 'Pathway reward',
|
|
246
|
+
active: true,
|
|
247
|
+
auto_apply: true,
|
|
248
|
+
sort_id: 1,
|
|
249
|
+
included_platforms: [constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY],
|
|
250
|
+
pathway_to_unlock_type: pathway,
|
|
251
|
+
reward_type: constants_1.OFFER_REWARD_TYPE_ENUM.ITEMS,
|
|
252
|
+
reward_items: {
|
|
253
|
+
num_of_items: 1,
|
|
254
|
+
excluded_refs: [],
|
|
255
|
+
exclusive_refs: [],
|
|
256
|
+
item_ids: [BURGER_ITEM_ID],
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
if (pathway === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ORDERS) {
|
|
260
|
+
return {
|
|
261
|
+
...base,
|
|
262
|
+
pathway_to_unlock_type_orders: {
|
|
263
|
+
scope: constants_1.PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM.OVERALL,
|
|
264
|
+
min_num_of_orders: 0,
|
|
265
|
+
max_num_of_orders: null,
|
|
266
|
+
total_amount: 1500,
|
|
267
|
+
max_amount: null,
|
|
268
|
+
orders_between_unlocks: null,
|
|
269
|
+
max_claims: 2,
|
|
270
|
+
max_uses_per_customer: 1,
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
if (pathway === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ITEMS) {
|
|
275
|
+
return {
|
|
276
|
+
...base,
|
|
277
|
+
pathway_to_unlock_type_orders: null,
|
|
278
|
+
pathway_to_unlock_type_items: {
|
|
279
|
+
num_of_items: 1,
|
|
280
|
+
max_uses_per_customer: 1,
|
|
281
|
+
max_claims: 2,
|
|
282
|
+
min_same_item_quantity: null,
|
|
283
|
+
max_same_item_quantity: null,
|
|
284
|
+
total_amount: null,
|
|
285
|
+
excluded_refs: [],
|
|
286
|
+
exclusive_refs: [],
|
|
287
|
+
item_ids: ['item-classic'],
|
|
288
|
+
category_ids: [],
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
if (pathway === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.POINTS) {
|
|
293
|
+
return {
|
|
294
|
+
...base,
|
|
295
|
+
pathway_to_unlock_type_orders: null,
|
|
296
|
+
pathway_to_unlock_type_points: {
|
|
297
|
+
num_of_points: 100,
|
|
298
|
+
total_amount: null,
|
|
299
|
+
max_uses_per_customer: 1,
|
|
300
|
+
max_claims: 2,
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
...base,
|
|
306
|
+
pathway_to_unlock_type_orders: null,
|
|
307
|
+
pathway_to_unlock_type_vouchers: {
|
|
308
|
+
total_amount: 1500,
|
|
309
|
+
max_amount: null,
|
|
310
|
+
max_uses_per_customer: 1,
|
|
311
|
+
max_claims: 2,
|
|
312
|
+
voucher_ids: ['voucher-v'],
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const PATHWAY_CASES = [
|
|
317
|
+
{ pathway: constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ORDERS },
|
|
318
|
+
{ pathway: constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ITEMS },
|
|
319
|
+
{ pathway: constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.POINTS, customer: { total_orders: 1, loyalty_points: 500 } },
|
|
320
|
+
{
|
|
321
|
+
pathway: constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.VOUCHER,
|
|
322
|
+
customer: { total_orders: 1, loyalty_points: 0, voucher_codes: { VV: 1 } },
|
|
323
|
+
vouchers: [
|
|
324
|
+
{
|
|
325
|
+
_id: 'voucher-v',
|
|
326
|
+
code: 'VV',
|
|
327
|
+
active: true,
|
|
328
|
+
max_uses: 100,
|
|
329
|
+
used_count: 0,
|
|
330
|
+
max_uses_per_customer: null,
|
|
331
|
+
expire_at: null,
|
|
332
|
+
},
|
|
333
|
+
],
|
|
334
|
+
},
|
|
335
|
+
];
|
|
336
|
+
function runPathwayStats({ pathwayCase, isEdit, baseline, }) {
|
|
337
|
+
return (0, offers_helpers_1.getOffersWithStats)({
|
|
338
|
+
offers: [makePathwayOffer(pathwayCase.pathway)],
|
|
339
|
+
customer: pathwayCase.customer ?? { total_orders: 1, loyalty_points: 0 },
|
|
340
|
+
vouchers: (pathwayCase.vouchers ?? []),
|
|
341
|
+
giftCards: [],
|
|
342
|
+
customerOfferRedemptionCounts: makeUsedCounts(1),
|
|
343
|
+
redeemed_offers: { [OFFER_ID]: 1 },
|
|
344
|
+
platform: constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY,
|
|
345
|
+
currency_symbol: constants_1.CURRENCY_SYMBOL_ENUM.$,
|
|
346
|
+
categories: makeCategories(),
|
|
347
|
+
currentItemsPrice: 2000,
|
|
348
|
+
totalDiscountApplied: 0,
|
|
349
|
+
order_discount_details: null,
|
|
350
|
+
isEdit,
|
|
351
|
+
editedOrderRedeemedOffers: baseline,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
describe('getOffersWithStats — baseline exemption across all pathway gates', () => {
|
|
355
|
+
test.each(PATHWAY_CASES.map((pathwayCase) => [pathwayCase.pathway, pathwayCase]))('%s pathway keeps the edited order claim with a baseline and blocks it on a new order', (_pathway, pathwayCase) => {
|
|
356
|
+
const edited = runPathwayStats({
|
|
357
|
+
pathwayCase,
|
|
358
|
+
isEdit: true,
|
|
359
|
+
baseline: { [OFFER_ID]: 1 },
|
|
360
|
+
});
|
|
361
|
+
expect(edited.unlockedOffersApplicableTimes[OFFER_ID]).toBe(1);
|
|
362
|
+
expect(edited.offersWithStats[0].stats.message).not.toContain('personal limit');
|
|
363
|
+
const fresh = runPathwayStats({ pathwayCase });
|
|
364
|
+
expect(fresh.unlockedOffersApplicableTimes[OFFER_ID]).toBe(0);
|
|
365
|
+
expect(fresh.offersWithStats[0].stats.message).toContain('personal limit');
|
|
366
|
+
});
|
|
367
|
+
});
|