@7365admin1/core 3.100.1 → 3.102.0

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.
@@ -0,0 +1,70 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+
4
+ import { notificationKind, withNotificationKind } from "./.build/utils/notification-kind.util.mjs";
5
+ import { MNotification } from "./.build/models/notification.model.mjs";
6
+
7
+ const ID = "6512f0a1b2c3d4e5f6a7b8c9";
8
+ const USER = "6602aa11bb22cc33dd44ee55";
9
+
10
+ // [sender, data it sends, category it passes, kind the row must carry]
11
+ const SENDERS = [
12
+ ["clientCreated", { module: "platform", kind: "client" }, "platform", "client"],
13
+ ["robotFault", { module: "platform", kind: "robot" }, "platform", "robot"],
14
+ ["robotConnection", { module: "platform", kind: "robot" }, "platform", "robot"],
15
+ ["bulletinBoardCreated", { module: "bulletinBoard" }, "bulletinBoard", "bulletinBoard"],
16
+ ["bulletinBoardCreatedForMA", { module: "bulletinBoard" }, "bulletinBoard", "bulletinBoard"],
17
+ ["bulletinBoardCreatedForServiceApps", { module: "bulletinBoard" }, undefined, "bulletinBoard"],
18
+ ["prelovedMarketplacePostCreation", { module: "prelovedMarketplace" }, undefined, "prelovedMarketplace"],
19
+ ["onlineFormRequestStatusUpdated", { module: "onlineForm" }, undefined, "onlineForm"],
20
+ ["eventCreatedForMA", { module: "event" }, undefined, "event"],
21
+ ["invitedVisitorCheckOutForMa", { module: "visitors" }, undefined, "visitors"],
22
+ ["serviceProviderInvited", { module: "other" }, "serviceProviderInvite", "serviceProviderInvite"],
23
+ ["serviceProviderInviteAnswered", { module: "other", kind: "serviceProviderInviteAnswer" }, "serviceProviderInvite", "serviceProviderInviteAnswer"],
24
+ ["incidentReported", { module: "incidentReport" }, "incidentReport", "incidentReport"],
25
+ ["incidentStatusChanged", { module: "incidentReport" }, "incidentReport", "incidentReport"],
26
+ ["emergencyContactChanged", { module: "emergencyContact" }, "emergencyContact", "emergencyContact"],
27
+ ["patrolException", { module: "virtualPatrol" }, "virtualPatrol", "virtualPatrol"],
28
+ ["cameraFault", { module: "cameraFault" }, "cameraFault", "cameraFault"],
29
+ ["documentExpiryReminder", { module: "documentExpiry" }, "documentExpiry", "documentExpiry"],
30
+ // API-core's sender computes the same thing inline; its tags, for the record.
31
+ ["feedback*", { module: "feedback" }, undefined, "feedback"],
32
+ ["workOrder*", { module: "workOrder" }, undefined, "workOrder"],
33
+ ["facilityBooking*", { module: "facilityBooking" }, undefined, "facilityBooking"],
34
+ ["invitedVisitorCheckIn", { module: "myVisitors" }, undefined, "myVisitors"],
35
+ ["inventoryAlert", { module: "inventory" }, "inventory", "inventory"],
36
+ ["marketplaceOrder*", { module: "marketplace-order" }, "marketplaceOrder", "marketplace-order"],
37
+ ["marketplaceVendorOrder*", { module: "marketplace-vendor-order" }, "marketplaceVendorOrder", "marketplace-vendor-order"],
38
+ ];
39
+
40
+ for (const [sender, data, category, kind] of SENDERS) {
41
+ test(`${sender} rows carry kind "${kind}" and still pass the stored schema`, () => {
42
+ const out = withNotificationKind({ ...data, params: { id: ID } }, category);
43
+ assert.equal(out.params.kind, kind);
44
+ assert.equal(out.params.id, ID);
45
+ // The stored row is validated; a kind must never get it rejected.
46
+ assert.doesNotThrow(() =>
47
+ MNotification({ userId: USER, screen: "", module: "other", params: out.params }),
48
+ );
49
+ });
50
+ }
51
+
52
+ test("a row with no id is left alone - params without an id would be rejected", () => {
53
+ const data = { module: "virtualPatrol" };
54
+ assert.equal(withNotificationKind(data, "virtualPatrol"), data);
55
+ assert.equal(withNotificationKind(undefined, "x"), undefined);
56
+ });
57
+
58
+ test("other / platform with no better name give no kind (readers fall back)", () => {
59
+ assert.equal(notificationKind({ module: "other" }, undefined), "");
60
+ assert.equal(notificationKind({ module: "platform" }, "platform"), "");
61
+ const data = { module: "other", params: { id: ID } };
62
+ assert.equal(withNotificationKind(data, undefined), data);
63
+ });
64
+
65
+ test("existing params keys survive", () => {
66
+ const out = withNotificationKind(
67
+ { module: "onlineForm", params: { id: ID, submissionStatus: "pending" } },
68
+ );
69
+ assert.deepEqual(out.params, { id: ID, submissionStatus: "pending", kind: "onlineForm" });
70
+ });