@managesome/eposmatic-toolkit 0.4.52 → 0.4.54

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.
Files changed (164) hide show
  1. package/esm/constants/MATERIALIZED_REPORTS.js +106 -2
  2. package/esm/constants/enums/delivery.js +13 -0
  3. package/esm/helpers/materialized-reports/index.js +6 -0
  4. package/esm/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +8 -62
  5. package/esm/helpers/materialized-reports/materialized-delivery-classification-helpers.js +95 -73
  6. package/esm/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +118 -146
  7. package/esm/helpers/materialized-reports/materialized-delivery-compile-helpers.js +304 -71
  8. package/esm/helpers/materialized-reports/materialized-delivery-entry-pages.js +307 -0
  9. package/esm/helpers/materialized-reports/materialized-delivery-index-migration.js +103 -0
  10. package/esm/helpers/materialized-reports/materialized-delivery-rows.js +109 -0
  11. package/esm/helpers/materialized-reports/materialized-delivery-wipe-targets.js +32 -0
  12. package/esm/helpers/materialized-reports/materialized-document-size.js +65 -0
  13. package/esm/helpers/materialized-reports/materialized-index-bootstrap.js +31 -16
  14. package/esm/helpers/materialized-reports/materialized-integer-contract.js +10 -1
  15. package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +3 -91
  16. package/esm/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.js +597 -0
  17. package/esm/helpers/materialized-reports/report-platform/definition.js +508 -0
  18. package/esm/helpers/materialized-reports/report-platform/index.js +4 -0
  19. package/esm/helpers/materialized-reports/report-platform/lifecycle/budget.js +27 -0
  20. package/esm/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.js +12 -0
  21. package/esm/helpers/materialized-reports/report-platform/lifecycle/entry-pages.js +121 -0
  22. package/esm/helpers/materialized-reports/report-platform/lifecycle/flat-projection.js +14 -0
  23. package/esm/helpers/materialized-reports/report-platform/lifecycle/index.js +8 -0
  24. package/esm/helpers/materialized-reports/report-platform/lifecycle/iteration-row.js +10 -0
  25. package/esm/helpers/materialized-reports/report-platform/lifecycle/run-stats.js +42 -0
  26. package/esm/helpers/materialized-reports/report-platform/lifecycle/scope-refs.js +28 -0
  27. package/esm/helpers/materialized-reports/report-platform/lifecycle/top-n.js +24 -0
  28. package/esm/helpers/materialized-reports/report-platform/registry.js +23 -0
  29. package/esm/helpers/materialized-reports/report-platform/validate-report-registry.js +214 -0
  30. package/esm/helpers/materialized-reports/scope-helpers.js +98 -0
  31. package/esm/helpers/materialized-reports/tenant-delivery-formatter.js +70 -20
  32. package/esm/schemas/models/applied_order_discounts.js +103 -0
  33. package/esm/schemas/models/index.js +12 -10
  34. package/esm/schemas/models/materialized_tenant_delivery_entries.js +33 -12
  35. package/esm/schemas/models/materialized_tenant_delivery_geo_cells.js +83 -0
  36. package/esm/schemas/models/materialized_tenant_delivery_geo_scopes.js +35 -0
  37. package/esm/schemas/models/materialized_tenant_delivery_reports.js +10 -1
  38. package/esm/schemas/types/applied_order_discounts.js +1 -0
  39. package/esm/schemas/types/index.js +14 -12
  40. package/esm/schemas/types/materialized_tenant_delivery_geo_cells.js +1 -0
  41. package/esm/schemas/types/materialized_tenant_delivery_geo_scopes.js +1 -0
  42. package/lib/constants/MATERIALIZED_REPORTS.d.ts +95 -1
  43. package/lib/constants/MATERIALIZED_REPORTS.js +108 -4
  44. package/lib/constants/enums/delivery.d.ts +9 -0
  45. package/lib/constants/enums/delivery.js +14 -1
  46. package/lib/helpers/materialized-reports/index.d.ts +6 -0
  47. package/lib/helpers/materialized-reports/index.js +6 -0
  48. package/lib/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +8 -62
  49. package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.d.ts +36 -9
  50. package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.js +94 -72
  51. package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.d.ts +23 -26
  52. package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +121 -150
  53. package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.d.ts +44 -5
  54. package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.js +306 -69
  55. package/lib/helpers/materialized-reports/materialized-delivery-entry-pages.d.ts +128 -0
  56. package/lib/helpers/materialized-reports/materialized-delivery-entry-pages.js +322 -0
  57. package/lib/helpers/materialized-reports/materialized-delivery-index-migration.d.ts +48 -0
  58. package/lib/helpers/materialized-reports/materialized-delivery-index-migration.js +108 -0
  59. package/lib/helpers/materialized-reports/materialized-delivery-rows.d.ts +15 -0
  60. package/lib/helpers/materialized-reports/materialized-delivery-rows.js +115 -0
  61. package/lib/helpers/materialized-reports/materialized-delivery-wipe-targets.d.ts +17 -0
  62. package/lib/helpers/materialized-reports/materialized-delivery-wipe-targets.js +35 -0
  63. package/lib/helpers/materialized-reports/materialized-document-size.d.ts +47 -0
  64. package/lib/helpers/materialized-reports/materialized-document-size.js +73 -0
  65. package/lib/helpers/materialized-reports/materialized-index-bootstrap.js +28 -13
  66. package/lib/helpers/materialized-reports/materialized-integer-contract.js +10 -1
  67. package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +2 -90
  68. package/lib/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.d.ts +186 -0
  69. package/lib/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.js +620 -0
  70. package/lib/helpers/materialized-reports/report-platform/definition.d.ts +133 -0
  71. package/lib/helpers/materialized-reports/report-platform/definition.js +511 -0
  72. package/lib/helpers/materialized-reports/report-platform/index.d.ts +4 -0
  73. package/lib/helpers/materialized-reports/report-platform/index.js +20 -0
  74. package/lib/helpers/materialized-reports/report-platform/lifecycle/budget.d.ts +8 -0
  75. package/lib/helpers/materialized-reports/report-platform/lifecycle/budget.js +31 -0
  76. package/lib/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.d.ts +8 -0
  77. package/lib/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.js +16 -0
  78. package/lib/helpers/materialized-reports/report-platform/lifecycle/entry-pages.d.ts +40 -0
  79. package/lib/helpers/materialized-reports/report-platform/lifecycle/entry-pages.js +130 -0
  80. package/lib/helpers/materialized-reports/report-platform/lifecycle/flat-projection.d.ts +22 -0
  81. package/lib/helpers/materialized-reports/report-platform/lifecycle/flat-projection.js +17 -0
  82. package/lib/helpers/materialized-reports/report-platform/lifecycle/index.d.ts +8 -0
  83. package/lib/helpers/materialized-reports/report-platform/lifecycle/index.js +24 -0
  84. package/lib/helpers/materialized-reports/report-platform/lifecycle/iteration-row.d.ts +13 -0
  85. package/lib/helpers/materialized-reports/report-platform/lifecycle/iteration-row.js +13 -0
  86. package/lib/helpers/materialized-reports/report-platform/lifecycle/run-stats.d.ts +20 -0
  87. package/lib/helpers/materialized-reports/report-platform/lifecycle/run-stats.js +47 -0
  88. package/lib/helpers/materialized-reports/report-platform/lifecycle/scope-refs.d.ts +13 -0
  89. package/lib/helpers/materialized-reports/report-platform/lifecycle/scope-refs.js +31 -0
  90. package/lib/helpers/materialized-reports/report-platform/lifecycle/top-n.d.ts +16 -0
  91. package/lib/helpers/materialized-reports/report-platform/lifecycle/top-n.js +29 -0
  92. package/lib/helpers/materialized-reports/report-platform/registry.d.ts +13 -0
  93. package/lib/helpers/materialized-reports/report-platform/registry.js +31 -0
  94. package/lib/helpers/materialized-reports/report-platform/validate-report-registry.d.ts +20 -0
  95. package/lib/helpers/materialized-reports/report-platform/validate-report-registry.js +218 -0
  96. package/lib/helpers/materialized-reports/scope-helpers.d.ts +8 -0
  97. package/lib/helpers/materialized-reports/scope-helpers.js +99 -0
  98. package/lib/helpers/materialized-reports/tenant-delivery-formatter.d.ts +41 -0
  99. package/lib/helpers/materialized-reports/tenant-delivery-formatter.js +70 -20
  100. package/lib/helpers/order/payment-collection.d.ts +25 -0
  101. package/lib/helpers/order/payment-collection.js +51 -0
  102. package/lib/schemas/models/applied_order_discounts.d.ts +80 -0
  103. package/lib/schemas/models/applied_order_discounts.js +106 -0
  104. package/lib/schemas/models/index.d.ts +12 -10
  105. package/lib/schemas/models/index.js +12 -10
  106. package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +31 -9
  107. package/lib/schemas/models/materialized_tenant_delivery_entries.js +32 -11
  108. package/lib/schemas/models/materialized_tenant_delivery_geo_cells.d.ts +129 -0
  109. package/lib/schemas/models/materialized_tenant_delivery_geo_cells.js +86 -0
  110. package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.d.ts +71 -0
  111. package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.js +38 -0
  112. package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +10 -1
  113. package/lib/schemas/models/materialized_tenant_delivery_reports.js +10 -1
  114. package/lib/schemas/models/materialized_tenant_discount_sources.d.ts +15 -15
  115. package/lib/schemas/types/applied_order_discounts.d.ts +22 -0
  116. package/lib/schemas/types/applied_order_discounts.js +2 -0
  117. package/lib/schemas/types/index.d.ts +14 -12
  118. package/lib/schemas/types/index.js +14 -12
  119. package/lib/schemas/types/materialized_tenant_delivery_entries.d.ts +36 -4
  120. package/lib/schemas/types/materialized_tenant_delivery_geo_cells.d.ts +178 -0
  121. package/lib/schemas/types/materialized_tenant_delivery_geo_cells.js +2 -0
  122. package/lib/schemas/types/materialized_tenant_delivery_geo_scopes.d.ts +21 -0
  123. package/lib/schemas/types/materialized_tenant_delivery_geo_scopes.js +2 -0
  124. package/lib/schemas/types/materialized_tenant_delivery_reports.d.ts +49 -7
  125. package/lib/tests/materialized-reports/analytics-growth-helpers.test.d.ts +1 -0
  126. package/lib/tests/materialized-reports/analytics-overview-helpers.test.d.ts +1 -0
  127. package/lib/tests/materialized-reports/analytics-performance-helpers.test.d.ts +1 -0
  128. package/lib/tests/materialized-reports/characterization/delivery.characterization.test.d.ts +1 -0
  129. package/lib/tests/materialized-reports/characterization/delivery.characterization.test.js +229 -0
  130. package/lib/tests/materialized-reports/characterization/discount.characterization.test.d.ts +1 -0
  131. package/lib/tests/materialized-reports/characterization/discount.characterization.test.js +99 -0
  132. package/lib/tests/materialized-reports/characterization/fixtures.d.ts +30 -0
  133. package/lib/tests/materialized-reports/characterization/fixtures.js +402 -0
  134. package/lib/tests/materialized-reports/characterization/golden.d.ts +18 -0
  135. package/lib/tests/materialized-reports/characterization/golden.js +127 -0
  136. package/lib/tests/materialized-reports/characterization/overview.characterization.test.d.ts +1 -0
  137. package/lib/tests/materialized-reports/characterization/overview.characterization.test.js +69 -0
  138. package/lib/tests/materialized-reports/characterization/prep-time.characterization.test.d.ts +1 -0
  139. package/lib/tests/materialized-reports/characterization/prep-time.characterization.test.js +102 -0
  140. package/lib/tests/materialized-reports/materialized-delivery-accumulation.test.js +56 -19
  141. package/lib/tests/materialized-reports/materialized-delivery-budgets.test.d.ts +1 -0
  142. package/lib/tests/materialized-reports/materialized-delivery-budgets.test.js +91 -0
  143. package/lib/tests/materialized-reports/materialized-delivery-compile.test.js +271 -15
  144. package/lib/tests/materialized-reports/materialized-delivery-final-audit.test.d.ts +1 -0
  145. package/lib/tests/materialized-reports/materialized-delivery-final-audit.test.js +128 -0
  146. package/lib/tests/materialized-reports/materialized-delivery-fold.test.js +42 -5
  147. package/lib/tests/materialized-reports/materialized-delivery-formatter.test.js +13 -1
  148. package/lib/tests/materialized-reports/materialized-delivery-geo.test.d.ts +1 -0
  149. package/lib/tests/materialized-reports/materialized-delivery-geo.test.js +446 -0
  150. package/lib/tests/materialized-reports/materialized-delivery-plan.test.js +117 -25
  151. package/lib/tests/materialized-reports/materialized-delivery-practical.test.d.ts +1 -0
  152. package/lib/tests/materialized-reports/materialized-delivery-practical.test.js +344 -0
  153. package/lib/tests/materialized-reports/materialized-integer-contract.test.js +14 -0
  154. package/lib/tests/materialized-reports/materialized-tenant-sales-overview-reports-schema.test.js +1 -1
  155. package/lib/tests/materialized-reports/report-platform/lifecycle-primitives.test.d.ts +1 -0
  156. package/lib/tests/materialized-reports/report-platform/lifecycle-primitives.test.js +177 -0
  157. package/lib/tests/materialized-reports/report-platform/registry-conformance.test.d.ts +1 -0
  158. package/lib/tests/materialized-reports/report-platform/registry-conformance.test.js +214 -0
  159. package/lib/tests/materialized-reports/report-platform/registry-validation.test.d.ts +1 -0
  160. package/lib/tests/materialized-reports/report-platform/registry-validation.test.js +103 -0
  161. package/lib/tests/offer-item-resolution.test.js +1 -4
  162. package/lib/tests/payment-collection-timestamps.test.d.ts +1 -0
  163. package/lib/tests/payment-collection-timestamps.test.js +71 -0
  164. package/package.json +6 -2
