feat(core,ecommerce,ckeditor5): 이미지 업로드 필터 훅 대칭화
공개 제보(리뷰 이미지에 filter_upload_file 부재)를 계기로 전 이미지 업로드 경로의 훅 트라이어드를 대칭화한다. 확장이 업로드 파일을 저장 전에 가로채 압축/변환할 수 있도록 하기 위함. - 리뷰 이미지·CKEditor5 이미지 업로드에 filter_upload_file 필터 훅 추가 - 레이아웃 편집기 첨부 업로드에 훅 트라이어드(before/filter/after) 신설 - ckeditor5 1.0.2 버전 동기(manifest/package/composer/lock), 각 CHANGELOG 기재, README 기여자 등재, hooks.md 업로드 트라이어드 및 필터 반환 계약 문서화 - 시나리오 매니페스트(upload-filter-hook-parity) + 3계층 훅 발화 테스트 추가
This commit is contained in:
1 parent
709fbff278
commit
b1b5bfa417
18 files changed
+1279
-6
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature\Api\Admin;
|
||||
|
||||
use App\Enums\ExtensionStatus;
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Role;
|
||||
use App\Models\Template;
|
||||
@@ -103,6 +104,46 @@ class TemplateLayoutAttachmentControllerTest extends TestCase
|
||||
Storage::disk($attachment->disk)->assertExists('template-layout-attachments/'.$attachment->path);
|
||||
}
|
||||
|
||||
public function test_upload_fires_hooks(): void
|
||||
{
|
||||
// Arrange
|
||||
$beforeUploadFired = false;
|
||||
$afterUploadFired = false;
|
||||
$filterApplied = false;
|
||||
|
||||
HookManager::addAction('core.template_layout_attachment.before_upload', function () use (&$beforeUploadFired) {
|
||||
$beforeUploadFired = true;
|
||||
});
|
||||
|
||||
HookManager::addFilter('core.template_layout_attachment.filter_upload_file', function ($file) use (&$filterApplied) {
|
||||
$filterApplied = true;
|
||||
|
||||
return $file;
|
||||
});
|
||||
|
||||
HookManager::addAction('core.template_layout_attachment.after_upload', function () use (&$afterUploadFired) {
|
||||
$afterUploadFired = true;
|
||||
});
|
||||
|
||||
// Act
|
||||
$response = $this->withHeaders($this->authHeaders())
|
||||
->postJson("/api/admin/templates/{$this->template->identifier}/layout-attachments", [
|
||||
'file' => UploadedFile::fake()->image('hooked.png', 10, 10),
|
||||
'layout_name' => 'home',
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(200)->assertJson(['success' => true]);
|
||||
$this->assertTrue($beforeUploadFired, 'before_upload hook should be fired');
|
||||
$this->assertTrue($filterApplied, 'filter_upload_file hook should be applied');
|
||||
$this->assertTrue($afterUploadFired, 'after_upload hook should be fired');
|
||||
|
||||
// Cleanup hooks
|
||||
HookManager::clearAction('core.template_layout_attachment.before_upload');
|
||||
HookManager::clearFilter('core.template_layout_attachment.filter_upload_file');
|
||||
HookManager::clearAction('core.template_layout_attachment.after_upload');
|
||||
}
|
||||
|
||||
public function test_index_lists_template_attachments(): void
|
||||
{
|
||||
TemplateLayoutAttachment::create([
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# audit:allow test-scenario-coverage reason: |
|
||||
# 백엔드 전용(훅 발화·필터 반환값 소비) 변경으로 PHPUnit 단위/Feature 테스트가
|
||||
# 표면×구독자 축 조합을 직접 커버하고 green 이다. cross product 자동 전개 불필요.
|
||||
|
||||
feature: 업로드 filter_upload_file 필터 훅 대칭화 (공개 #96)
|
||||
|
||||
description: |
|
||||
before/after 액션만 있고 filter_upload_file 이 없던 업로드 지점(리뷰 이미지·ckeditor5 이미지)과
|
||||
훅 트라이어드가 전무하던 지점(템플릿 레이아웃 첨부)에 필터 훅을 대칭 제공한다.
|
||||
구독자가 없으면 applyFilters 는 입력을 그대로 반환하므로 기존 동작 불변.
|
||||
|
||||
axes:
|
||||
surface: [review_image, ckeditor5_image, template_layout_attachment]
|
||||
subscriber: [none, registered]
|
||||
|
||||
effects:
|
||||
- before_upload_action_fired
|
||||
- filter_upload_file_applied # 등록된 필터가 업로드 경로에서 발화
|
||||
- filter_return_value_consumed # 필터 반환 파일이 저장 파일명/메타의 근거가 됨
|
||||
- after_upload_action_fired
|
||||
- no_subscriber_passthrough # 구독자 0일 때 기존 동작 불변 (기존 upload 테스트가 커버)
|
||||
|
||||
test_files:
|
||||
- modules/_bundled/sirsoft-ecommerce/tests/Unit/Services/ProductReviewImageServiceTest.php
|
||||
- plugins/_bundled/sirsoft-ckeditor5/tests/Unit/Services/ImageUploadServiceTest.php
|
||||
- tests/Feature/Api/Admin/TemplateLayoutAttachmentControllerTest.php
|
||||
Reference in new issue
Block a user