Fix authenticated editorial dashboard missing Vite page entry
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-14 12:04:52 +02:00
parent 203c8f9193
commit dd20e74703
12 changed files with 74 additions and 17 deletions
@@ -0,0 +1,32 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use App\Support\IsolatedQaDatabase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Vite;
use Tests\Support\AuthenticatesQaActors;
use Tests\TestCase;
final class EditorialDashboardBuildTest extends TestCase
{
use AuthenticatesQaActors, DatabaseTransactions;
public function test_authenticated_full_html_opens_with_the_real_compiled_dashboard_entry(): void
{
$this->assertTrue(IsolatedQaDatabase::allowsSchemaChanges());
$directory = getenv('EDITORIAL_QA_BUILD_DIRECTORY') ?: 'build';
$manifest = json_decode(file_get_contents(public_path($directory.'/manifest.json')), true, 512, JSON_THROW_ON_ERROR);
$key = 'resources/js/pages/management/editorial-workflow.tsx';
$this->assertArrayHasKey($key, $manifest, 'The authenticated dashboard must be a compiled page entry, not only a shared chunk.');
$this->app->make(Vite::class)->useBuildDirectory($directory)->useHotFile(storage_path('phpunit-no-vite-hot'));
config(['portal.qa_build_directory' => $directory, 'editorial_workflow.enabled' => true, 'portal.profile_access_enabled' => false]);
$actor = User::factory()->create();
config(['portal.managers' => [$actor->email]]);
$this->actingAsWithMfa($actor);
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);
}
}
}
+1 -1
View File
@@ -34,7 +34,7 @@ const Page = load('../../resources/js/pages/structures/competitiveness.tsx', {
PortalApiError: Error,
},
'../management/shared': { button: '', control: '' },
'../management/editorial-workflow': {
'@/lib/editorial-states': {
states: {
draft: 'Rascunho',
approved: 'Aprovado',
@@ -0,0 +1,13 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
test('compiled dashboard remains a resolvable page entry for authenticated full HTML', () => {
const manifestPath=process.env.EDITORIAL_BUILD_MANIFEST || fileURLToPath(new URL('../../public/build/manifest.json',import.meta.url));
const manifest=JSON.parse(fs.readFileSync(manifestPath,'utf8'));
const key='resources/js/pages/management/editorial-workflow.tsx';
assert.ok(manifest[key], 'Dashboard page entry missing; a shared chunk cannot satisfy the server-rendered Vite directive');
assert.equal(manifest[key].isDynamicEntry || manifest[key].isEntry, true);
assert.ok(fs.existsSync(path.join(path.dirname(manifestPath),manifest[key].file)));
});
@@ -7,7 +7,7 @@ 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/management/editorial-workflow.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'?{Link:({href,children,...props})=>React.createElement('a',{href,...props},children),router:{}}:name==='./shared'?{Management:({title,children})=>React.createElement('main',null,React.createElement('h1',null,title),children),Field:({label,children})=>React.createElement('label',null,label,children),button:'',control:''}:require(name),module,module.exports);
new Function('require','module','exports',code)(name=>name==='@/lib/editorial-states'?{states:{}}:name==='@inertiajs/react'?{Link:({href,children,...props})=>React.createElement('a',{href,...props},children),router:{}}:name==='./shared'?{Management:({title,children})=>React.createElement('main',null,React.createElement('h1',null,title),children),Field:({label,children})=>React.createElement('label',null,label,children),button:'',control:''}:require(name),module,module.exports);
const base={items:{data:[],current_page:1,last_page:1},notices:[],resourceAccess:true,opportunitiesUrl:'/opportunities-qa',opportunityPending:2,clustersUrl:'/clusters-qa',nativePending:{clusters:3,territories:0,zones:0},subjectsUrl:'/subjects-qa',territorialUrl:'/territories-qa',demographyUrl:'/demography-qa'};
test('dashboard groups authorised activities once with contextual counts and an empty notification state',()=>{
const html=renderToStaticMarkup(React.createElement(module.exports.default,base));
+1 -1
View File
@@ -49,7 +49,7 @@ new Function('require', 'module', 'exports', code)(
control: '',
button: '',
};
if (name === './editorial-workflow')
if (name === '@/lib/editorial-states')
return {
states: {
draft: 'Rascunho',