Separate dashboard functions from grouped administration operations
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -25,6 +25,9 @@ final class EditorialDashboardBuildTest extends TestCase
|
||||
$actor = User::factory()->create();
|
||||
config(['portal.managers' => [$actor->email]]);
|
||||
$this->actingAsWithMfa($actor);
|
||||
$nativeKey = 'resources/js/pages/dashboard.tsx';
|
||||
$this->assertArrayHasKey($nativeKey, $manifest);
|
||||
$this->get('/dashboard', ['Accept' => 'text/html'])->assertOk()->assertSee($manifest[$nativeKey]['file'], false);
|
||||
foreach (['/management/editorial', '/management/editorial?kind=legislation'] as $url) {
|
||||
$this->get($url, ['Accept' => 'text/html'])->assertOk()->assertSee('data-page=', false)->assertSee($manifest[$key]['file'], false);
|
||||
}
|
||||
|
||||
@@ -39,13 +39,17 @@ final class EditorialNativeNoticeTest extends TestCase
|
||||
{
|
||||
$service = app(ContentManagement::class);
|
||||
$items = $service->dashboardNavigation($this->author, $service->access($this->author));
|
||||
$this->assertSame(['label' => 'Visão geral', 'href' => '/management/editorial'], $items[0]);
|
||||
$this->assertContains('/management/clusters', array_column($items, 'href'));
|
||||
$this->assertSame(['label' => 'Visão geral', 'href' => '/dashboard'], $items[0]);
|
||||
$this->assertNotContains('/management/clusters', array_column($items, 'href'));
|
||||
$this->assertContains('/management/clusters', array_column($service->administrationNavigation($this->author, $service->access($this->author)), 'href'));
|
||||
$this->assertContains('/dashboard#manifestacoes', array_column($items, 'href'));
|
||||
$outsider = User::factory()->create();
|
||||
$this->assertSame([], $service->dashboardNavigation($outsider, []));
|
||||
$this->assertSame([], $service->dashboardNavigation(null, []));
|
||||
config(['editorial_workflow.enabled' => false]);
|
||||
$this->assertSame([], $service->dashboardNavigation($this->author, $service->access($this->author)));
|
||||
$after = array_column($service->dashboardNavigation($this->author, $service->access($this->author)), 'href');
|
||||
$this->assertContains('/dashboard', $after);
|
||||
$this->assertNotContains('/management/editorial', $after);
|
||||
}
|
||||
|
||||
public function test_cluster_events_use_the_common_inbox_and_recheck_current_scope_and_event_integrity(): void
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import {createRequire} from 'node:module';
|
||||
import React from 'react';
|
||||
import {renderToStaticMarkup} from 'react-dom/server';
|
||||
import ts from 'typescript';
|
||||
const require=createRequire(import.meta.url),module={exports:{}};
|
||||
const code=ts.transpileModule(fs.readFileSync(new URL('../../resources/js/pages/dashboard.tsx',import.meta.url),'utf8'),{compilerOptions:{module:ts.ModuleKind.CommonJS,jsx:ts.JsxEmit.ReactJSX}}).outputText;
|
||||
new Function('require','module','exports',code)(name=>name==='@inertiajs/react'?{Head:()=>null,Link:({children,href,...props})=>React.createElement('a',{href,...props},children)}:name==='react/jsx-runtime'?require(name):name==='@/routes'?{dashboard:()=>'/dashboard'}:{default:()=>null},module,module.exports);
|
||||
test('each manager dashboard menu anchor resolves to a real section',()=>{
|
||||
const html=renderToStaticMarkup(React.createElement(module.exports.default,{summary:{requestsByStatus:{},publishedOpportunities:0,draftOpportunities:0,activeSectors:0,recentRequests:[]},workQueue:null}));
|
||||
for(const id of ['meu-trabalho','manifestacoes','indicadores-oportunidades','pedidos-recentes','accoes-rapidas'])assert.match(html,new RegExp('id="'+id+'"'));
|
||||
assert.match(html,/Painel do portal/);
|
||||
});
|
||||
test('investor section remains distinct from administrative summary',()=>{
|
||||
const html=renderToStaticMarkup(React.createElement(module.exports.default,{summary:null,investorPath:{contexts:[],current:null}}));
|
||||
assert.match(html,/id="meus-investimentos"/);assert.doesNotMatch(html,/id="manifestacoes"/);
|
||||
});
|
||||
@@ -110,7 +110,7 @@ void test('sidebar renders every nested authorised destination instead of a firs
|
||||
'/management/economic-references/lot-01',
|
||||
])
|
||||
assert.ok(hrefs.includes(href), href);
|
||||
assert.match(html, /Área de trabalho/);
|
||||
assert.match(html, /Administração/);
|
||||
});
|
||||
void test('nested current destination is selected without changing its URL or replacing it with a group root', () => {
|
||||
const { html } = render(
|
||||
|
||||
@@ -226,8 +226,8 @@ void test('work area exposes existing content capability even when the old dashb
|
||||
},
|
||||
},
|
||||
});
|
||||
const work = groups.find((g) => g.id === 'work');
|
||||
assert.equal(work.label, 'Área de trabalho');
|
||||
const work = groups.find((g) => g.id === 'administration').children.find(g => g.id === 'administration-content');
|
||||
assert.equal(work.label, 'Conteúdos e oportunidades');
|
||||
assert.ok(
|
||||
work.children.some(
|
||||
(i) =>
|
||||
@@ -314,7 +314,7 @@ void test('direct analysis and ordinary creation preserve distinct selection sta
|
||||
groups,
|
||||
'/minhas-oportunidades/create?analysis=proactive',
|
||||
),
|
||||
'work',
|
||||
'administration',
|
||||
);
|
||||
assert.equal(
|
||||
currentNavigationItem(
|
||||
@@ -450,15 +450,28 @@ void test('installed concours has its own primary group and preserves public and
|
||||
});
|
||||
|
||||
void test('administration owns dashboard activities once and remains hidden without authorised destinations', () => {
|
||||
const dashboardNavigation = [{label: 'Visão geral', href: '/management/editorial'}, {label: 'Legislação', href: '/management/editorial?kind=legislation'}, {label: 'Competitividade', href: '/management/clusters'}];
|
||||
const groups = portalNavigation({authenticated: true, manager: true, dashboardNavigation});
|
||||
const dashboardNavigation = [{label: 'Visão geral', href: '/dashboard'}, {label: 'O meu trabalho', href: '/dashboard#meu-trabalho'}, {label: 'Circuito editorial', href: '/management/editorial'}];
|
||||
const groups = portalNavigation({authenticated: true, manager: true, dashboardNavigation, administrationNavigation: [{label:'Competitividade',href:'/management/clusters'}]});
|
||||
const admin = groups.find(g => g.id === 'administration');
|
||||
const dashboard = admin.children.find(g => g.id === 'collaborative-dashboard');
|
||||
assert.equal(dashboard.label, 'Dashboard');
|
||||
assert.equal(destinations(dashboard.children).includes('/management/clusters'), false);
|
||||
assert.equal(currentNavigationItem(groups, '/dashboard#meu-trabalho'), 'dashboard-activity-1');
|
||||
assert.deepEqual(destinations(dashboard.children), dashboardNavigation.map(i => i.href));
|
||||
assert.equal(currentNavigationGroup(groups, '/management/editorial?kind=legislation'), 'administration');
|
||||
assert.equal(currentNavigationGroup(groups, '/management/editorial'), 'administration');
|
||||
assert.equal(currentNavigationGroup(groups, '/management/clusters/synthetic/edit'), 'administration');
|
||||
assert.equal(destinations(groups).filter(h => h === '/management/clusters').length, 1);
|
||||
assert.equal(portalNavigation({authenticated: false, manager: false, dashboardNavigation}).some(g => g.id === 'administration'), false);
|
||||
assert.equal(portalNavigation({authenticated: true, manager: false}).some(g => g.id === 'administration'), false);
|
||||
});
|
||||
|
||||
void test('administrative operations are grouped outside Dashboard and removed from More/work', () => {
|
||||
const groups=portalNavigation({authenticated:true,manager:true,contentManagementHref:'/gestao-conteudos',dashboardNavigation:[{label:'Visão geral',href:'/dashboard'},{label:'O meu trabalho',href:'/dashboard#meu-trabalho'}],administrationNavigation:[{label:'Demografia',href:'/management/demography'}],profileAccess:{contexts:[],request:'/perfil/promotor',administration:'/perfis/gestao',audit:'/perfis/auditoria'},scopedAdministration:[{label:'Atribuições do Balcão',href:'/management/balcao/atribuicoes'}]});
|
||||
const admin=groups.find(g=>g.id==='administration');
|
||||
assert.deepEqual(admin.children.map(g=>g.label),['Dashboard','Conteúdos e oportunidades','Cadastros e investimento','Pedidos e acompanhamento','Acessos e configuração']);
|
||||
assert.deepEqual(destinations(admin.children.find(g=>g.label==='Dashboard').children),['/dashboard','/dashboard#meu-trabalho']);
|
||||
for(const href of ['/management/projects','/management/demography','/perfis/gestao','/perfis/auditoria','/management/balcao/atribuicoes']) {
|
||||
assert.equal(destinations(admin.children).filter(h=>h===href).length,1,href);
|
||||
assert.equal(destinations(groups.filter(g=>g.id!=='administration')).includes(href),false,href);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user