feat(superadmin): migrate internal docs from docusaurus to guava kb
This commit is contained in:
@@ -74,4 +74,27 @@ class UserRoleAccessTest extends TestCase
|
||||
$response2 = $this->actingAs($user)->get('/event-admin/dashboard');
|
||||
$response2->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_super_admin_can_access_super_admin_docs_panel(): void
|
||||
{
|
||||
$user = User::factory()->create(['role' => 'super_admin']);
|
||||
|
||||
$response = $this->actingAs($user, 'super_admin')->get('/super-admin/docs');
|
||||
|
||||
$response->assertRedirect();
|
||||
|
||||
$redirectPath = parse_url((string) $response->headers->get('Location'), PHP_URL_PATH);
|
||||
|
||||
$this->assertNotSame('/super-admin/docs/login', $redirectPath);
|
||||
$this->assertStringStartsWith('/super-admin/docs', (string) $redirectPath);
|
||||
}
|
||||
|
||||
public function test_non_super_admin_cannot_access_super_admin_docs_panel(): void
|
||||
{
|
||||
$user = User::factory()->create(['role' => 'tenant_admin']);
|
||||
|
||||
$response = $this->actingAs($user, 'super_admin')->get('/super-admin/docs');
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,26 @@ class FilamentPanelNavigationTest extends TestCase
|
||||
$pages = $resource::getPages();
|
||||
$this->assertNotEmpty($pages, $resource);
|
||||
|
||||
$registration = $pages['index'] ?? reset($pages);
|
||||
$registration = $pages['index'] ?? null;
|
||||
|
||||
if (! $registration) {
|
||||
foreach ($pages as $pageRegistration) {
|
||||
$candidate = $pageRegistration instanceof PageRegistration ? $pageRegistration->getPage() : $pageRegistration;
|
||||
|
||||
if ($this->pageRequiresMountArguments($candidate)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$registration = $pageRegistration;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $registration) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pageClass = $registration instanceof PageRegistration ? $registration->getPage() : $registration;
|
||||
|
||||
Livewire::test($pageClass)
|
||||
@@ -107,4 +126,23 @@ class FilamentPanelNavigationTest extends TestCase
|
||||
Filament::setTenant(null, true);
|
||||
}
|
||||
}
|
||||
|
||||
private function pageRequiresMountArguments(string $pageClass): bool
|
||||
{
|
||||
if (! method_exists($pageClass, 'mount')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$reflection = new \ReflectionMethod($pageClass, 'mount');
|
||||
|
||||
foreach ($reflection->getParameters() as $parameter) {
|
||||
if ($parameter->isOptional() || $parameter->isDefaultValueAvailable() || $parameter->allowsNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user