abkrim
4 months ago
678
4
Nova

Testing Nova

Posted 4 months ago by abkrim

I like test my dashboard app made with nova.

I'm looking form examples in internet, but only see a example for use Spatie\Permission but I don't need this package.

My test code fail

/** @test */
    function super_admin_has_ui_access()
    {
        $user = factory(User::class)->create(['is_super_admin' => true]);

        $response = $this->actingAs($user)
            ->get('/nova/resources/users/1');


        $response->assertStatus(200);
    }

Also if test only dashdoard

$response = $this->actingAs($user)
            ->withSession(['foo' => 'bar'])
            ->get('/nova/dashboards/main');

error

1) Tests\Feature\NovaAccessTest::super_admin_has_ui_access
Expected status code 200 but received 403.
Failed asserting that false is true.

/home/abkrim/Sites/albarid/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:185
/home/abkrim/Sites/albarid/tests/Feature/NovaAccessTest.php:20

Any ideas?

Please sign in or create an account to participate in this conversation.