新增聊天室刷新同步与全员刷新功能

This commit is contained in:
2026-04-21 17:14:12 +08:00
parent c209221bad
commit fed51dda18
13 changed files with 425 additions and 9 deletions
@@ -8,6 +8,7 @@
namespace Tests\Feature;
use App\Events\UserBrowserRefreshRequested;
use App\Jobs\SaveMessageJob;
use App\Models\Department;
use App\Models\Position;
@@ -15,6 +16,7 @@ use App\Models\Room;
use App\Models\User;
use App\Models\UserPosition;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Redis;
use Tests\TestCase;
@@ -40,6 +42,7 @@ class ChatAppointmentControllerTest extends TestCase
*/
public function test_appoint_pushes_private_toast_notification_to_target(): void
{
Event::fake([UserBrowserRefreshRequested::class]);
Queue::fake();
[$admin, $target, $room, $position] = $this->createAppointmentActors();
@@ -63,6 +66,12 @@ class ChatAppointmentControllerTest extends TestCase
$this->assertSame('✨', $privateMessage['toast_notification']['icon'] ?? null);
$this->assertSame('#a855f7', $privateMessage['toast_notification']['color'] ?? null);
Event::assertDispatched(UserBrowserRefreshRequested::class, function (UserBrowserRefreshRequested $event) use ($target, $admin) {
return $event->targetUserId === $target->id
&& $event->operator === $admin->username
&& $event->reason === '你的职务已发生变更,页面权限正在同步更新。';
});
Queue::assertPushed(SaveMessageJob::class, 1);
}
@@ -71,6 +80,7 @@ class ChatAppointmentControllerTest extends TestCase
*/
public function test_revoke_pushes_private_toast_notification_to_target(): void
{
Event::fake([UserBrowserRefreshRequested::class]);
Queue::fake();
[$admin, $target, $room, $position] = $this->createAppointmentActors();
@@ -102,6 +112,12 @@ class ChatAppointmentControllerTest extends TestCase
$this->assertSame('📋', $privateMessage['toast_notification']['icon'] ?? null);
$this->assertSame('#6b7280', $privateMessage['toast_notification']['color'] ?? null);
Event::assertDispatched(UserBrowserRefreshRequested::class, function (UserBrowserRefreshRequested $event) use ($target, $admin) {
return $event->targetUserId === $target->id
&& $event->operator === $admin->username
&& $event->reason === '你的职务已被撤销,页面权限正在同步更新。';
});
Queue::assertPushed(SaveMessageJob::class, 1);
}