Files
portal-api/tests/Feature/Api/Client/PublicSettingTest.php
baodev0andClaude Opus 5.5 0bd15f6018 feat: bật/tắt yêu cầu hoàn tất hồ sơ, xoá dịch vụ kèm đơn/hoá đơn, sync tên VM đã gán
- setting.require_complete_profile (mặc định bật), trả qua GET v1/setting
- bulkDeleteServices xoá mềm invoice nâng cấp + order mồ côi (ServiceOrderRecorder::discardOrder)
- createService trỏ dịch vụ sang order mới thì bỏ order cũ
- SyncVirtualMachine cập nhật name + gắn virtual_machine_id cho module_vmware

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 08:04:02 +07:00

54 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Api\Client;
use App\Models\Setting;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class PublicSettingTest extends TestCase
{
use RefreshDatabase;
public function test_public_setting_endpoints_expose_only_whitelisted_fields(): void
{
Setting::updateOrCreate(['key' => 'setting'], ['value' => json_encode([
'title' => 'Portal',
'brand_color' => '#EF6824',
'bot_token' => 'secret-bot-token',
'inet_api_key' => 'secret-inet-key',
'telegram_group_id' => '-100123',
'admin_email' => 'admin@example.com',
])]);
$client = $this->withHeaders(['x-access-token' => $this->buildClientAccessToken()])
->getJson('/v1/setting')
->assertOk()
->assertJsonPath('data.title', 'Portal')
->assertJsonPath('data.brand_color', '#EF6824')
->assertJsonPath('data.require_complete_profile', true);
$admin = $this->getJson('/api/v1/settings/public')->assertOk();
foreach ([$client, $admin] as $response) {
$body = $response->getContent();
$this->assertStringNotContainsString('secret-bot-token', $body);
$this->assertStringNotContainsString('secret-inet-key', $body);
$this->assertStringNotContainsString('-100123', $body);
$this->assertStringNotContainsString('admin@example.com', $body);
}
}
public function test_client_setting_reflects_disabled_profile_completion(): void
{
Setting::updateOrCreate(['key' => 'setting'], ['value' => json_encode(['require_complete_profile' => false])]);
$this->withHeaders(['x-access-token' => $this->buildClientAccessToken()])
->getJson('/v1/setting')
->assertOk()
->assertJsonPath('data.require_complete_profile', false);
}
}