Skip to content

Commit

Permalink
added:auth check and feature check to permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
namumakwembo committed Mar 4, 2025
1 parent 7fbd115 commit 3ae6e37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions resources/views/components/notification.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

@use('Namu\WireChat\Facades\WireChat')

@if(auth()->check() && WireChat::notificationsEnabled())

<div dusk="notification_manager"
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/SetupNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function handle()
$this->warn('To use Wirechat notifications, add the following at the top of your service worker file:');
$this->line("`importScripts('/js/wirechat/sw.js');`\n");
} else {
File::put($publicSW, $this->getStub($wirechatServiceWorkerStub));
File::put($publicSW, $this->getStub($mainServiceWorkerStub));
$this->info('✅ Created `sw.js` in the public directory.');
}

Expand Down
14 changes: 14 additions & 0 deletions tests/Feature/IndexTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

use Livewire\Livewire;
use Namu\WireChat\Facades\WireChat;
use Namu\WireChat\Livewire\Chat\Chat;
use Namu\WireChat\Livewire\Chats\Chats as Chatlist;
use Namu\WireChat\Livewire\Pages\Chats;
use Workbench\App\Models\User;

// /Auth checks
Expand Down Expand Up @@ -30,6 +32,18 @@

});


test('it reders @wirechatAssets', function () {
$auth = User::factory()->create();

$response= Livewire::actingAs($auth)->test(Chats::class)->assertOK();
$response->assertContainsBladeComponent('wirechatAssets');


})->only();



test('it doest not render livewire ChatBox component', function () {
$auth = User::factory()->create();
$response = $this->withoutExceptionHandling()->actingAs($auth)->get(route(WireChat::indexRouteName()));
Expand Down

0 comments on commit 3ae6e37

Please sign in to comment.