@@ -0,0 +1,344 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const delivery_1 = require("../../constants/enums/delivery");
4
+ const index_1 = require("../../helpers/materialized-reports/index");
5
+ const materialized_delivery_entry_pages_1 = require("../../helpers/materialized-reports/materialized-delivery-entry-pages");
6
+ const materialized_document_size_1 = require("../../helpers/materialized-reports/materialized-document-size");
7
+ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
8
+ const TENANT = 'tenant-practical';
9
+ const BRAND = 'brand-practical';
10
+ const DAY = '2026-09-10';
11
+ const order = (id, over = {}) => ({
12
+ _id: id,
13
+ tenant_id: TENANT,
14
+ platform: 'POS_DELIVERY',
15
+ order_status: 'COMPLETED',
16
+ createdAt: new Date(DAY + 'T10:00:00.000Z'),
17
+ localDate: DAY,
18
+ localHour: 10,
19
+ net_sale_amount: 5000,
20
+ amount_collected: 5000,
21
+ delivery_details: { city: 'Istanbul', state: 'Istanbul', delivery_cost: 300 },
22
+ ...over,
23
+ });
24
+ const delivery = (id, orderId, over = {}) => ({
25
+ _id: id,
26
+ tenant_id: TENANT,
27
+ order_id: orderId,
28
+ rider_id: 'rider-1',
29
+ rider_name: 'Sam',
30
+ status: 'COMPLETED',
31
+ createdAt: new Date(DAY + 'T10:05:00.000Z'),
32
+ updatedAt: new Date(DAY + 'T10:35:00.000Z'),
33
+ delivered_at: new Date(DAY + 'T10:32:00.000Z'),
34
+ expected_delivery_at: null,
35
+ distance_in_meters_from_store: 3000,
36
+ rider_earnings: {
37
+ status: delivery_1.RIDER_EARNINGS_STATUS_ENUM.FINAL,
38
+ amount: 700,
39
+ },
40
+ tracking_enabled: true,
41
+ localDate: DAY,
42
+ ...over,
43
+ });
44
+ describe('delivery practical-scale correctness', () => {
45
+ it('uses a per-metric denominator for completion and total time', () => {
46
+ const compiled = (0, index_1.compileTenantDeliveryReports)({
47
+ tenantId: TENANT,
48
+ brandId: BRAND,
49
+ localDate: DAY,
50
+ orders: [order('o1'), order('o2', { localHour: 11 })],
51
+ deliveries: [
52
+ delivery('d1', 'o1'),
53
+ delivery('d2', 'o2', {
54
+ status: 'IN_PROGRESS',
55
+ delivered_at: null,
56
+ updatedAt: new Date(DAY + 'T11:06:00.000Z'),
57
+ }),
58
+ ],
59
+ computedAt: new Date(DAY + 'T23:00:00.000Z'),
60
+ });
61
+ const page = (0, index_1.getFormattedTenantDeliveryReporting)(compiled.reports)[0][0];
62
+ expect(page.summary.average_complete_minutes).toBe(27);
63
+ expect(page.summary.average_total_minutes).toBe(32);
64
+ // The old denominator was graded_count (2), which produced 13.5 / 16.
65
+ expect(page.summary.average_complete_minutes).not.toBe(13.5);
66
+ expect(page.summary.average_total_minutes).not.toBe(16);
67
+ });
68
+ it('attributes a delivery to the ORDER local day, even after midnight', () => {
69
+ const orderDate = '2026-09-10';
70
+ const o = order('o-midnight', {
71
+ localDate: orderDate,
72
+ createdAt: new Date('2026-09-10T20:50:00.000Z'),
73
+ localHour: 23,
74
+ });
75
+ const d = delivery('d-midnight', 'o-midnight', {
76
+ localDate: '2026-09-11',
77
+ createdAt: new Date('2026-09-10T21:10:00.000Z'),
78
+ updatedAt: new Date('2026-09-10T21:40:00.000Z'),
79
+ delivered_at: new Date('2026-09-10T21:35:00.000Z'),
80
+ });
81
+ const compiled = (0, index_1.compileTenantDeliveryReports)({
82
+ tenantId: TENANT,
83
+ brandId: BRAND,
84
+ localDate: orderDate,
85
+ orders: [o],
86
+ deliveries: [d],
87
+ computedAt: new Date(),
88
+ });
89
+ const row = Object.values(compiled.entries[0].delivery_entries ?? {}).flatMap((section) => section.rows)[0];
90
+ expect(row.source_local_date).toBe(orderDate);
91
+ expect(row.source_day_unattributed).toBe(false);
92
+ expect(row.order_status).toBe('COMPLETED');
93
+ expect(row.street).toBeUndefined();
94
+ });
95
+ it('excludes pickup orders from H3 cells and unknown aggregates', () => {
96
+ const cells = (0, index_1.compileDeliveryGeoCounters)({
97
+ tenantId: TENANT,
98
+ brandId: BRAND,
99
+ localDate: DAY,
100
+ orders: [
101
+ order('o-delivery', {
102
+ delivery_details: { city: 'Istanbul', delivery_cost: 300, lat: 41, lng: 29 },
103
+ }),
104
+ order('o-pickup', { delivery_details: null }),
105
+ ],
106
+ deliveries: [],
107
+ computedAt: new Date(),
108
+ });
109
+ expect(cells.reduce((sum, cell) => sum + cell.orders, 0)).toBe(1);
110
+ expect(cells.some((cell) => cell.h3_cell === '__UNKNOWN__')).toBe(false);
111
+ });
112
+ it('returns cap counts in the geo response', () => {
113
+ const cells = Array.from({ length: 2002 }, (_, index) => ({
114
+ tenant_id: TENANT,
115
+ brand_id: BRAND,
116
+ scope_context: 'localDate',
117
+ scope_field: DAY,
118
+ city: 'Istanbul',
119
+ h3_cell: String(800000000000000 + index),
120
+ resolution: 8,
121
+ location: {
122
+ type: 'Point',
123
+ coordinates: [29, 41],
124
+ },
125
+ orders: 3,
126
+ app_orders: 3,
127
+ delivery_records: 3,
128
+ completed: 3,
129
+ cancelled: 0,
130
+ net_sale_amount: 0,
131
+ delivery_charge_amount: 0,
132
+ rider_revenue_amount: 0,
133
+ schema_version: 1,
134
+ computed_at: new Date(),
135
+ }));
136
+ const response = (0, index_1.buildDeliveryGeoResponse)({
137
+ cells: cells.slice(0, 2000),
138
+ totalOrders: 6006,
139
+ totalAppOrders: 6006,
140
+ cappedCellCount: 2,
141
+ cappedOrderCount: 6,
142
+ });
143
+ expect(response.capped_cell_count).toBe(2);
144
+ expect(response.capped_order_count).toBe(6);
145
+ });
146
+ it('keeps a 5,000-order cell far below the 2 MiB geo budget', () => {
147
+ const orders = Array.from({ length: 5000 }, (_, index) => order('big-' + index, {
148
+ platform: 'P' + (index % 7),
149
+ order_status: ['COMPLETED', 'CANCELLED', 'PENDING'][index % 3],
150
+ delivery_details: { city: 'Istanbul', delivery_cost: 300, lat: 41, lng: 29 },
151
+ }));
152
+ const result = (0, index_1.compileTenantDeliveryGeoCellsWithStats)({
153
+ tenantId: TENANT,
154
+ brandId: BRAND,
155
+ localDate: DAY,
156
+ orders,
157
+ deliveries: [],
158
+ computedAt: new Date(),
159
+ });
160
+ expect(result.cells).toHaveLength(1);
161
+ const keys = Object.keys(result.cells[0].by_key ?? {});
162
+ expect(keys.length).toBeLessThanOrEqual(64);
163
+ expect((0, materialized_document_size_1.materializedDocumentBsonBytes)(result.cells[0])).toBeLessThan(2 * 1024 * 1024);
164
+ });
165
+ it('reports write-time cell cap counts', () => {
166
+ const orders = [41.0, 41.1, 41.2].map((lat, index) => order('cap-' + index, {
167
+ delivery_details: { city: 'Istanbul', delivery_cost: 300, lat, lng: 29 + index * 0.1 },
168
+ }));
169
+ const result = (0, index_1.compileTenantDeliveryGeoCellsWithStats)({
170
+ tenantId: TENANT,
171
+ brandId: BRAND,
172
+ localDate: DAY,
173
+ orders,
174
+ deliveries: [],
175
+ computedAt: new Date(),
176
+ maxCells: 1,
177
+ });
178
+ expect(result.cells).toHaveLength(1);
179
+ expect(result.cappedCellCount).toBe(2);
180
+ expect(result.cappedOrderCount).toBe(2);
181
+ });
182
+ it('filters H3 cells by platform and order status through by_key', () => {
183
+ const cells = (0, index_1.compileDeliveryGeoCounters)({
184
+ tenantId: TENANT,
185
+ brandId: BRAND,
186
+ localDate: DAY,
187
+ orders: [
188
+ order('o-completed-pos', {
189
+ order_status: 'COMPLETED',
190
+ platform: 'POS_DELIVERY',
191
+ delivery_details: { city: 'Istanbul', delivery_cost: 300, lat: 41, lng: 29 },
192
+ }),
193
+ order('o-cancelled-web', {
194
+ order_status: 'CANCELLED',
195
+ platform: 'WEB_DELIVERY',
196
+ delivery_details: { city: 'Istanbul', delivery_cost: 300, lat: 41.0001, lng: 29.0001 },
197
+ }),
198
+ ],
199
+ deliveries: [],
200
+ computedAt: new Date(),
201
+ });
202
+ const all = (0, index_1.buildDeliveryGeoResponse)({ cells, totalOrders: 2, totalAppOrders: 0, minOrders: 1 });
203
+ const cancelled = (0, index_1.buildDeliveryGeoResponse)({
204
+ cells,
205
+ totalOrders: 1,
206
+ totalAppOrders: 0,
207
+ minOrders: 1,
208
+ filters: { order_statuses: ['CANCELLED'] },
209
+ });
210
+ const web = (0, index_1.buildDeliveryGeoResponse)({
211
+ cells,
212
+ totalOrders: 1,
213
+ totalAppOrders: 0,
214
+ minOrders: 1,
215
+ filters: { platforms: ['WEB_DELIVERY'] },
216
+ });
217
+ const both = (0, index_1.buildDeliveryGeoResponse)({
218
+ cells,
219
+ totalOrders: 1,
220
+ totalAppOrders: 0,
221
+ minOrders: 1,
222
+ filters: { platforms: ['WEB_DELIVERY'], order_statuses: ['CANCELLED'] },
223
+ });
224
+ expect(all.cells.reduce((sum, cell) => sum + cell.orders, 0)).toBe(2);
225
+ expect(cancelled.cells.reduce((sum, cell) => sum + cell.orders, 0)).toBe(1);
226
+ expect(web.cells.reduce((sum, cell) => sum + cell.orders, 0)).toBe(1);
227
+ expect(both.cells.reduce((sum, cell) => sum + cell.orders, 0)).toBe(1);
228
+ expect(cancelled.cells[0].orders).toBe(1);
229
+ expect(both.cells[0].orders).toBe(1);
230
+ for (const cell of cells) {
231
+ expect(Object.values(cell.by_key ?? {}).reduce((sum, value) => sum + value.orders, 0)).toBe(cell.orders);
232
+ }
233
+ });
234
+ it('city filter narrows cells without touching the by_key sums', () => {
235
+ const cells = (0, index_1.compileDeliveryGeoCounters)({
236
+ tenantId: TENANT,
237
+ brandId: BRAND,
238
+ localDate: DAY,
239
+ orders: [
240
+ order('o-istanbul', {
241
+ delivery_details: { city: 'Istanbul', delivery_cost: 300, lat: 41, lng: 29 },
242
+ }),
243
+ order('o-ankara', {
244
+ delivery_details: { city: 'Ankara', delivery_cost: 300, lat: 39.9, lng: 32.9 },
245
+ }),
246
+ ],
247
+ deliveries: [],
248
+ computedAt: new Date(),
249
+ });
250
+ const istanbul = (0, index_1.buildDeliveryGeoResponse)({
251
+ cells,
252
+ totalOrders: 1,
253
+ totalAppOrders: 0,
254
+ minOrders: 1,
255
+ filters: { cities: ['Istanbul'] },
256
+ });
257
+ expect(istanbul.cells).toHaveLength(1);
258
+ expect(istanbul.cells[0].city).toBe('Istanbul');
259
+ expect(istanbul.cells[0].orders).toBe(1);
260
+ for (const cell of cells) {
261
+ expect(Object.values(cell.by_key ?? {}).reduce((sum, value) => sum + value.orders, 0)).toBe(cell.orders);
262
+ }
263
+ });
264
+ it('splits a synthetic over-budget entry page deterministically', () => {
265
+ const rows = Array.from({ length: 35000 }, (_, index) => ({
266
+ delivery_id: 'd-' + index,
267
+ entry_key: 'e-' + index,
268
+ order_id: 'o-' + index,
269
+ source_local_date: DAY,
270
+ delivered_at: new Date(DAY + 'T10:00:00.000Z'),
271
+ created_at: new Date(DAY + 'T09:00:00.000Z'),
272
+ rider_name: 'r'.repeat(420),
273
+ }));
274
+ const document = {
275
+ tenant_id: TENANT,
276
+ brand_id: BRAND,
277
+ scope_context: 'localMonth',
278
+ scope_field: '2026-09',
279
+ page: DAY,
280
+ day_index: null,
281
+ sale_type_key_filters: ['ORDER_STATUS', 'PLATFORM', 'CITY'],
282
+ delivery_entries: { 'COMPLETED:POS_DELIVERY': { rows } },
283
+ off_app_order_count: 3,
284
+ schema_version: 3,
285
+ source_watermark: new Date(DAY + 'T23:00:00.000Z'),
286
+ computed_at: new Date(DAY + 'T23:00:00.000Z'),
287
+ createdAt: new Date(DAY + 'T23:00:00.000Z'),
288
+ updatedAt: new Date(DAY + 'T23:00:00.000Z'),
289
+ };
290
+ expect((0, materialized_document_size_1.materializedDocumentBsonBytes)(document)).toBeGreaterThan(MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_ENTRY_MAX_BSON_BYTES);
291
+ const pages = (0, index_1.splitMaterializedDeliveryEntryPage)(document);
292
+ expect(pages.length).toBeGreaterThan(1);
293
+ const ids = new Set();
294
+ let count = 0;
295
+ for (const page of pages) {
296
+ expect((0, materialized_document_size_1.materializedDocumentBsonBytes)(page)).toBeLessThanOrEqual(MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_ENTRY_MAX_BSON_BYTES);
297
+ expect((0, materialized_delivery_entry_pages_1.isDeliveryEntryPageForSourceDay)(page.scope_context, page.page, DAY)).toBe(true);
298
+ for (const section of Object.values(page.delivery_entries ?? {})) {
299
+ for (const row of section.rows) {
300
+ ids.add(String(row.delivery_id));
301
+ count += 1;
302
+ }
303
+ }
304
+ }
305
+ expect(count).toBe(rows.length);
306
+ expect(ids.size).toBe(rows.length);
307
+ const merged = (0, index_1.mergeMaterializedDeliveryEntryPages)(pages);
308
+ const mergedRows = Object.values(merged.delivery_entries ?? {}).flatMap((section) => section.rows);
309
+ expect(mergedRows.length).toBe(rows.length);
310
+ expect(new Set(mergedRows.map((row) => row.delivery_id)).size).toBe(rows.length);
311
+ expect(merged.off_app_order_count).toBe(3);
312
+ });
313
+ it('filters totals by order status, platform and city', () => {
314
+ const compiled = (0, index_1.compileTenantDeliveryReports)({
315
+ tenantId: TENANT,
316
+ brandId: BRAND,
317
+ localDate: DAY,
318
+ orders: [
319
+ order('o1', { order_status: 'COMPLETED', platform: 'POS_DELIVERY' }),
320
+ order('o2', {
321
+ order_status: 'CANCELLED',
322
+ platform: 'WEB_DELIVERY',
323
+ delivery_details: { city: 'Ankara', delivery_cost: 300 },
324
+ }),
325
+ ],
326
+ deliveries: [],
327
+ computedAt: new Date(),
328
+ });
329
+ const all = (0, index_1.getFormattedTenantDeliveryReporting)(compiled.reports)[0][0];
330
+ const cancelled = (0, index_1.getFormattedTenantDeliveryReporting)(compiled.reports, {
331
+ order_statuses: ['CANCELLED'],
332
+ })[0][0];
333
+ const pos = (0, index_1.getFormattedTenantDeliveryReporting)(compiled.reports, {
334
+ platforms: ['POS_DELIVERY'],
335
+ })[0][0];
336
+ const ankara = (0, index_1.getFormattedTenantDeliveryReporting)(compiled.reports, {
337
+ cities: ['Ankara'],
338
+ })[0][0];
339
+ expect(all.summary.orders).toBe(2);
340
+ expect(cancelled.summary.orders).toBe(1);
341
+ expect(pos.summary.orders).toBe(1);
342
+ expect(ankara.summary.orders).toBe(1);
343
+ });
344
+ });
@@ -232,3 +232,17 @@ describe('a FULL discount document set is integer-only', () => {
232
232
  }
233
233
  });
