setupUser(); $role = Role::firstOrCreate(['name' => 'Owner']); Permission::firstOrCreate(['name' => 'view bottle']); Permission::firstOrCreate(['name' => 'audit bottle']); $role->givePermissionTo(['view bottle', 'audit bottle']); $this->user->assignRole($role); }); it('renders the bottle audit page correctly', function () { $outlet = Outlet::factory()->create(); $bottle = Bottle::factory()->create(); $this->actingAs($this->user) ->get(route('studio.catalog.bottle.audit', ['outlet' => $outlet, 'bottle' => $bottle])) ->assertOk() ->assertSeeLivewire(Audit::class); }); it('cannot access bottle audit without permission', function () { $outlet = Outlet::factory()->create(); $bottle = Bottle::factory()->create(); $this->user->roles()->detach(); $this->user->permissions()->detach(); $this->actingAs($this->user) ->get(route('studio.catalog.bottle.audit', ['outlet' => $outlet, 'bottle' => $bottle])) ->assertForbidden(); });