@7365admin1/core 3.99.1-staging.381 → 3.99.1-staging.382
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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Regression (prod 2026-09-25, Wing Tai / Winsland House I): the Invite member
|
|
2
|
+
// dialog's own request
|
|
3
|
+
// GET /api/roles?search&page=1&limit=100&type=property_management_agency&org=<org>&site=<site>
|
|
4
|
+
// must answer 200 with the organisation's roles for every way an owner/admin
|
|
5
|
+
// reaches their organisation. Run with: yarn test:e2e
|
|
6
|
+
import { after, before, describe, it } from "node:test";
|
|
7
|
+
import assert from "node:assert/strict";
|
|
8
|
+
import { ObjectId } from "mongodb";
|
|
9
|
+
import { startHarness } from "./harness.mjs";
|
|
10
|
+
|
|
11
|
+
const PASSWORD = "OwnerReach-Passw0rd!";
|
|
12
|
+
const PM = "property_management_agency";
|
|
13
|
+
const CASES = [
|
|
14
|
+
["PM member holding a '*' owner role", "pm-star@e2e.example.com", { type: PM, role: "pmOwner" }],
|
|
15
|
+
["org-console member holding an EMPTY-permission owner role", "org-empty@e2e.example.com", { type: "organization", role: "orgOwnerEmpty" }],
|
|
16
|
+
["member pinned to this site", "pinned@e2e.example.com", { type: PM, role: "pmOwner", pinSite: true }],
|
|
17
|
+
["org creator with no membership row yet", "creator@e2e.example.com", { creator: true }],
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
describe("Invite member role list: owner/admin reach", { concurrency: 1 }, () => {
|
|
21
|
+
let h; const id = {};
|
|
22
|
+
before(async () => { h = await startHarness(); Object.assign(id, await seed(h)); }, { timeout: 300000 });
|
|
23
|
+
after(async () => { if (h) await h.stop(); });
|
|
24
|
+
|
|
25
|
+
for (const [name, email] of CASES) {
|
|
26
|
+
it(`${name}: 200 with the org's roles`, async () => {
|
|
27
|
+
const sid = await h.login(email, PASSWORD);
|
|
28
|
+
const res = await h.api(`/roles?search&page=1&limit=100&type=${PM}&org=${id.org}&site=${id.site}`, { sid });
|
|
29
|
+
assert.equal(res.status, 200, JSON.stringify(res.body));
|
|
30
|
+
const names = res.body.items.map((r) => r.name).sort();
|
|
31
|
+
assert.ok(names.includes("owner"), JSON.stringify(names));
|
|
32
|
+
assert.equal(names.includes("Other site role"), false);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
it("CONTROL: a member of ANOTHER organisation is refused", async () => {
|
|
37
|
+
const sid = await h.login("outsider@e2e.example.com", PASSWORD);
|
|
38
|
+
const res = await h.api(`/roles?search&page=1&limit=100&type=${PM}&org=${id.org}&site=${id.site}`, { sid });
|
|
39
|
+
assert.equal(res.status, 401);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
async function seed(h) {
|
|
44
|
+
const now = new Date().toISOString();
|
|
45
|
+
const org = new ObjectId(), other = new ObjectId(), site = new ObjectId(), site2 = new ObjectId();
|
|
46
|
+
const r = { pmOwner: new ObjectId(), orgOwnerEmpty: new ObjectId(), otherSite: new ObjectId(), otherOrg: new ObjectId() };
|
|
47
|
+
const emails = [...CASES.map((c) => c[1]), "outsider@e2e.example.com"];
|
|
48
|
+
const users = await h.db.collection("users").insertMany(emails.map((email) => ({ email, name: email.split("@")[0], status: "active", createdAt: now })));
|
|
49
|
+
const uid = (e) => users.insertedIds[emails.indexOf(e)];
|
|
50
|
+
await h.db.collection("users").updateMany({ email: { $in: emails } }, { $set: { password: await h.hashPassword(PASSWORD) } });
|
|
51
|
+
await h.db.collection("organizations").insertMany([
|
|
52
|
+
{ _id: org, name: "Wing E2E", email: "wing-org@e2e.example.com", type: "org", nature: PM, status: "active", createdBy: uid("creator@e2e.example.com"), createdAt: now },
|
|
53
|
+
{ _id: other, name: "Other E2E", email: "other-org@e2e.example.com", type: "org", nature: PM, status: "active", createdAt: now },
|
|
54
|
+
]);
|
|
55
|
+
await h.db.collection("sites").insertMany([
|
|
56
|
+
{ _id: site, name: "Winsland E2E I", org, orgId: org, status: "active" },
|
|
57
|
+
{ _id: site2, name: "Winsland E2E II", org, orgId: org, status: "active" },
|
|
58
|
+
]);
|
|
59
|
+
await h.db.collection("roles").insertMany([
|
|
60
|
+
{ _id: r.pmOwner, name: "owner", type: PM, org, site: "", permissions: ["*"], default: true, status: "active" },
|
|
61
|
+
{ _id: r.orgOwnerEmpty, name: "owner", type: "organization", org, site: "", permissions: [], default: true, status: "active" },
|
|
62
|
+
{ _id: r.otherSite, name: "Other site role", type: PM, org, site: site2, permissions: [], status: "active" },
|
|
63
|
+
{ _id: r.otherOrg, name: "owner", type: PM, org: other, site: "", permissions: ["*"], status: "active" },
|
|
64
|
+
]);
|
|
65
|
+
const rows = [];
|
|
66
|
+
for (const [, email, m] of CASES) {
|
|
67
|
+
if (m.creator) continue;
|
|
68
|
+
rows.push({ user: uid(email), org, type: m.type, role: r[m.role], status: "active", ...(m.pinSite ? { siteId: site } : {}) });
|
|
69
|
+
}
|
|
70
|
+
rows.push({ user: uid("outsider@e2e.example.com"), org: other, type: PM, role: r.otherOrg, status: "active" });
|
|
71
|
+
await h.db.collection("members").insertMany(rows);
|
|
72
|
+
return { org, site };
|
|
73
|
+
}
|