mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
feat: let the record's module map filter its own navigation
The other half of the switched-payload change, found by the integration test that asserted the door was gone and got the door. `isNavDestinationVisible` short-circuited on `sharedRecord`, so a switched session skipped the module filter entirely and every destination the grant's scope allowed was offered. That was right while the map was the actor's: a delegate's own preferences must not hide a domain the record granted. The map is the record's now, so the objection is gone and the line is what makes a guardian's toggle visible inside the profile it was set for. Scope decides which doors the grant opens; the map decides which of them the record uses at all. The read-only profile summary needs its marker checked against `!sharedRecord` rather than reached through the removed short-circuit, and the case that pinned the old reading is turned round with the reason written out. Refs #939
This commit is contained in:
1 parent
bed2ab568e
commit
ccca056f64
3 files changed
+75
-16
No files matched your search
@@ -88,19 +88,43 @@ describe("shared-record navigation", () => {
|
||||
).toEqual(["/checkups"]);
|
||||
});
|
||||
|
||||
it("uses the active record scope instead of the actor's module flags", () => {
|
||||
const actorModules = {
|
||||
medications: false,
|
||||
labs: false,
|
||||
mood: false,
|
||||
mentalHealth: false,
|
||||
cycle: false,
|
||||
illness: false,
|
||||
inboundDocuments: false,
|
||||
};
|
||||
/**
|
||||
* Scope and modules are two filters and they answer different questions.
|
||||
*
|
||||
* This case used to assert that the module map was IGNORED inside a shared
|
||||
* record, and the reason was sound at the time: the map `GET /api/auth/me`
|
||||
* published was the ACTOR's, which describes their own dashboard, so letting
|
||||
* it hide a domain the record had granted would have been the actor's
|
||||
* preference deciding somebody else's navigation.
|
||||
*
|
||||
* v1.38.14 (#939) removed the premise rather than the filter. The payload
|
||||
* now resolves the map for the RECORD the session is inside, so the map is
|
||||
* the record's own answer to "what does this record track" — and honouring
|
||||
* it is what makes a guardian's Modules toggle visible inside the profile it
|
||||
* was set for. The scope still decides which doors the grant opens; the map
|
||||
* decides which of them the record uses at all.
|
||||
*/
|
||||
it("applies the record's own module map on top of its scope", () => {
|
||||
const scope = ["medications", "labs"] as const;
|
||||
|
||||
expect(
|
||||
visibleNavDestinations(actorModules, true, true, ["medications"]).map(
|
||||
visibleNavDestinations({}, true, true, [...scope]).map(
|
||||
(destination) => destination.href,
|
||||
),
|
||||
).toEqual(["/medications", "/labs"]);
|
||||
|
||||
// The record tracks medications and not labs. Both are in scope; one door
|
||||
// is offered.
|
||||
expect(
|
||||
visibleNavDestinations({ labs: false }, true, true, [...scope]).map(
|
||||
(destination) => destination.href,
|
||||
),
|
||||
).toEqual(["/medications"]);
|
||||
|
||||
// And the scope still binds: a module the record tracks is not a door the
|
||||
// grant opens.
|
||||
expect(
|
||||
visibleNavDestinations({}, true, true, ["medications"]).map(
|
||||
(destination) => destination.href,
|
||||
),
|
||||
).toEqual(["/medications"]);
|
||||
|
||||
Reference in new issue
Block a user