feat(message_bizppurio): 알림 템플릿 편집 통합·검수 의견·관리탭 개선 및 언어팩 번역 보존 결함군 수정
비즈뿌리오 알림톡 UX 개편 후속: - 코어/게시판/이커머스 알림 템플릿 [편집] 모달에 확장 채널 편집 영역 (extension_point 2종 + hidden_template_editor 채널 메타)을 신설하고, 알림톡 템플릿·문자(SMS)·수신자 규칙을 한 창에서 통합 저장하도록 개정 (행 하단은 상태 요약 전용, 승인 여부 2단 배지) - 검수 신청에 검수자 전달 의견(comment) 동봉 — kapi request 로만 전달, 행에는 저장하지 않음 (FormRequest 신설 + API 문서 백필) - 관리 탭 모바일 카드뷰·도구줄 코어 관례 통일, 사이트맵 알림 정의 다국어 라벨 결측 수정 + 코어 정의 라벨 패리티 테스트 신설 언어팩 번역 소실·보존 결함군 (보완 실측 → 커밋 전 점검에서 연쇄 확정, 전부 실패 테스트 선행 후 수정): - [기본값 복원]이 활성 언어팩 번역(ja)을 영구 소실 → 복원 기본값에 시딩과 같은 주입기(SSoT)로 팩 로케일 병합 (notification·identity) - 코어 알림/본인인증 시더의 언어팩 주입 전면 불능 → 주입기가 연관/리스트 양형태 수용 + identity 시더의 config 복합 키 보존 - 실패한 언어팩 업데이트가 active 팩을 installed 로 방치 → 상태 복원 확장 - 병합·제거의 사용자 수정 보존 판정 사문(연관 전제 isset) → dot-path 판정 교정, 팩 주입 저장의 user_overrides 오염 차단(시딩 바인딩), 템플릿 2모델 translatableTrackableFields 선언(beta.4 설계 누락), 같은 프로세스 활성화 시 시더 번역 필터 stale(캡처 인스턴스 캐시) 교정 - 7.0.9 업그레이드 스텝 신설 — 활성 팩 seed 재동기화로 기설치본의 소실 번역 자동 복구 (멱등·운영자 수정 보존·팩별 실패 격리)
This commit is contained in:
1 parent
40f62e79aa
commit
e7fa1b5535
71 files changed
+7155
-8693
No files matched your search
@@ -104,7 +104,10 @@ class AdminIdentityMessageControllerTest extends TestCase
|
||||
|
||||
$template->refresh();
|
||||
$this->assertSame('운영자 제목', $template->subject['ko']);
|
||||
$this->assertContains('subject', $template->user_overrides ?? []);
|
||||
// subject/body 는 translatableTrackableFields — 수정이 dot-path sub-key 단위로
|
||||
// 기록되어야 시더 재실행·언어팩 병합이 수정된 로케일만 보존한다 (#597 교정)
|
||||
$this->assertContains('subject.ko', $template->user_overrides ?? []);
|
||||
$this->assertContains('subject.en', $template->user_overrides ?? []);
|
||||
$this->assertFalse($template->is_default, '운영자 편집 후 is_default 가 false 로 전환되어야 합니다.');
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,10 @@ namespace Tests\Feature\LanguagePack;
|
||||
use App\Enums\LanguagePackScope;
|
||||
use App\Enums\LanguagePackStatus;
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\IdentityMessageDefinition;
|
||||
use App\Models\IdentityMessageTemplate;
|
||||
use App\Models\LanguagePack;
|
||||
use App\Services\IdentityMessageTemplateService;
|
||||
use App\Services\LanguagePack\LanguagePackRegistry;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\File;
|
||||
@@ -39,6 +42,11 @@ class IdentitySeedInjectionTest extends TestCase
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @scenario domain=identity, entry=seeder_filter
|
||||
*
|
||||
* @effects seeder_filter_injects_active_pack_locales
|
||||
*/
|
||||
public function test_apply_filters_injects_ja_translation_when_active_pack_has_seed(): void
|
||||
{
|
||||
File::put($this->packRoot.'/seed/identity_messages.json', json_encode([
|
||||
@@ -111,4 +119,77 @@ class IdentitySeedInjectionTest extends TestCase
|
||||
// 활성 ja 팩 없음 → 입력 그대로 반환
|
||||
$this->assertSame($definitions, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* [기본값 복원] 경로 회귀 — IdentityMessageTemplateService::resetToDefault 는
|
||||
* core.identity.filter_default_message_definitions 필터의 기본값(ko/en)으로
|
||||
* subject/body 를 대체하므로, 언어팩 주입에 참여하지 않으면 팩이 주입해 둔
|
||||
* 로케일(ja)이 복원 시 영구 소실된다 (notification 쪽 실사례의 동형 — #597 보완 실측).
|
||||
*
|
||||
* @scenario domain=identity, entry=reset_default
|
||||
*
|
||||
* @effects identity_reset_default_preserves_lang_pack_locales
|
||||
*/
|
||||
public function test_reset_to_default_preserves_lang_pack_locales(): void
|
||||
{
|
||||
File::put($this->packRoot.'/seed/identity_messages.json', json_encode([
|
||||
'mail.purpose.signup' => [
|
||||
'definition' => ['name' => '会員登録認証', 'description' => ''],
|
||||
'templates' => ['mail' => ['subject' => '[アプリ] 認証コード', 'body' => '<p>{code}</p>']],
|
||||
],
|
||||
]));
|
||||
|
||||
LanguagePack::query()->create([
|
||||
'identifier' => 'test-feature-idv-ja',
|
||||
'vendor' => 'test',
|
||||
'scope' => LanguagePackScope::Core->value,
|
||||
'target_identifier' => null,
|
||||
'locale' => 'ja',
|
||||
'locale_name' => 'Japanese',
|
||||
'locale_native_name' => '日本語',
|
||||
'text_direction' => 'ltr',
|
||||
'version' => '1.0.0',
|
||||
'status' => LanguagePackStatus::Active->value,
|
||||
'is_protected' => false,
|
||||
'manifest' => [],
|
||||
'source_type' => 'zip',
|
||||
]);
|
||||
$this->app->make(LanguagePackRegistry::class)->invalidate();
|
||||
|
||||
// config/core.php 실항목을 그대로 픽스처로 사용 — 복원 매칭(provider/scope) 정합 보장.
|
||||
$cfg = config('core.identity_messages')['mail.purpose.signup'];
|
||||
|
||||
$definition = IdentityMessageDefinition::query()->create([
|
||||
'extension_type' => 'core',
|
||||
'extension_identifier' => 'core',
|
||||
'provider_id' => $cfg['provider_id'],
|
||||
'scope_type' => $cfg['scope_type'],
|
||||
'scope_value' => $cfg['scope_value'],
|
||||
'name' => $cfg['name'],
|
||||
'description' => $cfg['description'] ?? null,
|
||||
'channels' => $cfg['channels'] ?? ['mail'],
|
||||
'variables' => [],
|
||||
'is_active' => true,
|
||||
'is_default' => true,
|
||||
]);
|
||||
|
||||
$template = IdentityMessageTemplate::query()->create([
|
||||
'definition_id' => $definition->id,
|
||||
'channel' => 'mail',
|
||||
'subject' => ['ko' => '운영자가 바꾼 제목'],
|
||||
'body' => ['ko' => '운영자가 바꾼 본문 {code}'],
|
||||
'is_active' => true,
|
||||
'is_default' => false,
|
||||
]);
|
||||
|
||||
$updated = $this->app->make(IdentityMessageTemplateService::class)
|
||||
->resetToDefault($template);
|
||||
|
||||
$this->assertTrue((bool) $updated->is_default, '복원 후 is_default 가 참이어야 한다');
|
||||
$this->assertSame('[アプリ] 認証コード', $updated->subject['ja'] ?? null,
|
||||
'복원 기본값에 활성 팩 seed 의 ja subject 가 병합되어야 한다 — 없으면 복원이 팩 번역을 지운다');
|
||||
$this->assertSame('<p>{code}</p>', $updated->body['ja'] ?? null,
|
||||
'복원 기본값에 활성 팩 seed 의 ja body 가 병합되어야 한다');
|
||||
$this->assertArrayHasKey('ko', $updated->subject, 'ko 는 config 원본에서 보존');
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use App\Enums\LanguagePackStatus;
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\LanguagePack;
|
||||
use App\Services\LanguagePack\LanguagePackRegistry;
|
||||
use App\Services\NotificationTemplateService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Tests\TestCase;
|
||||
@@ -40,6 +41,11 @@ class NotificationSeedInjectionTest extends TestCase
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @scenario domain=notification, entry=seeder_filter
|
||||
*
|
||||
* @effects seeder_filter_injects_active_pack_locales
|
||||
*/
|
||||
public function test_apply_filters_injects_ja_translation_when_active_pack_has_seed(): void
|
||||
{
|
||||
File::put($this->packRoot.'/seed/notifications.json', json_encode([
|
||||
@@ -93,6 +99,114 @@ class NotificationSeedInjectionTest extends TestCase
|
||||
$this->assertSame('Welcome', $result[0]['name']['en']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 실경로 회귀 — 코어 시더(loadConfigSeed)는 config/core.php 원형(연관 배열,
|
||||
* 항목에 type 키 없음)을 그대로 필터에 넘긴다. injector 가 $def['type'] 만 보면
|
||||
* 전 항목이 스킵되어 ja 가 조용히 주입되지 않는다 (2026-08-24 실측 — #597 보완 실측).
|
||||
*
|
||||
* @scenario domain=notification, entry=seeder_filter
|
||||
*
|
||||
* @effects seeder_filter_injects_ja_for_real_seeder_payload
|
||||
*/
|
||||
public function test_apply_filters_injects_ja_for_config_shaped_associative_definitions(): void
|
||||
{
|
||||
File::put($this->packRoot.'/seed/notifications.json', json_encode([
|
||||
'welcome' => [
|
||||
'definition' => ['name' => 'ようこそ通知', 'description' => '新規会員へのウェルカム'],
|
||||
'templates' => ['mail' => ['subject' => 'ようこそ', 'body' => '<p>{user_name}</p>']],
|
||||
],
|
||||
]));
|
||||
|
||||
LanguagePack::query()->create([
|
||||
'identifier' => 'test-feature-notif-ja',
|
||||
'vendor' => 'test',
|
||||
'scope' => LanguagePackScope::Core->value,
|
||||
'target_identifier' => null,
|
||||
'locale' => 'ja',
|
||||
'locale_name' => 'Japanese',
|
||||
'locale_native_name' => '日本語',
|
||||
'text_direction' => 'ltr',
|
||||
'version' => '1.0.0',
|
||||
'status' => LanguagePackStatus::Active->value,
|
||||
'is_protected' => false,
|
||||
'manifest' => [],
|
||||
'source_type' => 'zip',
|
||||
]);
|
||||
$this->app->make(LanguagePackRegistry::class)->invalidate();
|
||||
|
||||
// config/core.php notification_definitions 원형과 동일한 형태 — 키가 곧 type.
|
||||
$definitions = [
|
||||
'welcome' => [
|
||||
'name' => ['ko' => '회원가입 환영', 'en' => 'Welcome'],
|
||||
'description' => ['ko' => '신규 회원 환영', 'en' => 'New member welcome'],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'subject' => ['ko' => '환영합니다', 'en' => 'Welcome'],
|
||||
'body' => ['ko' => '<p>{user_name}</p>', 'en' => '<p>{user_name}</p>'],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$result = HookManager::applyFilters('seed.notifications.translations', $definitions);
|
||||
|
||||
$this->assertSame('ようこそ通知', $result['welcome']['name']['ja'] ?? null,
|
||||
'연관 배열(실제 시더 페이로드) 형태에서 definition name 에 ja 가 병합되어야 한다');
|
||||
$this->assertSame('ようこそ', $result['welcome']['templates'][0]['subject']['ja'] ?? null,
|
||||
'연관 배열 형태에서 템플릿 subject 에 ja 가 병합되어야 한다');
|
||||
// ko/en 보존
|
||||
$this->assertSame('회원가입 환영', $result['welcome']['name']['ko']);
|
||||
}
|
||||
|
||||
/**
|
||||
* [기본값 복원] 경로 회귀 — NotificationTemplateService::getDefaultTemplateData 는
|
||||
* core.notification.filter_default_definitions 필터만 타고 언어팩 주입에는 참여하지
|
||||
* 않아, 복원을 누르면 팩이 주입해 둔 로케일(ja)이 ko/en 대체로 영구 소실됐다
|
||||
* (실사례: 2026-08-23 복원 실측이 welcome ja 를 지움 — #597 보완 실측에서 확정).
|
||||
* 복원 기본값에도 활성 팩 seed 로케일이 병합되어야 한다.
|
||||
*
|
||||
* @scenario domain=notification, entry=reset_default
|
||||
*
|
||||
* @effects reset_default_data_includes_lang_pack_locales
|
||||
*/
|
||||
public function test_reset_default_data_includes_lang_pack_locales(): void
|
||||
{
|
||||
File::put($this->packRoot.'/seed/notifications.json', json_encode([
|
||||
'welcome' => [
|
||||
'definition' => ['name' => 'ようこそ通知', 'description' => '新規会員へのウェルカム'],
|
||||
'templates' => ['mail' => ['subject' => 'ようこそ', 'body' => '<p>{user_name}</p>']],
|
||||
],
|
||||
]));
|
||||
|
||||
LanguagePack::query()->create([
|
||||
'identifier' => 'test-feature-notif-ja',
|
||||
'vendor' => 'test',
|
||||
'scope' => LanguagePackScope::Core->value,
|
||||
'target_identifier' => null,
|
||||
'locale' => 'ja',
|
||||
'locale_name' => 'Japanese',
|
||||
'locale_native_name' => '日本語',
|
||||
'text_direction' => 'ltr',
|
||||
'version' => '1.0.0',
|
||||
'status' => LanguagePackStatus::Active->value,
|
||||
'is_protected' => false,
|
||||
'manifest' => [],
|
||||
'source_type' => 'zip',
|
||||
]);
|
||||
$this->app->make(LanguagePackRegistry::class)->invalidate();
|
||||
|
||||
$defaultData = $this->app->make(NotificationTemplateService::class)
|
||||
->getDefaultTemplateData('welcome', 'mail');
|
||||
|
||||
$this->assertNotEmpty($defaultData, 'config/core.php 의 welcome/mail 기본 템플릿을 찾아야 한다');
|
||||
$this->assertSame('ようこそ', $defaultData['subject']['ja'] ?? null,
|
||||
'[기본값 복원] 기본값에 활성 팩 seed 의 ja subject 가 병합되어야 한다 — 없으면 복원이 팩 번역을 지운다');
|
||||
$this->assertSame('<p>{user_name}</p>', $defaultData['body']['ja'] ?? null,
|
||||
'[기본값 복원] 기본값에 활성 팩 seed 의 ja body 가 병합되어야 한다');
|
||||
$this->assertArrayHasKey('ko', $defaultData['subject'], 'ko 는 config 원본에서 보존');
|
||||
}
|
||||
|
||||
public function test_apply_filters_passthrough_when_no_active_pack(): void
|
||||
{
|
||||
$definitions = [
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Upgrades;
|
||||
|
||||
use App\Enums\LanguagePackScope;
|
||||
use App\Enums\LanguagePackStatus;
|
||||
use App\Extension\UpgradeContext;
|
||||
use App\Models\IdentityMessageDefinition;
|
||||
use App\Models\IdentityMessageTemplate;
|
||||
use App\Models\LanguagePack;
|
||||
use App\Models\NotificationDefinition;
|
||||
use App\Models\NotificationTemplate;
|
||||
use App\Upgrades\Data\V7_0_9\Migrations\ResyncActiveLanguagePackTranslations;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 7.0.9 업그레이드 스텝 — 활성 언어팩 seed 번역 재동기화 백필 검증.
|
||||
*
|
||||
* 7.0.9 이전의 [기본값 복원] 결함·코어 시더 주입 불능으로 소실된 팩 로케일이
|
||||
* 업그레이드 시 병합 복구되는지, 그리고 운영자 수정(user_overrides)은 덮지
|
||||
* 않는지를 실제 활성화 훅 경로(core.language_packs.activated)로 검증한다.
|
||||
*/
|
||||
class Upgrade709LangPackResyncTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private string $packIdentifier = 'test-upgrade-resync-ja';
|
||||
|
||||
private string $packRoot = '';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// upgrade data 파일은 composer autoload 대상이 아니며 AbstractUpgradeStep 이
|
||||
// 실행 시점에 require_once 로 수동 로드한다. 테스트에서도 동일하게 수동 로드.
|
||||
require_once base_path('upgrades/data/7.0.9/migrations/01_ResyncActiveLanguagePackTranslations.php');
|
||||
|
||||
$this->packRoot = base_path('lang-packs/'.$this->packIdentifier);
|
||||
File::ensureDirectoryExists($this->packRoot.'/seed');
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
File::deleteDirectory($this->packRoot);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 활성 팩 행을 생성합니다 (resolveDirectory → lang-packs/{identifier}).
|
||||
*
|
||||
* @return LanguagePack 생성된 팩
|
||||
*/
|
||||
private function createActivePack(): LanguagePack
|
||||
{
|
||||
return LanguagePack::query()->create([
|
||||
'identifier' => $this->packIdentifier,
|
||||
'vendor' => 'test',
|
||||
'scope' => LanguagePackScope::Core->value,
|
||||
'target_identifier' => null,
|
||||
'locale' => 'ja',
|
||||
'locale_name' => 'Japanese',
|
||||
'locale_native_name' => '日本語',
|
||||
'text_direction' => 'ltr',
|
||||
'version' => '1.0.0',
|
||||
'status' => LanguagePackStatus::Active->value,
|
||||
'is_protected' => false,
|
||||
'manifest' => [],
|
||||
'source_type' => 'zip',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 마이그레이션을 업그레이드 컨텍스트로 실행합니다.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function runMigration(): void
|
||||
{
|
||||
(new ResyncActiveLanguagePackTranslations)->run(
|
||||
new UpgradeContext('7.0.8', '7.0.9', '7.0.9')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* [기본값 복원]이 지운 알림 템플릿 ja 가 업그레이드 재동기화로 복구되고,
|
||||
* 운영자가 수정한(user_overrides 등록) 템플릿의 ja 는 덮이지 않는다.
|
||||
*
|
||||
* @scenario domain=notification, entry=upgrade_resync
|
||||
*
|
||||
* @effects upgrade_resync_restores_wiped_pack_locales
|
||||
*/
|
||||
public function test_resync_restores_wiped_notification_locale_and_preserves_overrides(): void
|
||||
{
|
||||
File::put($this->packRoot.'/seed/notifications.json', json_encode([
|
||||
'welcome' => [
|
||||
'definition' => ['name' => 'ようこそ通知'],
|
||||
'templates' => ['mail' => ['subject' => 'ようこそ', 'body' => '<p>{user_name}</p>']],
|
||||
],
|
||||
'password_changed' => [
|
||||
'templates' => ['mail' => ['subject' => 'パスワード変更', 'body' => '<p>{user_name}</p>']],
|
||||
],
|
||||
]));
|
||||
$this->createActivePack();
|
||||
|
||||
// 복원 결함이 ja 를 지운 상태 재현: ko/en 만 남고 user_overrides 는 null.
|
||||
$wipedDef = NotificationDefinition::create([
|
||||
'type' => 'welcome',
|
||||
'hook_prefix' => 'core.auth',
|
||||
'extension_type' => 'core',
|
||||
'extension_identifier' => 'core',
|
||||
'name' => ['ko' => '환영', 'en' => 'Welcome'],
|
||||
'channels' => ['mail'],
|
||||
'hooks' => ['core.auth.after_register'],
|
||||
]);
|
||||
$wiped = NotificationTemplate::create([
|
||||
'definition_id' => $wipedDef->id,
|
||||
'channel' => 'mail',
|
||||
'subject' => ['ko' => '환영합니다', 'en' => 'Welcome'],
|
||||
'body' => ['ko' => '<p>환영</p>', 'en' => '<p>welcome</p>'],
|
||||
'is_active' => true,
|
||||
'is_default' => true,
|
||||
]);
|
||||
|
||||
// 운영자 수정 상태 재현: ja 커스텀 + user_overrides 보존 선언.
|
||||
$customDef = NotificationDefinition::create([
|
||||
'type' => 'password_changed',
|
||||
'hook_prefix' => 'core.auth',
|
||||
'extension_type' => 'core',
|
||||
'extension_identifier' => 'core',
|
||||
'name' => ['ko' => '비밀번호 변경', 'en' => 'Password changed'],
|
||||
'channels' => ['mail'],
|
||||
'hooks' => ['core.auth.after_password_change'],
|
||||
]);
|
||||
$custom = NotificationTemplate::create([
|
||||
'definition_id' => $customDef->id,
|
||||
'channel' => 'mail',
|
||||
'subject' => ['ko' => '커스텀 제목', 'ja' => 'カスタム件名'],
|
||||
'body' => ['ko' => '<p>커스텀</p>', 'ja' => '<p>カスタム</p>'],
|
||||
'is_active' => true,
|
||||
'is_default' => false,
|
||||
]);
|
||||
// 운영자 수정 시 updating 이벤트가 기록하는 실제 형식 = dot-path 리스트 "{column}.{locale}"
|
||||
$custom->user_overrides = ['subject.ja', 'body.ja'];
|
||||
$custom->saveQuietly();
|
||||
|
||||
$this->assertArrayNotHasKey('ja', $wiped->fresh()->subject, '사전 조건: 소실 상태(ja 부재)');
|
||||
|
||||
$this->runMigration();
|
||||
|
||||
$this->assertSame('ようこそ', $wiped->fresh()->subject['ja'] ?? null,
|
||||
'소실된 템플릿 subject 에 활성 팩 seed 의 ja 가 병합 복구되어야 한다');
|
||||
$this->assertSame('ようこそ通知', $wipedDef->fresh()->name['ja'] ?? null,
|
||||
'정의 name 에도 ja 가 병합되어야 한다');
|
||||
$this->assertSame('カスタム件名', $custom->fresh()->subject['ja'] ?? null,
|
||||
'운영자 수정(user_overrides 등록) 템플릿의 ja 는 seed 로 덮이지 않아야 한다');
|
||||
}
|
||||
|
||||
/**
|
||||
* 본인인증 메시지 템플릿의 소실된 ja 도 같은 재동기화로 복구된다.
|
||||
*
|
||||
* @scenario domain=identity, entry=upgrade_resync
|
||||
*
|
||||
* @effects upgrade_resync_restores_wiped_identity_locales
|
||||
*/
|
||||
public function test_resync_restores_wiped_identity_message_locale(): void
|
||||
{
|
||||
File::put($this->packRoot.'/seed/identity_messages.json', json_encode([
|
||||
'mail.purpose.signup' => [
|
||||
'definition' => ['name' => '会員登録認証'],
|
||||
'templates' => ['mail' => ['subject' => '[アプリ] 認証コード', 'body' => '<p>{code}</p>']],
|
||||
],
|
||||
]));
|
||||
$this->createActivePack();
|
||||
|
||||
$cfg = config('core.identity_messages')['mail.purpose.signup'];
|
||||
$definition = IdentityMessageDefinition::query()->create([
|
||||
'extension_type' => 'core',
|
||||
'extension_identifier' => 'core',
|
||||
'provider_id' => $cfg['provider_id'],
|
||||
'scope_type' => $cfg['scope_type'],
|
||||
'scope_value' => $cfg['scope_value'],
|
||||
'name' => ['ko' => '회원가입 인증'],
|
||||
'channels' => ['mail'],
|
||||
'variables' => [],
|
||||
'is_active' => true,
|
||||
'is_default' => true,
|
||||
]);
|
||||
$template = IdentityMessageTemplate::query()->create([
|
||||
'definition_id' => $definition->id,
|
||||
'channel' => 'mail',
|
||||
'subject' => ['ko' => '[앱] 인증 코드'],
|
||||
'body' => ['ko' => '<p>{code}</p>'],
|
||||
'is_active' => true,
|
||||
'is_default' => true,
|
||||
]);
|
||||
|
||||
$this->assertArrayNotHasKey('ja', $template->fresh()->subject, '사전 조건: 소실 상태(ja 부재)');
|
||||
|
||||
$this->runMigration();
|
||||
|
||||
$this->assertSame('[アプリ] 認証コード', $template->fresh()->subject['ja'] ?? null,
|
||||
'소실된 본인인증 템플릿 subject 에 활성 팩 seed 의 ja 가 병합 복구되어야 한다');
|
||||
}
|
||||
}
|
||||
@@ -98,12 +98,15 @@ class SyncDatabaseTranslationsTest extends TestCase
|
||||
public function test_case_b_skips_locale_when_user_overrides_registered(): void
|
||||
{
|
||||
// Permission 은 HasUserOverrides 미사용이므로 Role 로 검증 (Role/Menu/Notification 모두 동일 정책)
|
||||
// user_overrides 는 실제 생산 형식(운영자 수정 시 updating 이벤트가 기록하는
|
||||
// dot-path 리스트 "{column}.{locale}")으로 둔다 — 과거 픽스처는 어떤 생산자도
|
||||
// 쓰지 않는 연관 형식이라 보존 판정 결함(isset 사문)을 green 으로 가렸다.
|
||||
$role = Role::query()->create([
|
||||
'identifier' => 'test_role_b',
|
||||
'name' => ['ko' => '바', 'en' => 'Bar', 'ja' => '사용자수정'],
|
||||
'description' => ['ko' => 'D', 'en' => 'D'],
|
||||
'is_active' => true,
|
||||
'user_overrides' => ['name' => ['updated_at' => now()->toIso8601String()]],
|
||||
'user_overrides' => ['name.ja'],
|
||||
]);
|
||||
|
||||
$pack = $this->setupPackWithPermissionsSeed([
|
||||
@@ -167,12 +170,13 @@ class SyncDatabaseTranslationsTest extends TestCase
|
||||
|
||||
public function test_deactivate_preserves_locale_when_user_overrides_registered(): void
|
||||
{
|
||||
// dot-path 리스트 = 실제 생산 형식 (test_case_b 주석 참조)
|
||||
$role = Role::query()->create([
|
||||
'identifier' => 'test_role_zed',
|
||||
'name' => ['ko' => '제드', 'en' => 'Zed', 'ja' => '사용자수정ja'],
|
||||
'description' => ['ko' => '', 'en' => ''],
|
||||
'is_active' => true,
|
||||
'user_overrides' => ['name' => ['updated_at' => now()->toIso8601String()]],
|
||||
'user_overrides' => ['name.ja'],
|
||||
]);
|
||||
|
||||
$pack = $this->setupPackWithPermissionsSeed([
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Notifications;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 코어 소유 알림 정의 타입 ↔ 관리자 화면 라벨 패리티 (#597 후속, 2026-08-24)
|
||||
*
|
||||
* 관리자 알림 설정 화면의 정의 목록은 제목을 DB `name` 이 아니라 프론트 다국어 키
|
||||
* `admin.settings.notification_definitions.types.{type}` 로 렌더한다. 이 네임스페이스의
|
||||
* 코어 소유분은 admin 템플릿(sirsoft-admin_basic)의 `lang/partial/{ko,en}/admin.json` 이
|
||||
* 공급한다(모듈 소유 타입은 각 모듈의 화면·lang 이 담당).
|
||||
*
|
||||
* 키가 없으면 예외도 경고도 없이 원시 키 문자열이 화면 제목으로 그대로 노출된다
|
||||
* (실사례: sitemap_regenerated / sitemap_regenerate_failed — #481 이 config 정의만 추가하고
|
||||
* 템플릿 라벨을 누락). config/core.php 에 정의를 추가하는 커밋이 라벨을 빠뜨리는 일이
|
||||
* 재발하지 않도록, 코어 정의 전수를 양 로케일 라벨과 대조한다.
|
||||
*
|
||||
* 마커는 로케일별 테스트 메서드 docblock 에 있다 (@scenario 는 docblock 당 1조합).
|
||||
*/
|
||||
class NotificationDefinitionTypeLabelParityTest extends TestCase
|
||||
{
|
||||
/** 코어 소유 타입 라벨을 공급하는 admin 템플릿 lang partial */
|
||||
private const LABEL_FILES = [
|
||||
'ko' => 'templates/_bundled/sirsoft-admin_basic/lang/partial/ko/admin.json',
|
||||
'en' => 'templates/_bundled/sirsoft-admin_basic/lang/partial/en/admin.json',
|
||||
];
|
||||
|
||||
/**
|
||||
* 코어 정의 타입 전수가 ko 라벨을 가진다
|
||||
*
|
||||
* @scenario locale=ko
|
||||
*
|
||||
* @effects core_definition_types_have_admin_template_labels
|
||||
*/
|
||||
public function test_every_core_definition_type_has_ko_label(): void
|
||||
{
|
||||
$this->assertLabelsCoverCoreTypes('ko');
|
||||
}
|
||||
|
||||
/**
|
||||
* 코어 정의 타입 전수가 en 라벨을 가진다
|
||||
*
|
||||
* @scenario locale=en
|
||||
*
|
||||
* @effects core_definition_types_have_admin_template_labels
|
||||
*/
|
||||
public function test_every_core_definition_type_has_en_label(): void
|
||||
{
|
||||
$this->assertLabelsCoverCoreTypes('en');
|
||||
}
|
||||
|
||||
/**
|
||||
* 코어 정의 전수 ↔ 해당 로케일 라벨 대조
|
||||
*
|
||||
* @param string $locale 검사할 로케일 (ko|en)
|
||||
*/
|
||||
private function assertLabelsCoverCoreTypes(string $locale): void
|
||||
{
|
||||
$types = array_keys((array) config('core.notification_definitions'));
|
||||
|
||||
// 모집단 검증 — config 구조가 바뀌어 빈 배열이 되면 초록이 무의미하다.
|
||||
$this->assertGreaterThanOrEqual(
|
||||
5,
|
||||
count($types),
|
||||
'config/core.php notification_definitions 에서 코어 정의를 읽지 못했다 — 테스트 경로/구조 확인 필요'
|
||||
);
|
||||
|
||||
$relPath = self::LABEL_FILES[$locale];
|
||||
$labels = $this->loadTypeLabels($relPath);
|
||||
|
||||
$missing = array_values(array_filter(
|
||||
$types,
|
||||
fn (string $type) => ! array_key_exists($type, $labels)
|
||||
|| ! is_string($labels[$type])
|
||||
|| trim($labels[$type]) === ''
|
||||
));
|
||||
|
||||
$this->assertSame(
|
||||
[],
|
||||
$missing,
|
||||
"admin 템플릿 {$locale} 라벨 누락 — 알림 설정 화면 제목에 원시 키가 그대로 노출된다.\n"
|
||||
."{$relPath} 의 settings.notification_definitions.types 에 다음 타입을 추가할 것:\n"
|
||||
.implode(', ', $missing)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* partial admin.json 에서 타입 라벨 맵을 읽는다
|
||||
*
|
||||
* @param string $relPath 저장소 루트 기준 경로
|
||||
* @return array<string, mixed> 타입 → 라벨
|
||||
*/
|
||||
private function loadTypeLabels(string $relPath): array
|
||||
{
|
||||
$path = base_path($relPath);
|
||||
$this->assertFileExists($path, "라벨 파일이 없다: {$relPath}");
|
||||
|
||||
$data = json_decode((string) file_get_contents($path), true);
|
||||
$this->assertIsArray($data, "라벨 파일 JSON 파싱 실패: {$relPath}");
|
||||
|
||||
$labels = $data['settings']['notification_definitions']['types'] ?? null;
|
||||
$this->assertIsArray(
|
||||
$labels,
|
||||
"settings.notification_definitions.types 경로가 없다: {$relPath} — 파일 구조가 바뀌었으면 본 테스트의 경로를 갱신할 것"
|
||||
);
|
||||
|
||||
return $labels;
|
||||
}
|
||||
}
|
||||
@@ -34,13 +34,40 @@ class LanguagePackServiceTest extends TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/** 실번들 케이스가 삭제하는 실 설치본의 백업 경로 (테스트 종료 시 복원). */
|
||||
private ?string $protectedRealInstallDir = null;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->service = $this->app->make(LanguagePackService::class);
|
||||
|
||||
// 실번들(g7-core-ja) 케이스들은 활성 설치본 디렉토리를 만들고 cleanup 에서 삭제한다.
|
||||
// DB 는 RefreshDatabase 로 격리되지만 파일 시스템은 실 저장소를 공유하므로,
|
||||
// 개발 환경에 이미 설치된 실 설치본이 있으면 백업해 두고 tearDown 에서 복원한다
|
||||
// (미보호 시 실환경 팩이 files_missing 드리프트에 빠진다 — 2026-08-24 실측).
|
||||
$realDir = base_path('lang-packs/g7-core-ja');
|
||||
if (File::isDirectory($realDir)) {
|
||||
$backup = base_path('lang-packs/.test-backup-g7-core-ja');
|
||||
File::deleteDirectory($backup);
|
||||
File::moveDirectory($realDir, $backup);
|
||||
$this->protectedRealInstallDir = $backup;
|
||||
}
|
||||
$this->registry = $this->app->make(LanguagePackRegistry::class);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if ($this->protectedRealInstallDir !== null) {
|
||||
$realDir = base_path('lang-packs/g7-core-ja');
|
||||
File::deleteDirectory($realDir);
|
||||
File::moveDirectory($this->protectedRealInstallDir, $realDir);
|
||||
$this->protectedRealInstallDir = null;
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 테스트 언어팩 1건을 DB 에 직접 생성합니다.
|
||||
*
|
||||
@@ -1085,4 +1112,73 @@ class LanguagePackServiceTest extends TestCase
|
||||
File::deleteDirectory($path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 회귀 가드 — performUpdate 중 설치 트랜잭션이 status 를 installed 로 기록한 뒤
|
||||
* (활성화 단계 이전/도중) 실패하면, catch 의 상태 복원이 Updating 만 보던 탓에
|
||||
* active 였던 팩이 installed 로 방치됐다. 파일은 백업으로 원상 복원되므로
|
||||
* 상태도 이전 상태(active)로 복원되어야 한다 — 방치되면 해당 로케일의 백엔드
|
||||
* 번역이 통째로 폴백되는데 오류도 로그도 없다 (#597 보완 실측에서 유사 상태 실측).
|
||||
*
|
||||
* @scenario vector=update_failure_after_install_transaction, actor_permission=cli_system
|
||||
*
|
||||
* @effects failed_update_restores_previous_active_status
|
||||
*/
|
||||
public function test_failed_update_restores_previous_active_status(): void
|
||||
{
|
||||
$identifier = 'test-update-restore-ja';
|
||||
$bundledDir = base_path('lang-packs/_bundled/'.$identifier);
|
||||
File::ensureDirectoryExists($bundledDir);
|
||||
File::put($bundledDir.'/language-pack.json', json_encode(['identifier' => $identifier]));
|
||||
|
||||
try {
|
||||
$pack = LanguagePack::query()->create([
|
||||
'identifier' => $identifier,
|
||||
'vendor' => 'test',
|
||||
'scope' => LanguagePackScope::Core->value,
|
||||
'target_identifier' => null,
|
||||
'locale' => 'ja',
|
||||
'locale_name' => 'Japanese',
|
||||
'locale_native_name' => '日本語',
|
||||
'text_direction' => 'ltr',
|
||||
'version' => '1.0.0',
|
||||
'status' => LanguagePackStatus::Active->value,
|
||||
'is_protected' => false,
|
||||
'manifest' => [],
|
||||
'source_type' => 'bundled',
|
||||
]);
|
||||
|
||||
// Laravel partialMock 은 생성자를 건너뛰어 readonly 의존성이 미초기화되므로,
|
||||
// 생성자 인자를 컨테이너에서 구성해 넘기는 Mockery partial 을 사용한다.
|
||||
$ctorArgs = array_map(
|
||||
static fn (\ReflectionParameter $param) => app($param->getType()->getName()),
|
||||
(new \ReflectionClass(LanguagePackService::class))->getConstructor()->getParameters()
|
||||
);
|
||||
$service = \Mockery::mock(LanguagePackService::class, $ctorArgs)->makePartial();
|
||||
$service->shouldReceive('installFromBundled')
|
||||
->once()
|
||||
->andReturnUsing(function () use ($pack) {
|
||||
// 설치 트랜잭션이 성공적으로 installed 를 기록한 직후 실패하는 상황 재현
|
||||
$pack->newQuery()->whereKey($pack->id)
|
||||
->update(['status' => LanguagePackStatus::Installed->value]);
|
||||
|
||||
throw new \RuntimeException('activate step failed (재현)');
|
||||
});
|
||||
|
||||
try {
|
||||
$service->performUpdate($pack->fresh(), true);
|
||||
$this->fail('installFromBundled 실패가 전파되어야 한다');
|
||||
} catch (\RuntimeException $e) {
|
||||
// 예상된 실패 — 상태 복원만 검증
|
||||
}
|
||||
|
||||
$this->assertSame(
|
||||
LanguagePackStatus::Active->value,
|
||||
$pack->fresh()->status,
|
||||
'실패한 update 는 이전 상태(active)를 복원해야 한다 — installed 로 방치되면 해당 로케일 번역이 조용히 폴백된다'
|
||||
);
|
||||
} finally {
|
||||
File::deleteDirectory($bundledDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
feature: 언어팩 로케일 주입·복원 일관성 (#597 보완 실측 후속)
|
||||
|
||||
description: |
|
||||
활성 언어팩 seed 의 로케일(ja 등)이 시더 필터와 [기본값 복원] 양쪽에서 같은 SSoT 로
|
||||
병합되는지 고정한다.
|
||||
|
||||
배경 (2026-08-24 #597 보완 실측에서 실측·확정):
|
||||
- [기본값 복원] 경로(core.notification.filter_default_definitions /
|
||||
core.identity.filter_default_message_definitions)가 언어팩 주입에 참여하지 않아,
|
||||
복원을 누르면 팩이 주입해 둔 로케일이 config 의 ko/en 만으로 대체되어 영구 소실됐다
|
||||
(실사례: 2026-08-23 복원 실측이 welcome ja 를 지움 — 오류·로그 없음).
|
||||
- 시더 필터(seed.notifications.translations)의 주입기가 리스트+type 형태만 읽어,
|
||||
코어 시더의 실제 페이로드(config 원형 — 연관 배열, 항목에 type 없음)에서는
|
||||
전 항목이 스킵되어 주입이 오류 없이 전면 불능이었다. identity 축은 시더가
|
||||
config 복합 키를 버리고 리스트로 넘겨 같은 방식으로 전면 불능이었다.
|
||||
- 커밋 전 점검(같은 날)에서 추가 확정: 7.0.9 업그레이드 스텝이 활성 팩마다
|
||||
활성화 훅을 재발화해 기존 설치본의 소실분을 병합 복구한다(upgrade_resync 축).
|
||||
이 백필의 안전 전제인 사용자 수정 보존은 dot-path(`"컬럼.로케일"`) 판정으로
|
||||
정합화했고(종전 isset 판정은 사문), 주입 저장의 user_overrides 오염(시더 동결
|
||||
유발)과 같은 프로세스 활성화의 시더 필터 stale(캡처 인스턴스 캐시)도 함께 교정.
|
||||
|
||||
axes:
|
||||
domain: [notification, identity]
|
||||
entry: [seeder_filter, reset_default, upgrade_resync]
|
||||
|
||||
effects:
|
||||
- seeder_filter_injects_active_pack_locales
|
||||
- seeder_filter_injects_ja_for_real_seeder_payload
|
||||
- reset_default_data_includes_lang_pack_locales
|
||||
- identity_reset_default_preserves_lang_pack_locales
|
||||
- upgrade_resync_restores_wiped_pack_locales
|
||||
- upgrade_resync_restores_wiped_identity_locales
|
||||
|
||||
test_files:
|
||||
- tests/Feature/LanguagePack/NotificationSeedInjectionTest.php
|
||||
- tests/Feature/LanguagePack/IdentitySeedInjectionTest.php
|
||||
- tests/Feature/Upgrades/Upgrade709LangPackResyncTest.php
|
||||
|
||||
validation:
|
||||
automated: "php artisan test --filter='NotificationSeedInjectionTest|IdentitySeedInjectionTest|Upgrade709LangPackResyncTest|SyncDatabaseTranslationsTest'"
|
||||
manual: |
|
||||
관리자 알림 설정에서 언어팩이 번역을 제공하는 템플릿(예: welcome)에 [기본값 복원] 실행 후,
|
||||
일본어 화면에서 제목·본문 번역이 유지되는지 확인한다.
|
||||
@@ -0,0 +1,27 @@
|
||||
feature: 코어 알림 정의 타입 ↔ 관리자 화면 라벨 패리티
|
||||
|
||||
description: |
|
||||
관리자 알림 설정 화면의 정의 목록 제목은 DB name 이 아니라 프론트 다국어 키
|
||||
admin.settings.notification_definitions.types.{type} 로 렌더된다. 이 네임스페이스의
|
||||
코어 소유분은 admin 템플릿(sirsoft-admin_basic)의 lang/partial/{ko,en}/admin.json 이
|
||||
공급한다(모듈 소유 타입은 각 모듈 화면·lang 담당, ja 는 템플릿 언어팩 담당).
|
||||
|
||||
키가 없으면 예외·경고 없이 원시 키 문자열이 제목으로 그대로 노출된다
|
||||
(실사례: #481 이 sitemap_regenerated / sitemap_regenerate_failed 정의를 config 에만
|
||||
추가하고 템플릿 라벨을 누락 — 2026-08-24 PO 제보). config/core.php 의 코어 정의
|
||||
전수를 양 로케일 라벨과 자동 대조해 재발을 차단한다.
|
||||
|
||||
axes:
|
||||
locale: [ko, en]
|
||||
|
||||
effects:
|
||||
- core_definition_types_have_admin_template_labels
|
||||
|
||||
test_files:
|
||||
- tests/Unit/Notifications/NotificationDefinitionTypeLabelParityTest.php
|
||||
|
||||
validation:
|
||||
manual: |
|
||||
/admin/settings?tab=notification_definitions 의 메일·사이트내 알림 탭에서 각 행 제목이
|
||||
번역 문구로 표시되는지(원시 admin.settings.* 키 노출 0) 브라우저 실측. ja locale 은
|
||||
g7-template-sirsoft-admin_basic-ja 팩 활성 상태에서 동일 확인.
|
||||
Reference in new issue
Block a user