@7365admin1/core 3.74.0 → 3.75.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.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/backfill-org-owner-roles.test.mjs +6 -1
- package/test/e2e/client-invite-service365.e2e.test.mjs +50 -1
- package/test/org-default-roles.test.mjs +11 -0
package/package.json
CHANGED
|
@@ -63,6 +63,11 @@ test("a role-less organisation gets exactly the roles defaultOwnerRoles writes",
|
|
|
63
63
|
for (const nature of APP_SERVICE_TYPES) {
|
|
64
64
|
const { payloads } = planForOrg(org({ nature }), 0);
|
|
65
65
|
const expected = defaultOwnerRoles(ORG, nature);
|
|
66
|
+
// The tool posts the nature as the role type; POST /api/roles stores a
|
|
67
|
+
// developer's as property_management_agency (`serviceAppType`), which is
|
|
68
|
+
// what defaultOwnerRoles writes directly.
|
|
69
|
+
const appType = nature === "real_estate_developer" ? "property_management_agency" : nature;
|
|
70
|
+
for (const p of payloads) if (p.type === nature) p.type = appType;
|
|
66
71
|
|
|
67
72
|
// Four now, not two. The tool duplicates the permission list so it runs
|
|
68
73
|
// with no build step, and THIS is the assertion that stops the copy
|
|
@@ -72,7 +77,7 @@ test("a role-less organisation gets exactly the roles defaultOwnerRoles writes",
|
|
|
72
77
|
assert.deepEqual(payloads.map(apiShape), expected.map(apiShape), nature);
|
|
73
78
|
assert.deepEqual(
|
|
74
79
|
payloads.map((p) => p.type),
|
|
75
|
-
["organization", "organization",
|
|
80
|
+
["organization", "organization", appType, appType],
|
|
76
81
|
);
|
|
77
82
|
assert.deepEqual(payloads.map((p) => p.name), [
|
|
78
83
|
"owner", "Administrator", "owner", "Administrator",
|
|
@@ -24,6 +24,7 @@ const PM_CLIENT = "pm-cis@e2e.example.com";
|
|
|
24
24
|
const RED_CLIENT = "red-cis@e2e.example.com";
|
|
25
25
|
|
|
26
26
|
const MODULES = ["visitor-mgmt", "members", "roles", "invitations", "sites"];
|
|
27
|
+
const RED_OWNER = ["visitor-mgmt:view-visitors", "members:view-members"];
|
|
27
28
|
|
|
28
29
|
// Every switch explicit, the way the form sends them.
|
|
29
30
|
const RESIDENT_APP = {
|
|
@@ -97,12 +98,60 @@ describe("Invite Client gives a Property Management client its Service365 module
|
|
|
97
98
|
});
|
|
98
99
|
|
|
99
100
|
it("a real estate developer gets the same Property Management set", async () => {
|
|
100
|
-
|
|
101
|
+
// Owner, 2026-09-15: Invite Client now offers Real Estate Developer, with the
|
|
102
|
+
// owner role chosen from the Property Management catalogue like a PM client.
|
|
103
|
+
const res = await invite(STAFF, { email: RED_CLIENT, app: ["real_estate_developer"], modules: MODULES, permissions: RED_OWNER, residentAppModules: RESIDENT_APP });
|
|
101
104
|
assert.equal(res.status, 201, JSON.stringify(res.body));
|
|
102
105
|
const made = await onboard(RED_CLIENT, "CIS Developer Client", "real_estate_developer");
|
|
103
106
|
assert.equal(made.status, 201, JSON.stringify(made.body));
|
|
104
107
|
const org = await h.db.collection("organizations").findOne({ name: "CIS Developer Client" });
|
|
105
108
|
assert.deepEqual(org.residentAppModules, RESIDENT_APP);
|
|
109
|
+
assert.deepEqual(org.modules, MODULES);
|
|
110
|
+
const owner = await h.db.collection("roles").findOne({ _id: org.invitedRole });
|
|
111
|
+
assert.ok(owner, "the chosen owner role is recorded on the organisation");
|
|
112
|
+
// The Property Management app reads property_management_agency roles and
|
|
113
|
+
// memberships; a developer-typed one was a role no application could open.
|
|
114
|
+
assert.equal(owner.type, "property_management_agency");
|
|
115
|
+
assert.deepEqual([...owner.permissions].sort(), [...RED_OWNER].sort());
|
|
116
|
+
assert.equal(org.nature, "real_estate_developer", "the organisation keeps its nature");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("a real estate developer's owner opens the Property Management app, capped like a PM client", async () => {
|
|
120
|
+
const org = await h.db.collection("organizations").findOne({ name: "CIS Developer Client" });
|
|
121
|
+
const owner = await h.db.collection("users").findOne({ email: RED_CLIENT });
|
|
122
|
+
|
|
123
|
+
// Onboarding's finish sends the invitation's app, which for a developer is its nature.
|
|
124
|
+
const member = await h.api("/members/direct", {
|
|
125
|
+
method: "POST",
|
|
126
|
+
sid: sid[RED_CLIENT],
|
|
127
|
+
body: { userId: owner._id.toString(), orgId: org._id.toString(), roleId: org.invitedRole.toString(), app: "real_estate_developer", siteId: new ObjectId().toString(), siteName: "Show flat" },
|
|
128
|
+
});
|
|
129
|
+
assert.equal(member.status, 201, JSON.stringify(member.body));
|
|
130
|
+
const rows = await h.db.collection("members").find({ org: org._id, user: owner._id, type: { $ne: "organization" } }).toArray();
|
|
131
|
+
assert.deepEqual(rows.map((r) => r.type), ["property_management_agency"]);
|
|
132
|
+
|
|
133
|
+
// Asked either way, the lookup answers with that one row.
|
|
134
|
+
for (const type of ["property_management_agency", "real_estate_developer"]) {
|
|
135
|
+
const res = await h.api(`/members/user/${owner._id}/app/${type}/org?org=${org._id}`, { sid: sid[RED_CLIENT] });
|
|
136
|
+
assert.equal(res.status, 200, `${type}: ${JSON.stringify(res.body)}`);
|
|
137
|
+
assert.equal(String(res.body._id), String(rows[0]._id));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// The grant caps the developer's roles, whichever type the request names.
|
|
141
|
+
for (const type of ["property_management_agency", "real_estate_developer"]) {
|
|
142
|
+
const wider = await h.api("/roles", {
|
|
143
|
+
method: "POST", sid: sid[RED_CLIENT],
|
|
144
|
+
body: { name: `Too wide ${type}`, type, org: org._id.toString(), permissions: ["visitor-mgmt:delete-visitor"] },
|
|
145
|
+
});
|
|
146
|
+
assert.ok([401, 403].includes(wider.status), `${type}: got ${wider.status} ${JSON.stringify(wider.body)}`);
|
|
147
|
+
}
|
|
148
|
+
const lead = await h.api("/roles", {
|
|
149
|
+
method: "POST", sid: sid[RED_CLIENT],
|
|
150
|
+
body: { name: "Estate lead", type: "real_estate_developer", org: org._id.toString(), permissions: ["visitor-mgmt:view-visitors"] },
|
|
151
|
+
});
|
|
152
|
+
assert.equal(lead.status, 201, JSON.stringify(lead.body));
|
|
153
|
+
const stored = await h.db.collection("roles").findOne({ org: org._id, name: "Estate lead" });
|
|
154
|
+
assert.equal(stored.type, "property_management_agency");
|
|
106
155
|
});
|
|
107
156
|
});
|
|
108
157
|
|
|
@@ -281,3 +281,14 @@ test("the owner-permissions kill switch", async () => {
|
|
|
281
281
|
assert.equal(clientInviteOwnerPermissionsOn({}), true);
|
|
282
282
|
assert.equal(clientInviteOwnerPermissionsOn({ CLIENT_INVITE_OWNER_PERMISSIONS: "off" }), false);
|
|
283
283
|
});
|
|
284
|
+
|
|
285
|
+
test("a real estate developer's application roles are Property Management roles", () => {
|
|
286
|
+
// Owner, 2026-09-12: a developer is the Property Management set. The PM app
|
|
287
|
+
// asks for property_management_agency roles; a developer-typed one was
|
|
288
|
+
// invisible to every application.
|
|
289
|
+
const roles = defaultOwnerRoles(ORG, "real_estate_developer", ["members:view-members"]);
|
|
290
|
+
const types = roles.map((r) => r.type).sort();
|
|
291
|
+
assert.deepEqual(types, ["organization", "organization", "property_management_agency", "property_management_agency"]);
|
|
292
|
+
const owner = roles.find((r) => r.type === "property_management_agency" && r.name === "owner");
|
|
293
|
+
assert.deepEqual(owner.permissions, ["members:view-members"]);
|
|
294
|
+
});
|