36 lines
1.8 KiB
PHP
36 lines
1.8 KiB
PHP
<?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);
|
|
$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);
|
|
}
|
|
}
|
|
}
|