Skip to content

Commit d975d48

Browse files
committed
Updated packages/excel-parser/src/parse-excel.ts so the parsed JSON representation preserves raw record IDs as object keys instead of sanitizing them. This keeps the in-memory/JSON parse result faithful to the Excel source, while leaving filename-safe encoding confined to the file-store output path in config-store-output.ts.
Updated the split parse-excel test suites to assert against raw ID keys for packs, variants, volume groups, suppliers, allocations, and supplier packs.
1 parent 02a378d commit d975d48

5 files changed

Lines changed: 128 additions & 105 deletions

File tree

packages/excel-parser/src/__tests__/parse-excel.letter-variants.test.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ describe("parse-excel letter variants", () => {
3030
],
3131
});
3232

33-
expect(result.packs.pack1.postage.id).toBe("postage-standard");
34-
expect(result.packs.pack1.postage.size).toBe("STANDARD");
35-
expect(result.packs.pack2.postage.id).toBe("postage-large");
36-
expect(result.packs.pack2.postage.size).toBe("LARGE");
37-
expect(result.variants.variant1.packSpecificationIds).toEqual([
33+
expect(result.packs["pack-1"]?.postage.id).toBe("postage-standard");
34+
expect(result.packs["pack-1"]?.postage.size).toBe("STANDARD");
35+
expect(result.packs["pack-2"]?.postage.id).toBe("postage-large");
36+
expect(result.packs["pack-2"]?.postage.size).toBe("LARGE");
37+
expect(result.variants["variant-1"]?.packSpecificationIds).toEqual([
3838
"pack-1",
3939
"pack-2",
4040
]);
@@ -54,7 +54,7 @@ describe("parse-excel letter variants", () => {
5454
],
5555
});
5656

57-
expect(result.variants.variantwithconstraints.constraints).toEqual({
57+
expect(result.variants["variant-with-constraints"]?.constraints).toEqual({
5858
sheets: { value: 8, operator: "LESS_THAN" },
5959
deliveryDays: { value: 3, operator: "LESS_THAN" },
6060
});
@@ -88,8 +88,8 @@ describe("parse-excel letter variants", () => {
8888
],
8989
});
9090

91-
expect(result.variants.variantwithids.clientId).toBe("client-123");
92-
expect(result.variants.variantwithids.campaignIds).toEqual([
91+
expect(result.variants["variant-with-ids"]?.clientId).toBe("client-123");
92+
expect(result.variants["variant-with-ids"]?.campaignIds).toEqual([
9393
"campaign-1",
9494
"campaign-2",
9595
"campaign-3",
@@ -109,7 +109,7 @@ describe("parse-excel letter variants", () => {
109109
],
110110
});
111111

112-
expect(result.variants.variantwithsupplier.supplierId).toBe(
112+
expect(result.variants["variant-with-supplier"]?.supplierId).toBe(
113113
"supplier-printco",
114114
);
115115
});
@@ -143,7 +143,7 @@ describe("parse-excel letter variants", () => {
143143
],
144144
});
145145

146-
expect(result.variants.variantpriority.priority).toBe(12);
146+
expect(result.variants["variant-priority"]?.priority).toBe(12);
147147
});
148148

149149
it("uses the LetterVariant priority default when omitted", () => {
@@ -174,7 +174,7 @@ describe("parse-excel letter variants", () => {
174174
],
175175
});
176176

177-
expect(result.variants.variantdefaultpriority.priority).toBe(50);
177+
expect(result.variants["variant-default-priority"]?.priority).toBe(50);
178178
});
179179

180180
it("uses the LetterVariant priority default when the Excel cell is blank", () => {
@@ -206,7 +206,7 @@ describe("parse-excel letter variants", () => {
206206
],
207207
});
208208

209-
expect(result.variants.variantblankpriority.priority).toBe(50);
209+
expect(result.variants["variant-blank-priority"]?.priority).toBe(50);
210210
});
211211

212212
it("throws when LetterVariant priority is outside the allowed range", () => {
@@ -253,7 +253,9 @@ describe("parse-excel letter variants", () => {
253253
],
254254
});
255255

256-
expect(result.variants.variantnodesc.description).toBe("My Variant Name");
256+
expect(result.variants["variant-no-desc"]?.description).toBe(
257+
"My Variant Name",
258+
);
257259
});
258260

259261
it("throws on empty packSpecificationIds", () => {
@@ -299,7 +301,9 @@ describe("parse-excel letter variants", () => {
299301
],
300302
});
301303

302-
expect(result.variants.variantnoconstraints.constraints).toBeUndefined();
304+
expect(
305+
result.variants["variant-no-constraints"]?.constraints,
306+
).toBeUndefined();
303307
});
304308

305309
it("trims spaces in campaignIds and packSpecificationIds", () => {
@@ -337,11 +341,11 @@ describe("parse-excel letter variants", () => {
337341
],
338342
});
339343

340-
expect(result.variants.variantspace.packSpecificationIds).toEqual([
344+
expect(result.variants["variant-space"]?.packSpecificationIds).toEqual([
341345
"pack-space-1",
342346
"pack-space-2",
343347
]);
344-
expect(result.variants.variantspace.campaignIds).toEqual([
348+
expect(result.variants["variant-space"]?.campaignIds).toEqual([
345349
"campaign-1",
346350
"campaign-2",
347351
]);
@@ -361,7 +365,7 @@ describe("parse-excel letter variants", () => {
361365
],
362366
});
363367

364-
expect(result.variants.variantwithsides.constraints).toEqual({
368+
expect(result.variants["variant-with-sides"]?.constraints).toEqual({
365369
sheets: { value: 8, operator: "LESS_THAN" },
366370
sides: { value: 16, operator: "LESS_THAN" },
367371
deliveryDays: { value: 3, operator: "LESS_THAN" },

0 commit comments

Comments
 (0)