修复聊天室字号偏好和游戏通知显示
This commit is contained in:
@@ -417,7 +417,7 @@ class UserControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试可以保存聊天室屏蔽与禁音偏好。
|
||||
* 测试可以保存聊天室屏蔽、禁音与字号偏好。
|
||||
*/
|
||||
public function test_can_update_chat_preferences(): void
|
||||
{
|
||||
@@ -428,6 +428,7 @@ class UserControllerTest extends TestCase
|
||||
$response = $this->actingAs($user)->putJson('/user/chat-preferences', [
|
||||
'blocked_system_senders' => ['钓鱼播报', '神秘箱子', '跑马'],
|
||||
'sound_muted' => true,
|
||||
'font_size' => 22,
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
@@ -435,15 +436,59 @@ class UserControllerTest extends TestCase
|
||||
->assertJsonPath('data.blocked_system_senders.0', '钓鱼播报')
|
||||
->assertJsonPath('data.blocked_system_senders.1', '神秘箱子')
|
||||
->assertJsonPath('data.blocked_system_senders.2', '跑马')
|
||||
->assertJsonPath('data.sound_muted', true);
|
||||
->assertJsonPath('data.sound_muted', true)
|
||||
->assertJsonPath('data.font_size', 22);
|
||||
|
||||
$user->refresh();
|
||||
$this->assertEquals([
|
||||
'blocked_system_senders' => ['钓鱼播报', '神秘箱子', '跑马'],
|
||||
'sound_muted' => true,
|
||||
'font_size' => 22,
|
||||
], $user->chat_preferences);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试保存屏蔽偏好时未提交字号不会清空已有字号。
|
||||
*/
|
||||
public function test_chat_preferences_keep_existing_font_size_when_missing_from_payload(): void
|
||||
{
|
||||
$user = User::factory()->create([
|
||||
'chat_preferences' => [
|
||||
'blocked_system_senders' => [],
|
||||
'sound_muted' => false,
|
||||
'font_size' => 18,
|
||||
],
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->putJson('/user/chat-preferences', [
|
||||
'blocked_system_senders' => ['钓鱼播报'],
|
||||
'sound_muted' => false,
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('data.font_size', 18);
|
||||
|
||||
$user->refresh();
|
||||
$this->assertSame(18, $user->chat_preferences['font_size']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试非法聊天室字号会返回校验错误。
|
||||
*/
|
||||
public function test_invalid_chat_font_size_returns_validation_error(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->putJson('/user/chat-preferences', [
|
||||
'blocked_system_senders' => [],
|
||||
'sound_muted' => false,
|
||||
'font_size' => 31,
|
||||
]);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors('font_size');
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试猜谜活动新文案会兼容落回旧的屏蔽键。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user