修复新人进房欢迎消息显示
This commit is contained in:
@@ -721,6 +721,8 @@ class ChatControllerTest extends TestCase
|
||||
$room = Room::create(['room_name' => 'annsafe']);
|
||||
$user = $this->createUserWithPositionPermissions([
|
||||
PositionPermissionRegistry::ROOM_ANNOUNCEMENT,
|
||||
], [
|
||||
'has_received_new_gift' => true,
|
||||
]);
|
||||
|
||||
$this->actingAs($user)->get(route('chat.room', $room->id));
|
||||
@@ -992,6 +994,38 @@ class ChatControllerTest extends TestCase
|
||||
$this->assertStringContainsString($user->username, $presenceMessage['presence_text']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试新人首次进房时首屏历史包含礼包公告、AI 欢迎和普通进场播报。
|
||||
*/
|
||||
public function test_newbie_first_join_keeps_bonus_ai_and_entry_welcome_messages(): void
|
||||
{
|
||||
$room = Room::create(['room_name' => 'newbie']);
|
||||
$user = User::factory()->create([
|
||||
'jjb' => 0,
|
||||
'has_received_new_gift' => false,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->get(route('chat.room', $room->id));
|
||||
|
||||
$response->assertOk();
|
||||
$history = collect($response->viewData('historyMessages'));
|
||||
|
||||
$newbieBonusMessage = $history->first(fn (array $message): bool => ($message['welcome_kind'] ?? '') === 'newbie_bonus');
|
||||
$aiWelcomeMessage = $history->first(fn (array $message): bool => ($message['welcome_kind'] ?? '') === 'ai_newbie_welcome');
|
||||
$entryMessage = $history->first(fn (array $message): bool => ($message['welcome_kind'] ?? '') === 'entry_broadcast');
|
||||
|
||||
$this->assertNotNull($newbieBonusMessage);
|
||||
$this->assertSame('系统公告', $newbieBonusMessage['from_user']);
|
||||
$this->assertStringContainsString('6666 金币新人大礼包', $newbieBonusMessage['content']);
|
||||
$this->assertNotNull($aiWelcomeMessage);
|
||||
$this->assertSame('AI小班长', $aiWelcomeMessage['from_user']);
|
||||
$this->assertSame('大家', $aiWelcomeMessage['to_user']);
|
||||
$this->assertNotNull($entryMessage);
|
||||
$this->assertSame($user->username, $entryMessage['welcome_user']);
|
||||
$this->assertTrue($user->fresh()->has_received_new_gift);
|
||||
$this->assertSame(6666, (int) $user->fresh()->jjb);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试可以获取所有房间的在线人数状态。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user