@@ -2,23 +2,108 @@ import assert from 'node:assert/strict';
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import { portalNavigation } from '../resources/js/lib/portal-navigation.ts';
|
||||
|
||||
const access = { installed: true, manage: { label: 'Gestão de Oportunidades', href: '/management/opportunities' }, create: { label: 'Nova oportunidade', href: '/management/opportunities/create' }, installationHref: '/management/opportunity-management-install' };
|
||||
const flatten = (items) => items.flatMap(item => [item, ...flatten(item.children ?? [])]);
|
||||
const manager = flatten(portalNavigation({ authenticated: true, manager: true, opportunityManagement: access }));
|
||||
assert.equal(manager.find(item => item.id === 'dashboard').href, '/dashboard');
|
||||
assert.equal(manager.find(item => item.id === 'dossiers').href, '/investidor');
|
||||
assert.equal(manager.filter(item => item.id === 'manage-opportunities').length, 1);
|
||||
assert.equal(manager.find(item => item.id === 'manage-opportunities').label, 'Gestão de Oportunidades');
|
||||
assert.equal(manager.find(item => item.id === 'create-opportunity').label, 'Nova oportunidade');
|
||||
const investor = flatten(portalNavigation({ authenticated: true, manager: false, opportunityManagement: access }));
|
||||
assert.equal(investor.find(item => item.id === 'dashboard').href, '/investidor');
|
||||
assert.equal(investor.some(item => item.id === 'manage-opportunities' || item.id === 'create-opportunity'), false);
|
||||
const disabled = flatten(portalNavigation({ authenticated: true, manager: true }));
|
||||
assert.equal(disabled.find(item => item.id === 'dashboard').href, '/investidor');
|
||||
assert.equal(disabled.find(item => item.id === 'manage-opportunities').label, 'Oportunidades');
|
||||
assert.equal(disabled.some(item => item.id === 'create-opportunity'), false);
|
||||
const pending = flatten(portalNavigation({ authenticated: true, manager: true, opportunityManagement: { ...access, installed: false } }));
|
||||
assert.equal(pending.some(item => item.id === 'create-opportunity'), false);
|
||||
const proof = { captured_at: new Date().toISOString(), manager_dashboard: '/dashboard', private_dossiers_preserved: '/investidor', management_destinations: 2, duplicate_management_items: 0, investor_denied: true, disabled_configuration_compatible: true, missing_installation_not_presented_as_installed: true, browser_visual_observed: false };
|
||||
writeFileSync(new URL('../storage/app/private/investmoz-v2/portal-audit/dashboard-navigation-catalogue-qa.json', import.meta.url), JSON.stringify(proof, null, 2));
|
||||
const access = {
|
||||
installed: true,
|
||||
manage: {
|
||||
label: 'Gestão de Oportunidades',
|
||||
href: '/management/opportunities',
|
||||
},
|
||||
create: {
|
||||
label: 'Nova oportunidade',
|
||||
href: '/management/opportunities/create',
|
||||
},
|
||||
installationHref: '/management/opportunity-management-install',
|
||||
};
|
||||
const flatten = (items) =>
|
||||
items.flatMap((item) => [item, ...flatten(item.children ?? [])]);
|
||||
const manager = flatten(
|
||||
portalNavigation({
|
||||
authenticated: true,
|
||||
manager: true,
|
||||
opportunityManagement: access,
|
||||
}),
|
||||
);
|
||||
assert.equal(
|
||||
manager.find((item) => item.id === 'dashboard').href,
|
||||
'/dashboard',
|
||||
);
|
||||
assert.equal(
|
||||
manager.find((item) => item.id === 'dossiers').href,
|
||||
'/investidor',
|
||||
);
|
||||
assert.equal(
|
||||
manager.filter((item) => item.id === 'manage-opportunities').length,
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
manager.find((item) => item.id === 'manage-opportunities').label,
|
||||
'Gestão de Oportunidades',
|
||||
);
|
||||
assert.equal(
|
||||
manager.find((item) => item.id === 'create-opportunity').label,
|
||||
'Nova oportunidade',
|
||||
);
|
||||
const investor = flatten(
|
||||
portalNavigation({
|
||||
authenticated: true,
|
||||
manager: false,
|
||||
opportunityManagement: access,
|
||||
}),
|
||||
);
|
||||
assert.equal(
|
||||
investor.find((item) => item.id === 'dashboard').href,
|
||||
'/investidor',
|
||||
);
|
||||
assert.equal(
|
||||
investor.some(
|
||||
(item) =>
|
||||
item.id === 'manage-opportunities' ||
|
||||
item.id === 'create-opportunity',
|
||||
),
|
||||
false,
|
||||
);
|
||||
const disabled = flatten(
|
||||
portalNavigation({ authenticated: true, manager: true }),
|
||||
);
|
||||
assert.equal(
|
||||
disabled.find((item) => item.id === 'dashboard').href,
|
||||
'/investidor',
|
||||
);
|
||||
assert.equal(
|
||||
disabled.find((item) => item.id === 'manage-opportunities').label,
|
||||
'Oportunidades',
|
||||
);
|
||||
assert.equal(
|
||||
disabled.some((item) => item.id === 'create-opportunity'),
|
||||
false,
|
||||
);
|
||||
const pending = flatten(
|
||||
portalNavigation({
|
||||
authenticated: true,
|
||||
manager: true,
|
||||
opportunityManagement: { ...access, installed: false },
|
||||
}),
|
||||
);
|
||||
assert.equal(
|
||||
pending.some((item) => item.id === 'create-opportunity'),
|
||||
false,
|
||||
);
|
||||
const proof = {
|
||||
captured_at: new Date().toISOString(),
|
||||
manager_dashboard: '/dashboard',
|
||||
private_dossiers_preserved: '/investidor',
|
||||
management_destinations: 2,
|
||||
duplicate_management_items: 0,
|
||||
investor_denied: true,
|
||||
disabled_configuration_compatible: true,
|
||||
missing_installation_not_presented_as_installed: true,
|
||||
browser_visual_observed: false,
|
||||
};
|
||||
writeFileSync(
|
||||
new URL(
|
||||
'../storage/app/private/investmoz-v2/portal-audit/dashboard-navigation-catalogue-qa.json',
|
||||
import.meta.url,
|
||||
),
|
||||
JSON.stringify(proof, null, 2),
|
||||
);
|
||||
process.stdout.write(JSON.stringify(proof));
|
||||
|
||||
Reference in New Issue
Block a user