恢复用户卡片私信查看

This commit is contained in:
pllx
2026-05-09 11:25:28 +08:00
parent 8c1b0b0840
commit da0846c7ab
3 changed files with 73 additions and 15 deletions
@@ -10,6 +10,7 @@ namespace Tests\Feature\Feature;
use App\Events\BrowserRefreshRequested;
use App\Jobs\SaveMessageJob;
use App\Models\Department;
use App\Models\Message;
use App\Models\Position;
use App\Models\Room;
use App\Models\User;
@@ -232,6 +233,55 @@ class AdminCommandControllerTest extends TestCase
Event::assertNotDispatched(BrowserRefreshRequested::class);
}
/**
* 测试站长查看用户私信时不会混入系统发给用户的私信通知。
*/
public function test_view_whispers_excludes_system_private_messages(): void
{
$admin = User::factory()->create([
'id' => 1,
'user_level' => 100,
]);
$target = User::factory()->create([
'username' => '目标用户',
]);
$friend = User::factory()->create([
'username' => '好友用户',
]);
Message::create([
'room_id' => 1,
'from_user' => $target->username,
'to_user' => $friend->username,
'content' => '这条用户私聊需要显示',
'is_secret' => true,
'sent_at' => now(),
]);
Message::create([
'room_id' => 1,
'from_user' => '系统',
'to_user' => $target->username,
'content' => '这条系统私信不应显示',
'is_secret' => true,
'sent_at' => now(),
]);
Message::create([
'room_id' => 1,
'from_user' => '系统传音',
'to_user' => $target->username,
'content' => '这条系统传音私信也不应显示',
'is_secret' => true,
'sent_at' => now(),
]);
$response = $this->actingAs($admin)->getJson(route('command.whispers', $target->username));
$response->assertOk()
->assertJsonPath('status', 'success')
->assertJsonCount(1, 'messages')
->assertJsonPath('messages.0.content', '这条用户私聊需要显示');
}
/**
* 测试管理操作中的奖励金币会给接收方写入带右下角提示的私聊消息。
*/