markTestSkipped('Core template engine not built. Run npm run build to generate build files.'); } // sirsoft-admin_basic 템플릿 설치 및 활성화 $templateService = app(TemplateService::class); try { // 템플릿 설치 $templateService->installTemplate('sirsoft-admin_basic'); // 설치된 템플릿 조회 $template = Template::where('identifier', 'sirsoft-admin_basic')->first(); // 템플릿 활성화 if ($template) { $templateService->activateTemplate($template->id); } } catch (\Exception $e) { // 템플릿이 이미 설치되어 있거나 설치 실패 시 무시 // 테스트는 계속 진행됨 } } /** * 활성화된 템플릿이 있을 때 템플릿 번들이 로드되는지 테스트 */ public function test_admin_blade_loads_template_bundles_when_active_template_exists(): void { // Arrange: setUp()에서 이미 sirsoft-admin_basic가 설치 및 활성화됨 // 추가 템플릿 생성 불필요 // Act: admin view 렌더링 $response = $this->get('/admin'); // Assert: 템플릿 번들 로딩 확인 $response->assertStatus(200); // CSS 번들 로드 확인 (API를 통한 에셋 서빙) $response->assertSee('/api/templates/assets/sirsoft-admin_basic/css/components.css?v=', false); // JS 번들 로드 확인 (API를 통한 에셋 서빙) $response->assertSee('/api/templates/assets/sirsoft-admin_basic/js/components.iife.js?v=', false); // 코어 렌더링 엔진 로드 확인 $response->assertSee('/build/core/template-engine.min.js?v=', false); // data-template-id 속성 확인 $response->assertSee('data-template-id="sirsoft-admin_basic"', false); // 템플릿 엔진 초기화 스크립트 확인 $response->assertSee("templateId: 'sirsoft-admin_basic'", false); } /** * 활성화된 템플릿이 없을 때 기본 템플릿 번들이 로드되는지 테스트 */ public function test_admin_blade_loads_default_template_when_no_active_template(): void { // Arrange: 활성화된 템플릿 없음 Template::factory()->create([ 'identifier' => 'inactive-template', 'type' => 'admin', 'status' => 'inactive', ]); // Act: admin view 렌더링 $response = $this->get('/admin'); // Assert: 기본 템플릿 번들 로딩 확인 $response->assertStatus(200); // CSS 번들 로드 확인 (API를 통한 에셋 서빙) $response->assertSee('/api/templates/assets/sirsoft-admin_basic/css/components.css?v=', false); // JS 번들 로드 확인 (API를 통한 에셋 서빙) $response->assertSee('/api/templates/assets/sirsoft-admin_basic/js/components.iife.js?v=', false); // 코어 렌더링 엔진 로드 확인 $response->assertSee('/build/core/template-engine.min.js?v=', false); // data-template-id 속성에 기본값 확인 $response->assertSee('data-template-id="sirsoft-admin_basic"', false); // 템플릿 엔진 초기화 스크립트에 기본값 확인 $response->assertSee("templateId: 'sirsoft-admin_basic'", false); } /** * 템플릿이 전혀 없을 때도 페이지가 정상 렌더링되는지 테스트 * * 활성화된 템플릿이 없으면 Fallback UI가 표시됩니다. * Fallback UI에서는 코어 렌더링 엔진이 로드되지 않습니다. */ public function test_admin_blade_renders_without_any_template(): void { // Arrange: 모든 템플릿 비활성화 Template::query()->update(['status' => ExtensionStatus::Inactive->value]); // Act: admin view 렌더링 $response = $this->get('/admin'); // Assert: 페이지가 정상적으로 렌더링됨 $response->assertStatus(200); // 기본 구조 확인 $response->assertSee('