@pdtf/schemas 3.4.1-3 → 3.4.1-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "3.4.1-3",
3
+ "version": "3.4.1-4",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -1862,7 +1862,8 @@
1862
1862
  }
1863
1863
  },
1864
1864
  "baspi4Required": ["wholeFreeholdForSale"],
1865
- "baspi5Required": ["wholeFreeholdForSale"]
1865
+ "baspi5Required": ["wholeFreeholdForSale"],
1866
+ "nts2Required": ["estateRentcharges"]
1866
1867
  },
1867
1868
  {
1868
1869
  "properties": {
@@ -58,7 +58,10 @@
58
58
  ],
59
59
  "type": "object"
60
60
  }
61
- }
61
+ },
62
+ "required": [
63
+ "estateRentcharges"
64
+ ]
62
65
  }
63
66
  ]
64
67
  }
@@ -351,6 +351,89 @@ describe("Extension Overlays", () => {
351
351
  expect(siSection.required).toContain("containsAsbestos");
352
352
  });
353
353
 
354
+ test("should make estateRentcharges required when er extension is applied", () => {
355
+ const schema = getTransactionSchema(schemaId, ["nts2023", "er"]);
356
+
357
+ // Check that estateRentcharges is required at the oneOf branch level
358
+ const freeholdBranch =
359
+ schema.properties?.propertyPack?.properties?.ownership?.properties
360
+ ?.ownershipsToBeTransferred?.items?.oneOf?.[0];
361
+
362
+ expect(freeholdBranch).toBeDefined();
363
+ expect(freeholdBranch.required).toBeDefined();
364
+ expect(freeholdBranch.required).toContain("estateRentcharges");
365
+
366
+ // Verify the estateRentcharges property itself is properly structured
367
+ const erProp = freeholdBranch.properties?.estateRentcharges;
368
+ expect(erProp).toBeDefined();
369
+ expect(erProp.ntsRef).toBe("A3.4");
370
+ expect(erProp.required).toContain("yesNo");
371
+ });
372
+
373
+ test("should consistently apply required fields at parent level for extension properties", () => {
374
+ // Test multiple extensions that should have required fields at parent level
375
+ const schema = getTransactionSchema(schemaId, [
376
+ "nts2023",
377
+ "jk",
378
+ "er",
379
+ "ma",
380
+ "tf",
381
+ ]);
382
+
383
+ // Check specialist issues - japaneseKnotweed should be required
384
+ const siSection =
385
+ schema.properties?.propertyPack?.properties?.specialistIssues;
386
+ expect(siSection?.required).toContain("japaneseKnotweed");
387
+
388
+ // Check ownership - estateRentcharges should be required in freehold branch
389
+ const freeholdBranch =
390
+ schema.properties?.propertyPack?.properties?.ownership?.properties
391
+ ?.ownershipsToBeTransferred?.items?.oneOf?.[0];
392
+ expect(freeholdBranch?.required).toContain("estateRentcharges");
393
+
394
+ // Check leasehold - leaseholdInformation should be required in leasehold branch
395
+ const leaseholdBranch =
396
+ schema.properties?.propertyPack?.properties?.ownership?.properties
397
+ ?.ownershipsToBeTransferred?.items?.oneOf?.[2];
398
+ expect(leaseholdBranch?.required).toContain("leaseholdInformation");
399
+
400
+ // Verify that the required arrays are properly merged (not overwritten)
401
+ // Note: The length check might fail if only one extension is applied to specialistIssues
402
+ // Let's check what's actually in the required arrays
403
+ console.log("SpecialistIssues required:", siSection?.required);
404
+ console.log("FreeholdBranch required:", freeholdBranch?.required);
405
+ console.log("LeaseholdBranch required:", leaseholdBranch?.required);
406
+
407
+ expect(siSection.required.length).toBeGreaterThanOrEqual(1);
408
+ expect(freeholdBranch.required.length).toBeGreaterThan(0);
409
+ expect(leaseholdBranch.required.length).toBeGreaterThan(0);
410
+ });
411
+
412
+ test("should merge required arrays for multiple specialist issues overlays", () => {
413
+ // Apply multiple specialist issues overlays
414
+ const overlays = ["nts2023", "jk", "as", "dr", "sb", "hs"];
415
+ const schema = getTransactionSchema(schemaId, overlays);
416
+ const siSection =
417
+ schema.properties?.propertyPack?.properties?.specialistIssues;
418
+
419
+ // The overlays correspond to these property keys
420
+ const expectedRequired = [
421
+ "japaneseKnotweed",
422
+ "containsAsbestos",
423
+ "dryRotEtcTreatment",
424
+ "subsidenceOrStructuralFault",
425
+ "ongoingHealthOrSafetyIssue",
426
+ ];
427
+
428
+ expect(siSection?.required).toBeDefined();
429
+ // Should contain all expected keys
430
+ expectedRequired.forEach((key) => {
431
+ expect(siSection.required).toContain(key);
432
+ });
433
+ // Should be the same length as the number of overlays (excluding nts2023)
434
+ expect(siSection.required.length).toBe(expectedRequired.length);
435
+ });
436
+
354
437
  test("should handle discriminator patterns correctly", () => {
355
438
  const schema = getTransactionSchema(schemaId, ["nts2023", "jk"]);
356
439
  const jkProp =