diff --git a/resources/views/chat/frame.blade.php b/resources/views/chat/frame.blade.php index 9eb6e7e..ae66ce9 100644 --- a/resources/views/chat/frame.blade.php +++ b/resources/views/chat/frame.blade.php @@ -285,6 +285,57 @@ + {{-- ═══════════ 账号安全绑定强引导(邮箱/微信二选一) ═══════════ --}} + @if (empty(Auth::user()->email) && empty(Auth::user()->wxid)) + + + @endif + diff --git a/tests/Feature/SecurityBindAlertTest.php b/tests/Feature/SecurityBindAlertTest.php new file mode 100644 index 0000000..f0063b3 --- /dev/null +++ b/tests/Feature/SecurityBindAlertTest.php @@ -0,0 +1,92 @@ +create([ + 'room_name' => '大厅', + 'room_owner' => '站长', + 'room_des' => '欢迎光临', + 'permit_level' => 0, + ]); + } + + /** + * 测试当用户邮箱和微信均未绑定时,进入聊天室大厅页面会渲染安全绑定遮罩弹窗提示 + */ + public function test_shows_bind_alert_modal_when_user_has_no_email_and_no_wechat(): void + { + $user = User::factory()->create([ + 'email' => null, + 'wxid' => null, + ]); + + $room = $this->createRoom(); + + $response = $this->actingAs($user)->get(route('chat.room', $room->id)); + + $response->assertStatus(200); + $response->assertSee('security-bind-modal'); + $response->assertSee('账号安全绑定提醒'); + $response->assertSee('立即前往设置(查看微信小小二维码)'); + } + + /** + * 测试当用户已经设置了邮箱时,进入聊天室大厅页面不会弹出安全绑定提醒 + */ + public function test_does_not_show_bind_alert_when_user_has_email(): void + { + $user = User::factory()->create([ + 'email' => 'has.email@example.com', + 'wxid' => null, + ]); + + $room = $this->createRoom(); + + $response = $this->actingAs($user)->get(route('chat.room', $room->id)); + + $response->assertStatus(200); + $response->assertDontSee('security-bind-modal'); + $response->assertDontSee('账号安全绑定提醒'); + } + + /** + * 测试当用户已经绑定了微信时,进入聊天室大厅页面不会弹出安全提醒 + */ + public function test_does_not_show_bind_alert_when_user_has_wechat(): void + { + $user = User::factory()->create([ + 'email' => null, + 'wxid' => 'wxid_test_123', + ]); + + $room = $this->createRoom(); + + $response = $this->actingAs($user)->get(route('chat.room', $room->id)); + + $response->assertStatus(200); + $response->assertDontSee('security-bind-modal'); + $response->assertDontSee('账号安全绑定提醒'); + } +}