234
234
  });
235
+ describe('geometry is the one exception', () => {
236
+ it('accepts a GeoJSON centroid while still rejecting money decimals', () => {
237
+ expect((0, materialized_integer_contract_1.findNonIntegerNumericLeaves)({
238
+ h3_cell: '88194ad33dfffff',
239
+ orders: 3,
240
+ location: { type: 'Point', coordinates: [28.9784123, 41.0082456] },
241
+ })).toEqual([]);
242
+ expect((0, materialized_integer_contract_1.findNonIntegerNumericLeaves)({
243
+ orders: 3,
244
+ net_sale_amount: 12.5,
245
+ location: { type: 'Point', coordinates: [28.9784123, 41.0082456] },
246
+ }).map((violation) => violation.path)).toEqual(['net_sale_amount']);
247
+ });
248
+ });
@@ -209,7 +209,7 @@ describe('materialized_tenant_sales_overview_reports schema', () => {
209
209
  });
210
210
  it('rejects unsupported key-filter dimensions', () => {
211
211
  // NOTE: this test previously used 'CITY' as its unsupported example. The delivery
212
- // report (M4) legitimately ADDED CITY as a real dimension - a key is <PLATFORM>:<CITY>
212
+ // report (M4) legitimately ADDED CITY as a real dimension - a key is <ORDER_STATUS>:<PLATFORM>:<CITY>
213
213
  // - so the fixture silently stopped testing rejection. The sentinel is now a value
214
214
  // that is deliberately not a dimension, and the guard below makes the test fail
215
215
  // LOUDLY if that ever changes, instead of quietly passing on a valid value.
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const MATERIALIZED_REPORTS_1 = require("../../../constants/MATERIALIZED_REPORTS");
4
+ const materialized_reports_1 = require("../../../helpers/materialized-reports");
5
+ const budget_1 = require("../../../helpers/materialized-reports/report-platform/lifecycle/budget");
6
+ const cap_metadata_1 = require("../../../helpers/materialized-reports/report-platform/lifecycle/cap-metadata");
7
+ const entry_pages_1 = require("../../../helpers/materialized-reports/report-platform/lifecycle/entry-pages");
8
+ const flat_projection_1 = require("../../../helpers/materialized-reports/report-platform/lifecycle/flat-projection");
9
+ const iteration_row_1 = require("../../../helpers/materialized-reports/report-platform/lifecycle/iteration-row");
10
+ const run_stats_1 = require("../../../helpers/materialized-reports/report-platform/lifecycle/run-stats");
11
+ const scope_refs_1 = require("../../../helpers/materialized-reports/report-platform/lifecycle/scope-refs");
12
+ const top_n_1 = require("../../../helpers/materialized-reports/report-platform/lifecycle/top-n");
13
+ const registry_1 = require("../../../helpers/materialized-reports/report-platform/registry");
14
+ const report_contract_1 = require("../../../helpers/reporting-contract/report-contract");
15
+ const fixtures_1 = require("../characterization/fixtures");
16
+ const sortRefs = (refs) => [...refs].map((ref) => `${ref.scope_context}|${ref.scope_field}`).sort();
17
+ const fixtures = (0, fixtures_1.buildCharacterizationFixtures)();
18
+ const dayOrders = fixtures.dayOrders;
19
+ const delivery = (0, materialized_reports_1.compileTenantDeliveryReports)({
20
+ tenantId: fixtures_1.CHARACTERIZATION_TENANT_ID,
21
+ brandId: fixtures_1.CHARACTERIZATION_BRAND_ID,
22
+ localDate: fixtures_1.CHARACTERIZATION_DAY,
23
+ orders: dayOrders,
24
+ deliveries: fixtures.deliveries,
25
+ computedAt: fixtures_1.CHARACTERIZATION_COMPUTED_AT,
26
+ });
27
+ const discount = (0, materialized_reports_1.compileTenantDiscountReports)({
28
+ tenantId: fixtures_1.CHARACTERIZATION_TENANT_ID,
29
+ brandId: fixtures_1.CHARACTERIZATION_BRAND_ID,
30
+ localDate: fixtures_1.CHARACTERIZATION_DAY,
31
+ orders: dayOrders,
32
+ computedAt: fixtures_1.CHARACTERIZATION_COMPUTED_AT,
33
+ });
34
+ describe('lifecycle primitive: scope refs', () => {
35
+ it('matches the existing Overview ref builder', () => {
36
+ const definition = (0, registry_1.getReportDefinition)(report_contract_1.REPORT_KEY_ENUM.OVERVIEW);
37
+ expect(sortRefs((0, scope_refs_1.resolveReportScopeRefsForDay)(definition, fixtures_1.CHARACTERIZATION_DAY))).toEqual(sortRefs((0, materialized_reports_1.getMaterializedTenantSalesOverviewScopeRefsForDay)(fixtures_1.CHARACTERIZATION_DAY)));
38
+ });
39
+ it('matches the existing Discounts ref builder', () => {
40
+ const definition = (0, registry_1.getReportDefinition)(report_contract_1.REPORT_KEY_ENUM.DISCOUNTS);
41
+ expect(sortRefs((0, scope_refs_1.resolveReportScopeRefsForDay)(definition, fixtures_1.CHARACTERIZATION_DAY))).toEqual(sortRefs((0, materialized_reports_1.getMaterializedDiscountScopeRefsForDay)(fixtures_1.CHARACTERIZATION_DAY)));
42
+ });
43
+ it('keeps Prep/Delivery hour-free and returns all expected periods', () => {
44
+ for (const key of [report_contract_1.REPORT_KEY_ENUM.PREP_TIME, report_contract_1.REPORT_KEY_ENUM.DELIVERY]) {
45
+ const refs = (0, scope_refs_1.resolveReportScopeRefsForDay)((0, registry_1.getReportDefinition)(key), fixtures_1.CHARACTERIZATION_DAY);
46
+ expect(refs.some((ref) => ref.scope_context === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_HOUR)).toBe(false);
47
+ expect(refs.length).toBe((0, registry_1.getReportDefinition)(key).reportScopes.length);
48
+ }
49
+ });
50
+ });
51
+ describe('lifecycle primitive: entry pages', () => {
52
+ it('matches the existing Delivery page identity for every entry scope', () => {
53
+ const definition = (0, registry_1.getReportDefinition)(report_contract_1.REPORT_KEY_ENUM.DELIVERY);
54
+ for (const scope of definition.entryScopes) {
55
+ expect((0, entry_pages_1.resolveEntryPageForScope)(definition, scope, fixtures_1.CHARACTERIZATION_DAY)).toBe((0, materialized_reports_1.deliveryEntryPageOf)(scope, fixtures_1.CHARACTERIZATION_DAY));
56
+ }
57
+ expect((0, entry_pages_1.resolveEntryPageForScope)(definition, 'localQuarter', fixtures_1.CHARACTERIZATION_DAY)).toBeNull();
58
+ });
59
+ it('keeps the Discounts page identity (day/hour all, period source date)', () => {
60
+ const definition = (0, registry_1.getReportDefinition)(report_contract_1.REPORT_KEY_ENUM.DISCOUNTS);
61
+ expect((0, entry_pages_1.resolveEntryPageForScope)(definition, 'localDate', fixtures_1.CHARACTERIZATION_DAY)).toBe('all');
62
+ expect((0, entry_pages_1.resolveEntryPageForScope)(definition, 'localHour', fixtures_1.CHARACTERIZATION_DAY)).toBe('all');
63
+ expect((0, entry_pages_1.resolveEntryPageForScope)(definition, 'localMonth', fixtures_1.CHARACTERIZATION_DAY)).toBe(fixtures_1.CHARACTERIZATION_DAY);
64
+ });
65
+ it('keeps Prep Time page-less', () => {
66
+ const definition = (0, registry_1.getReportDefinition)(report_contract_1.REPORT_KEY_ENUM.PREP_TIME);
67
+ expect((0, entry_pages_1.resolveEntryPageForScope)(definition, 'localDate', fixtures_1.CHARACTERIZATION_DAY)).toBeNull();
68
+ });
69
+ it('reproduces the Delivery #N splitter byte-for-byte', () => {
70
+ const entry = delivery.entries.find((document) => document.scope_context === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE);
71
+ const legacy = (0, materialized_reports_1.splitMaterializedDeliveryEntryPage)(entry, 3000);
72
+ const generic = (0, entry_pages_1.splitEntryPage)({
73
+ document: entry,
74
+ maxBytes: 3000,
75
+ pageOf: (document) => document.page,
76
+ sectionsOf: (document) => document.delivery_entries ?? null,
77
+ rebuild: (document, page, sections) => ({
78
+ ...document,
79
+ page,
80
+ delivery_entries: sections,
81
+ }),
82
+ scopeLabel: (document) => `${document.scope_context}:${document.scope_field}`,
83
+ });
84
+ expect(generic).toEqual(legacy);
85
+ expect(generic.map((page) => page.page)).toEqual(legacy.map((page) => page.page));
86
+ });
87
+ it('keeps base/sub-page identities exact', () => {
88
+ expect((0, entry_pages_1.entryPageBase)('all')).toBe('all');
89
+ expect((0, entry_pages_1.entryPageBase)('all#2')).toBe('all');
90
+ expect((0, entry_pages_1.entryPageBase)((0, materialized_reports_1.deliveryEntryPageBase)('2026-09-14#3'))).toBe('2026-09-14');
91
+ expect((0, entry_pages_1.buildEntrySubPage)('2026-09-14', 0)).toBe('2026-09-14#0');
92
+ });
93
+ });
94
+ describe('lifecycle primitive: flat projection plan', () => {
95
+ it('matches the existing row + scope builders for Delivery', () => {
96
+ const entry = delivery.entries.find((document) => document.scope_context === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE);
97
+ const retargeted = { ...entry, scope_context: 'localDate', scope_field: fixtures_1.CHARACTERIZATION_DAY, day_index: null };
98
+ const directRows = (0, materialized_reports_1.buildMaterializedDrilldownRows)(MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_DELIVERY_ENTRIES, retargeted, fixtures_1.CHARACTERIZATION_DAY);
99
+ const directScope = (0, materialized_reports_1.buildMaterializedDrilldownScope)(MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_DELIVERY_ENTRIES, retargeted, directRows.rows, fixtures_1.CHARACTERIZATION_DAY);
100
+ const plan = (0, flat_projection_1.buildReportFlatProjectionPlan)({
101
+ reportType: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_DELIVERY_ENTRIES,
102
+ entryDocument: entry,
103
+ scopeContext: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
104
+ scopeField: fixtures_1.CHARACTERIZATION_DAY,
105
+ sourceLocalDate: fixtures_1.CHARACTERIZATION_DAY,
106
+ });
107
+ expect(plan.rows).toEqual(directRows.rows);
108
+ expect(plan.scope).toEqual(directScope);
109
+ });
110
+ it('matches the existing Discounts projection', () => {
111
+ const entry = discount.entries.find((document) => document.scope_context === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE);
112
+ const plan = (0, flat_projection_1.buildReportFlatProjectionPlan)({
113
+ reportType: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_DISCOUNT_ENTRIES,
114
+ entryDocument: entry,
115
+ scopeContext: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
116
+ scopeField: fixtures_1.CHARACTERIZATION_DAY,
117
+ sourceLocalDate: fixtures_1.CHARACTERIZATION_DAY,
118
+ });
119
+ expect(plan.rows.length).toBeGreaterThan(0);
120
+ expect(plan.scope).not.toBeNull();
121
+ });
122
+ });
123
+ describe('lifecycle primitive: iteration row', () => {
124
+ it('matches the existing iteration builder', () => {
125
+ const document = discount.reports.find((report) => report.scope_context === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE);
126
+ const direct = (0, materialized_reports_1.buildMaterializedTenantReportIteration)(document, {
127
+ reportType: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_DISCOUNT_REPORTS,
128
+ reason: 'CHARACTERIZATION',
129
+ computedAt: fixtures_1.CHARACTERIZATION_COMPUTED_AT,
130
+ });
131
+ const wrapped = (0, iteration_row_1.buildReportIterationRow)(document, {
132
+ reportType: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_DISCOUNT_REPORTS,
133
+ reason: 'CHARACTERIZATION',
134
+ computedAt: fixtures_1.CHARACTERIZATION_COMPUTED_AT,
135
+ });
136
+ expect(wrapped).toEqual(direct);
137
+ });
138
+ });
139
+ describe('lifecycle primitive: budget', () => {
140
+ it('resolves the declared report/entry/side budgets', () => {
141
+ const definition = (0, registry_1.getReportDefinition)(report_contract_1.REPORT_KEY_ENUM.DELIVERY);
142
+ expect((0, budget_1.getReportCollectionBudget)(definition, 'report')).toBe(15 * 1024 * 1024);
143
+ expect((0, budget_1.getReportCollectionBudget)(definition, 'entries')).toBe(15 * 1024 * 1024);
144
+ expect((0, budget_1.getReportCollectionBudget)(definition, 'side', 'materialized_tenant_delivery_geo_cells')).toBe(2 * 1024 * 1024);
145
+ });
146
+ it('throws when a document exceeds its declared budget', () => {
147
+ const definition = {
148
+ ...(0, registry_1.getReportDefinition)(report_contract_1.REPORT_KEY_ENUM.DELIVERY),
149
+ budgets: { materialized_tenant_delivery_entries: 64 },
150
+ };
151
+ expect(() => (0, budget_1.assertReportDocumentBudget)(definition, 'entries', { payload: 'x'.repeat(256) })).toThrow(/budget/i);
152
+ });
153
+ });
154
+ describe('lifecycle primitive: run stats / cap / top-N', () => {
155
+ it('builds and merges run stats', () => {
156
+ const left = (0, run_stats_1.buildReportRunStats)({ reportKey: 'A', localDate: '2026-09-14', documents: 2 });
157
+ const right = (0, run_stats_1.buildReportRunStats)({ reportKey: 'A', localDate: '2026-09-14', documents: 3, flatRows: 5 });
158
+ expect((0, run_stats_1.mergeReportRunStats)(left, right)).toMatchObject({ documents: 5, flatRows: 5 });
159
+ });
160
+ it('merges cap metadata and preserves exactness', () => {
161
+ const merged = (0, cap_metadata_1.mergeReportCapMetadata)({ cappedCellCount: 1, cappedOrderCount: 2, exact: true }, { cappedCellCount: 3, cappedOrderCount: 4, exact: false });
162
+ expect(merged).toEqual({ cappedCellCount: 4, cappedOrderCount: 6, exact: false });
163
+ expect((0, cap_metadata_1.mergeReportCapMetadata)(null, cap_metadata_1.EMPTY_REPORT_CAP_METADATA).exact).toBe(true);
164
+ });
165
+ it('selects top-N deterministically and folds the rest into __OTHER__', () => {
166
+ const entries = Array.from({ length: 51 }, (_, index) => ({
167
+ key: `City-${String(index).padStart(2, '0')}`,
168
+ count: 1,
169
+ }));
170
+ const selection = (0, top_n_1.selectReportTopN)(entries, 50);
171
+ expect(selection.kept).toHaveLength(50);
172
+ expect(selection.dropped).toEqual(['City-50']);
173
+ expect(selection.other).toBe(top_n_1.REPORT_OTHER_TOKEN);
174
+ expect((0, top_n_1.resolveReportTopNKey)(selection, 'City-50')).toBe(top_n_1.REPORT_OTHER_TOKEN);
175
+ expect((0, top_n_1.resolveReportTopNKey)(selection, 'City-00')).toBe('City-00');
176
+ });
177
+ });