Separate system accounts and household people, add generation directory and consented member location sharing
This commit is contained in:
+16
-2
@@ -8,15 +8,29 @@ test('API uses current household scope for each new request',async()=>{
|
||||
assert.equal(calls[0].headers['X-Household-Id'],'house-a');assert.equal(calls[1].headers['X-Household-Id'],'house-b');
|
||||
});
|
||||
test('switch destroys old private state before requesting another household',async()=>{
|
||||
const events=[];const c=vm.createContext({state:{familyId:'a'},currentUser:{id:'root'},isPlatformAdmin:()=>true,
|
||||
const events=[];const c=vm.createContext({state:{familyId:'a',households:[{id:'a'},{id:'b'}]},currentUser:{id:'root'},isPlatformAdmin:()=>true,
|
||||
clearPrivateView(){events.push('clear');c.currentUser=null;c.state={};},auth:async()=>{events.push('auth');assert.equal(c.householdScope,'b');assert.equal(c.currentUser.id,'root');}});
|
||||
vm.runInContext(part(homes,'async function switchHousehold(','function openHousehold('),c);await c.switchHousehold('b');
|
||||
assert.deepEqual(events,['clear','auth']);
|
||||
});
|
||||
test('family administrator cannot invoke household switching',async()=>{
|
||||
test('account cannot switch to a household without a grant',async()=>{
|
||||
const c=vm.createContext({state:{familyId:'a'},isPlatformAdmin:()=>false,clearPrivateView:()=>{throw Error('should not switch');}});
|
||||
vm.runInContext(part(homes,'async function switchHousehold(','function openHousehold('),c);await c.switchHousehold('b');
|
||||
});
|
||||
|
||||
test('ordinary account can switch to an explicitly authorized household',async()=>{
|
||||
const events=[];const c=vm.createContext({state:{familyId:'a',households:[{id:'a'},{id:'b'}]},currentUser:{id:'member'},isPlatformAdmin:()=>false,
|
||||
clearPrivateView(){events.push('clear');c.state={};},auth:async()=>{events.push('auth');c.loggedIn=true;c.state={familyId:'b'};}});
|
||||
vm.runInContext(part(homes,'async function switchHousehold(','function openHousehold('),c);
|
||||
assert.equal(await c.switchHousehold('b'),true);assert.deepEqual(events,['clear','auth']);
|
||||
});
|
||||
|
||||
test('leadership selection includes accounts with a separate household grant',()=>{
|
||||
const c=vm.createContext({});vm.runInContext(part(homes,'function leadershipCandidates(','function syncLeadershipSelection('),c);
|
||||
const rows=[{id:'linked',familyId:'a',familyGrants:{b:{role:'member'}},role:'member'},
|
||||
{id:'other',familyId:'a',role:'member'},{id:'disabled',familyId:'b',role:'member',disabled:true}];
|
||||
assert.deepEqual(Array.from(c.leadershipCandidates(rows,'b'),u=>u.id),['linked']);
|
||||
});
|
||||
test('household switch invalidates outstanding API data',async()=>{
|
||||
let finish;const c=vm.createContext({sessionGeneration:0,householdScope:'a',fetch:()=>new Promise(r=>finish=r)});
|
||||
vm.runInContext(part(app,'async function api(','function toast('),c);
|
||||
|
||||
Reference in New Issue
Block a user