die tenant admin oauth authentifizierung wurde implementiert und funktioniert jetzt. Zudem wurde das marketing frontend dashboard implementiert.
This commit is contained in:
@@ -5,16 +5,16 @@ namespace Tests\Feature\Tenant;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SettingsApiTest extends TenantTestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected Tenant $tenant;
|
||||
|
||||
protected User $tenantUser;
|
||||
|
||||
protected string $token;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -37,9 +37,9 @@ class SettingsApiTest extends TenantTestCase
|
||||
$response = $this->authenticatedRequest('GET', '/api/v1/tenant/settings');
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJson(['message' => 'Settings erfolgreich abgerufen.'])
|
||||
->assertJsonPath('data.settings.branding.primary_color', '#3B82F6')
|
||||
->assertJsonPath('data.settings.features.photo_likes_enabled', true);
|
||||
->assertJson(['message' => 'Settings erfolgreich abgerufen.'])
|
||||
->assertJsonPath('data.settings.branding.primary_color', '#3B82F6')
|
||||
->assertJsonPath('data.settings.features.photo_likes_enabled', true);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -64,10 +64,10 @@ class SettingsApiTest extends TenantTestCase
|
||||
$response = $this->authenticatedRequest('POST', '/api/v1/tenant/settings', $settingsData);
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJson(['message' => 'Settings erfolgreich aktualisiert.'])
|
||||
->assertJsonPath('data.settings.branding.primary_color', '#FF6B6B')
|
||||
->assertJsonPath('data.settings.features.photo_likes_enabled', false)
|
||||
->assertJsonPath('data.settings.custom_domain', 'custom.example.com');
|
||||
->assertJson(['message' => 'Settings erfolgreich aktualisiert.'])
|
||||
->assertJsonPath('data.settings.branding.primary_color', '#FF6B6B')
|
||||
->assertJsonPath('data.settings.features.photo_likes_enabled', false)
|
||||
->assertJsonPath('data.settings.custom_domain', 'custom.example.com');
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'id' => $this->tenant->id,
|
||||
@@ -89,9 +89,9 @@ class SettingsApiTest extends TenantTestCase
|
||||
$response = $this->authenticatedRequest('POST', '/api/v1/tenant/settings', $invalidData);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors([
|
||||
'settings.branding.primary_color',
|
||||
]);
|
||||
->assertJsonValidationErrors([
|
||||
'settings.branding.primary_color',
|
||||
]);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -100,9 +100,9 @@ class SettingsApiTest extends TenantTestCase
|
||||
$response = $this->authenticatedRequest('POST', '/api/v1/tenant/settings/reset');
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJson(['message' => 'Settings auf Standardwerte zurueckgesetzt.'])
|
||||
->assertJsonPath('data.settings.branding.primary_color', '#3B82F6')
|
||||
->assertJsonPath('data.settings.features.photo_likes_enabled', true);
|
||||
->assertJson(['message' => 'Settings auf Standardwerte zurueckgesetzt.'])
|
||||
->assertJsonPath('data.settings.branding.primary_color', '#3B82F6')
|
||||
->assertJsonPath('data.settings.features.photo_likes_enabled', true);
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'id' => $this->tenant->id,
|
||||
@@ -135,8 +135,8 @@ class SettingsApiTest extends TenantTestCase
|
||||
]);
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJson(['available' => true])
|
||||
->assertJson(['message' => 'Domain ist verfuegbar.']);
|
||||
->assertJson(['available' => true])
|
||||
->assertJson(['message' => 'Domain ist verfuegbar.']);
|
||||
|
||||
// Invalid domain format
|
||||
$response = $this->authenticatedRequest('POST', '/api/v1/tenant/settings/validate-domain', [
|
||||
@@ -144,19 +144,19 @@ class SettingsApiTest extends TenantTestCase
|
||||
]);
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJson(['available' => false])
|
||||
->assertJson(['message' => 'Ungueltiges Domain-Format.']);
|
||||
->assertJson(['available' => false])
|
||||
->assertJson(['message' => 'Ungueltiges Domain-Format.']);
|
||||
|
||||
// Taken domain (create another tenant with same domain)
|
||||
$otherTenant = Tenant::factory()->create(['custom_domain' => 'taken.example.com']);
|
||||
|
||||
|
||||
$response = $this->authenticatedRequest('POST', '/api/v1/tenant/settings/validate-domain', [
|
||||
'domain' => 'taken.example.com',
|
||||
]);
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJson(['available' => false])
|
||||
->assertJson(['message' => 'Domain ist bereits vergeben.']);
|
||||
->assertJson(['available' => false])
|
||||
->assertJson(['message' => 'Domain ist bereits vergeben.']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -165,7 +165,8 @@ class SettingsApiTest extends TenantTestCase
|
||||
$response = $this->authenticatedRequest('POST', '/api/v1/tenant/settings/validate-domain');
|
||||
|
||||
$response->assertStatus(400)
|
||||
->assertJson(['error' => 'Domain ist erforderlich.']);
|
||||
->assertJsonPath('error.code', 'domain_missing')
|
||||
->assertJsonPath('error.message', 'Bitte gib eine Domain an.');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
@@ -178,15 +179,13 @@ class SettingsApiTest extends TenantTestCase
|
||||
'tenant_id' => $otherTenant->id,
|
||||
'role' => 'admin',
|
||||
]);
|
||||
$otherToken = 'mock-jwt-token-' . $otherTenant->id . '-' . time();
|
||||
$otherToken = 'mock-jwt-token-'.$otherTenant->id.'-'.time();
|
||||
|
||||
// This tenant's user should not see other tenant's settings
|
||||
$response = $this->authenticatedRequest('GET', '/api/v1/tenant/settings');
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonPath('data.settings.branding.primary_color', '#3B82F6') // Default for this tenant
|
||||
->assertJsonMissing(['#FF0000']); // Other tenant's color
|
||||
->assertJsonPath('data.settings.branding.primary_color', '#3B82F6') // Default for this tenant
|
||||
->assertJsonMissing(['#FF0000']); // Other tenant's color
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user