fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -153,46 +153,175 @@ void test('catalogue detail and return preserve the search inside the local cata
|
||||
);
|
||||
});
|
||||
|
||||
const destinations=(items)=>items.flatMap(item=>[...(item.href?[item.href]:[]),...destinations(item.children??[])]);
|
||||
void test('both menu consumers respect the existing scoped server decision rather than generic manager status',()=>{
|
||||
assert.equal(canShowLegacyManagement({user:{id:1},canManagePortal:true,legacyManagementAccess:false}),false);
|
||||
assert.equal(canShowLegacyManagement({user:{id:1},canManagePortal:true,legacyManagementAccess:true}),true);
|
||||
assert.equal(canShowLegacyManagement({user:null,canManagePortal:true,legacyManagementAccess:true}),false);
|
||||
assert.equal(canShowLegacyManagement({user:{id:1},canManagePortal:true}),true);
|
||||
const destinations = (items) =>
|
||||
items.flatMap((item) => [
|
||||
...(item.href ? [item.href] : []),
|
||||
...destinations(item.children ?? []),
|
||||
]);
|
||||
void test('both menu consumers respect the existing scoped server decision rather than generic manager status', () => {
|
||||
assert.equal(
|
||||
canShowLegacyManagement({
|
||||
user: { id: 1 },
|
||||
canManagePortal: true,
|
||||
legacyManagementAccess: false,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
canShowLegacyManagement({
|
||||
user: { id: 1 },
|
||||
canManagePortal: true,
|
||||
legacyManagementAccess: true,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
canShowLegacyManagement({
|
||||
user: null,
|
||||
canManagePortal: true,
|
||||
legacyManagementAccess: true,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
canShowLegacyManagement({ user: { id: 1 }, canManagePortal: true }),
|
||||
true,
|
||||
);
|
||||
});
|
||||
void test('work entry is discoverable without exposing private capabilities to an anonymous visitor',()=>{
|
||||
const groups=portalNavigation({authenticated:false,manager:true,contentManagementHref:'/gestao-conteudos',contentManagementAccess:{opportunities:{index:'/management/opportunities',create:'/management/opportunities/create'}},scopedAdministration:[{label:'Private QA administration',href:'/management/secret'}]});
|
||||
assert.deepEqual(destinations(groups.find(g=>g.id==='work').children),['/acesso-gestao']);
|
||||
assert.equal(JSON.stringify(groups).includes('/management/'),false);
|
||||
assert.equal(JSON.stringify(groups).includes('/gestao-conteudos'),false);
|
||||
void test('work entry is discoverable without exposing private capabilities to an anonymous visitor', () => {
|
||||
const groups = portalNavigation({
|
||||
authenticated: false,
|
||||
manager: true,
|
||||
contentManagementHref: '/gestao-conteudos',
|
||||
contentManagementAccess: {
|
||||
opportunities: {
|
||||
index: '/management/opportunities',
|
||||
create: '/management/opportunities/create',
|
||||
},
|
||||
},
|
||||
scopedAdministration: [
|
||||
{ label: 'Private QA administration', href: '/management/secret' },
|
||||
],
|
||||
});
|
||||
assert.deepEqual(
|
||||
destinations(groups.find((g) => g.id === 'work').children),
|
||||
['/acesso-gestao'],
|
||||
);
|
||||
assert.equal(JSON.stringify(groups).includes('/management/'), false);
|
||||
assert.equal(JSON.stringify(groups).includes('/gestao-conteudos'), false);
|
||||
});
|
||||
void test('work area exposes existing content capability even when the old dashboard flag has no menu object',()=>{
|
||||
const groups=portalNavigation({authenticated:true,manager:true,opportunityManagement:null,contentManagementHref:'/gestao-conteudos',contentManagementAccess:{opportunities:{index:'/management/opportunities',create:'/management/opportunities/create'}}});
|
||||
const work=groups.find(g=>g.id==='work');
|
||||
assert.equal(work.label,'Área de trabalho');
|
||||
assert.ok(work.children.some(i=>i.label==='Preparar análise e ideia'&&i.href==='/management/opportunities/create?analysis=proactive'));
|
||||
assert.ok(work.children.some(i=>i.href==='/gestao-conteudos'));
|
||||
assert.ok(work.children.some(i=>i.href==='/management/opportunities'));
|
||||
void test('work area exposes existing content capability even when the old dashboard flag has no menu object', () => {
|
||||
const groups = portalNavigation({
|
||||
authenticated: true,
|
||||
manager: true,
|
||||
opportunityManagement: null,
|
||||
contentManagementHref: '/gestao-conteudos',
|
||||
contentManagementAccess: {
|
||||
opportunities: {
|
||||
index: '/management/opportunities',
|
||||
create: '/management/opportunities/create',
|
||||
},
|
||||
},
|
||||
});
|
||||
const work = groups.find((g) => g.id === 'work');
|
||||
assert.equal(work.label, 'Área de trabalho');
|
||||
assert.ok(
|
||||
work.children.some(
|
||||
(i) =>
|
||||
i.label === 'Preparar análise e ideia' &&
|
||||
i.href ===
|
||||
'/management/opportunities/create?analysis=proactive',
|
||||
),
|
||||
);
|
||||
assert.ok(work.children.some((i) => i.href === '/gestao-conteudos'));
|
||||
assert.ok(
|
||||
work.children.some((i) => i.href === '/management/opportunities'),
|
||||
);
|
||||
});
|
||||
void test('every previously authorised management/profile destination survives the regrouping exactly once',()=>{
|
||||
const access={authenticated:true,manager:true,businesses:true,education:true,ai:true,contentManagementHref:'/gestao-conteudos',profileAccess:{contexts:[],mine:'/minhas-oportunidades',create:'/minhas-oportunidades/create',request:'/perfil/promotor',review:null,audit:'/perfis/auditoria',administration:'/perfis/gestao'},scopedAdministration:[{label:'Referências económicas',href:'/management/economic-references/lot-01'}]};
|
||||
const old=destinations(legacyPortalNavigation(access).filter(g=>['management','profile-opportunities'].includes(g.id)));
|
||||
const groups=portalNavigation(access);const after=destinations(groups);
|
||||
for(const href of old)assert.equal(after.filter(x=>x===href).length,1,href);
|
||||
assert.equal(after.length,new Set(after).size);
|
||||
assert.ok(destinations(groups.find(g=>g.id==='work').children).includes('/management/economic-references/lot-01'));
|
||||
assert.equal(after.filter(href=>href==='/management/profile-install').length,1,'profile installation already present in the old authorised sidebar must survive');
|
||||
void test('every previously authorised management/profile destination survives the regrouping exactly once', () => {
|
||||
const access = {
|
||||
authenticated: true,
|
||||
manager: true,
|
||||
businesses: true,
|
||||
education: true,
|
||||
ai: true,
|
||||
contentManagementHref: '/gestao-conteudos',
|
||||
profileAccess: {
|
||||
contexts: [],
|
||||
mine: '/minhas-oportunidades',
|
||||
create: '/minhas-oportunidades/create',
|
||||
request: '/perfil/promotor',
|
||||
review: null,
|
||||
audit: '/perfis/auditoria',
|
||||
administration: '/perfis/gestao',
|
||||
},
|
||||
scopedAdministration: [
|
||||
{
|
||||
label: 'Referências económicas',
|
||||
href: '/management/economic-references/lot-01',
|
||||
},
|
||||
],
|
||||
};
|
||||
const old = destinations(
|
||||
legacyPortalNavigation(access).filter((g) =>
|
||||
['management', 'profile-opportunities'].includes(g.id),
|
||||
),
|
||||
);
|
||||
const groups = portalNavigation(access);
|
||||
const after = destinations(groups);
|
||||
for (const href of old)
|
||||
assert.equal(after.filter((x) => x === href).length, 1, href);
|
||||
assert.equal(after.length, new Set(after).size);
|
||||
assert.ok(
|
||||
destinations(groups.find((g) => g.id === 'work').children).includes(
|
||||
'/management/economic-references/lot-01',
|
||||
),
|
||||
);
|
||||
assert.equal(
|
||||
after.filter((href) => href === '/management/profile-install').length,
|
||||
1,
|
||||
'profile installation already present in the old authorised sidebar must survive',
|
||||
);
|
||||
});
|
||||
void test('ordinary authenticated account has an explanation entry and does not acquire creation or management links',()=>{
|
||||
const groups=portalNavigation({authenticated:true,manager:false});
|
||||
assert.deepEqual(destinations(groups.find(g=>g.id==='work').children),['/acesso-gestao']);
|
||||
assert.equal(JSON.stringify(groups).includes('analysis=proactive'),false);
|
||||
assert.equal(JSON.stringify(groups).includes('/management/'),false);
|
||||
void test('ordinary authenticated account has an explanation entry and does not acquire creation or management links', () => {
|
||||
const groups = portalNavigation({ authenticated: true, manager: false });
|
||||
assert.deepEqual(
|
||||
destinations(groups.find((g) => g.id === 'work').children),
|
||||
['/acesso-gestao'],
|
||||
);
|
||||
assert.equal(JSON.stringify(groups).includes('analysis=proactive'), false);
|
||||
assert.equal(JSON.stringify(groups).includes('/management/'), false);
|
||||
});
|
||||
void test('direct analysis and ordinary creation preserve distinct selection state in the same work group',()=>{
|
||||
const access={authenticated:true,manager:false,profileAccess:{contexts:[],mine:'/minhas-oportunidades',create:'/minhas-oportunidades/create',request:'/perfil/promotor',review:null,administration:null}};
|
||||
const groups=portalNavigation(access);
|
||||
assert.equal(currentNavigationGroup(groups,'/minhas-oportunidades/create?analysis=proactive'),'work');
|
||||
assert.equal(currentNavigationItem(groups,'/minhas-oportunidades/create?analysis=proactive'),'prepare-analysis');
|
||||
assert.equal(currentNavigationItem(groups,'/minhas-oportunidades/create'),'new-my-opportunity');
|
||||
void test('direct analysis and ordinary creation preserve distinct selection state in the same work group', () => {
|
||||
const access = {
|
||||
authenticated: true,
|
||||
manager: false,
|
||||
profileAccess: {
|
||||
contexts: [],
|
||||
mine: '/minhas-oportunidades',
|
||||
create: '/minhas-oportunidades/create',
|
||||
request: '/perfil/promotor',
|
||||
review: null,
|
||||
administration: null,
|
||||
},
|
||||
};
|
||||
const groups = portalNavigation(access);
|
||||
assert.equal(
|
||||
currentNavigationGroup(
|
||||
groups,
|
||||
'/minhas-oportunidades/create?analysis=proactive',
|
||||
),
|
||||
'work',
|
||||
);
|
||||
assert.equal(
|
||||
currentNavigationItem(
|
||||
groups,
|
||||
'/minhas-oportunidades/create?analysis=proactive',
|
||||
),
|
||||
'prepare-analysis',
|
||||
);
|
||||
assert.equal(
|
||||
currentNavigationItem(groups, '/minhas-oportunidades/create'),
|
||||
'new-my-opportunity',
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user