Testing using acting as with superadmin.

Hi, i'm using PEST to test some parts of my panel, and I want to make a test to assert that some html is visible.

The problem is when i'm trying to use a new user, with super_admin role, but when the page render, it trows 403 forbidden.

Here the test:

it('Has contextual menu', function () {
        $project = \Maat\Projects\Models\Project::factory()->create();

        $user = User::factory()->create();
        $user->assignRole('super_admin');

        $response = $this->actingAs($user)->get(\Maat\Projects\Resources\ProjectResource::getUrl('view', [
            'record' => $project->name
        ]));

        $response->assertSee('<span class="fi-sidebar-item-label flex-1 truncate text-primary-600 dark:text-primary-400 font-semibold">Info</span>');
    });
Was this page helpful?