Add VIP presence themes and custom greetings
This commit is contained in:
@@ -98,6 +98,37 @@ class ChatControllerTest extends TestCase
|
||||
$this->assertEquals(0, Redis::hexists("room:{$room->id}:users", $user->username));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试会员用户首次进房时会把专属欢迎主题写入历史消息。
|
||||
*/
|
||||
public function test_vip_user_join_message_uses_presence_theme_payload(): void
|
||||
{
|
||||
$room = Room::create(['room_name' => 'vip_theme_room']);
|
||||
$vipLevel = \App\Models\VipLevel::factory()->create([
|
||||
'join_effect' => 'lightning',
|
||||
'join_banner_style' => 'storm',
|
||||
'allow_custom_messages' => true,
|
||||
]);
|
||||
$user = User::factory()->create([
|
||||
'vip_level_id' => $vipLevel->id,
|
||||
'hy_time' => now()->addDays(30),
|
||||
'custom_join_message' => '{username} 带着风暴王座闪耀降临',
|
||||
'has_received_new_gift' => true,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->get(route('chat.room', $room->id));
|
||||
|
||||
$response->assertStatus(200);
|
||||
$history = $response->viewData('historyMessages');
|
||||
$presenceMessage = collect($history)->first(fn (array $message) => ($message['action'] ?? '') === 'vip_presence');
|
||||
|
||||
$this->assertNotNull($presenceMessage);
|
||||
$this->assertSame('join', $presenceMessage['presence_type']);
|
||||
$this->assertSame('lightning', $presenceMessage['presence_effect']);
|
||||
$this->assertSame('storm', $presenceMessage['presence_banner_style']);
|
||||
$this->assertStringContainsString($user->username, $presenceMessage['presence_text']);
|
||||
}
|
||||
|
||||
public function test_can_get_rooms_online_status()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
Reference in New Issue
Block a user