将用户管理操作接入职务权限体系
This commit is contained in:
@@ -215,6 +215,43 @@ class ChatControllerTest extends TestCase
|
||||
$response->assertDontSee("runAdminAction('announce-message')", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试用户名片中的用户管理按钮会按职务权限显示。
|
||||
*/
|
||||
public function test_room_view_renders_only_granted_user_management_buttons(): void
|
||||
{
|
||||
$room = Room::create(['room_name' => 'usermenu']);
|
||||
$user = $this->createUserWithPositionPermissions([
|
||||
PositionPermissionRegistry::USER_WARN,
|
||||
PositionPermissionRegistry::USER_MUTE,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->get(route('chat.room', $room->id));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertSee('⚠️ 警告', false);
|
||||
$response->assertSee('🔇 禁言', false);
|
||||
$response->assertDontSee('🚫 踢出', false);
|
||||
$response->assertDontSee('🧊 冻结', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试没有用户管理权限时,用户名片中不会渲染相关按钮。
|
||||
*/
|
||||
public function test_room_view_hides_user_management_buttons_without_permissions(): void
|
||||
{
|
||||
$room = Room::create(['room_name' => 'nousermenu']);
|
||||
$user = $this->createUserWithPositionPermissions([]);
|
||||
|
||||
$response = $this->actingAs($user)->get(route('chat.room', $room->id));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertDontSee('⚠️ 警告', false);
|
||||
$response->assertDontSee('🚫 踢出', false);
|
||||
$response->assertDontSee('🔇 禁言', false);
|
||||
$response->assertDontSee('🧊 冻结', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试站长即使没有在职职务,也能看到管理菜单中的刷新全员按钮。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user