fixes login page in tenant admin pwa
This commit is contained in:
@@ -95,4 +95,31 @@ class TenantProfileApiTest extends TestCase
|
||||
|
||||
$response->assertStatus(401);
|
||||
}
|
||||
|
||||
public function test_exchange_returns_no_content_when_session_missing(): void
|
||||
{
|
||||
$response = $this->postJson('/api/v1/tenant-auth/exchange');
|
||||
|
||||
$response->assertNoContent();
|
||||
}
|
||||
|
||||
public function test_exchange_returns_token_for_authenticated_session(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create();
|
||||
$user = User::factory()->create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'role' => 'tenant_admin',
|
||||
'email_verified_at' => now(),
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson('/api/v1/tenant-auth/exchange');
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertJsonStructure([
|
||||
'token',
|
||||
'token_type',
|
||||
'abilities',
|
||||
'user' => ['id', 'email', 'role', 'tenant_id'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user