import 'package:flutter_test/flutter_test.dart'; import 'package:plezy/media/media_backend.dart'; import 'package:plezy/models/plex/plex_home_user.dart'; import 'package:plezy/profiles/profile.dart'; import 'package:plezy/widgets/media_context_menu.dart'; void main() { group('isAdminActionAllowedForMediaItem', () { test('blocks non-admin Plex Home users on Plex items', () { final profile = Profile.virtualPlexHome(connectionId: 'plex-1', homeUser: _homeUser(admin: false)); expect( isAdminActionAllowedForMediaItem(isOwnerOrAdmin: true, itemBackend: MediaBackend.plex, activeProfile: profile), isFalse, ); }); test('does not apply Plex Home role to Jellyfin items', () { final profile = Profile.virtualPlexHome(connectionId: 'plex-1', homeUser: _homeUser(admin: false)); expect( isAdminActionAllowedForMediaItem( isOwnerOrAdmin: true, itemBackend: MediaBackend.jellyfin, activeProfile: profile, ), isTrue, ); }); test('allows Plex admin Home users on Plex items', () { final profile = Profile.virtualPlexHome(connectionId: 'plex-1', homeUser: _homeUser(admin: true)); expect( isAdminActionAllowedForMediaItem(isOwnerOrAdmin: true, itemBackend: MediaBackend.plex, activeProfile: profile), isTrue, ); }); }); } PlexHomeUser _homeUser({required bool admin}) { return PlexHomeUser( id: 0, uuid: 'home-user', title: 'Home User', username: null, email: null, friendlyName: null, thumb: 'https://plex.tv/users/home-user/avatar', hasPassword: false, restricted: false, updatedAt: null, admin: admin, guest: false, protected: false, ); }