fixes login page in tenant admin pwa

This commit is contained in:
Codex Agent
2025-11-07 13:52:29 +01:00
parent 253239455b
commit f3c44be76d
9 changed files with 156 additions and 21 deletions

View File

@@ -0,0 +1,64 @@
<?php
namespace Tests\Feature\Tenant\Settings;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class NotificationPreferencesTest extends TestCase
{
use RefreshDatabase;
public function test_tenant_admin_can_fetch_notification_preferences(): void
{
$tenant = Tenant::factory()->create([
'notification_preferences' => [
'photo_thresholds' => false,
],
]);
$user = User::factory()->create([
'tenant_id' => $tenant->id,
'role' => 'tenant_admin',
'email_verified_at' => now(),
]);
Sanctum::actingAs($user, abilities: ['tenant-admin', 'tenant:'.$tenant->id]);
$response = $this->getJson('/api/v1/tenant/settings/notifications');
$response->assertOk();
$response->assertJsonPath('data.preferences.photo_thresholds', false);
$response->assertJsonStructure([
'data' => [
'defaults',
'preferences',
'overrides',
'meta' => ['credit_warning_sent_at', 'credit_warning_threshold'],
],
]);
}
public function test_super_admin_can_fetch_notification_preferences_for_specific_tenant(): void
{
$tenant = Tenant::factory()->create();
$superAdmin = User::factory()->create([
'role' => 'super_admin',
'tenant_id' => null,
'email_verified_at' => now(),
]);
Sanctum::actingAs($superAdmin, abilities: ['tenant-admin', 'super-admin']);
$response = $this
->withHeader('X-Tenant-ID', (string) $tenant->id)
->getJson('/api/v1/tenant/settings/notifications');
$response->assertOk();
$response->assertJsonPath('data.defaults.photo_thresholds', true);
}
}