diff --git a/tests/mock_library_repo.go b/tests/mock_library_repo.go
index 6e922ed88..5feb8fb06 100644
--- a/tests/mock_library_repo.go
+++ b/tests/mock_library_repo.go
@@ -267,7 +267,6 @@ func (m *MockLibraryRepo) GetUserLibraries(ctx context.Context, userID string) (
if userID == "non-existent" {
return nil, model.ErrNotFound
}
- // If per-user tracking is set, return only the assigned libraries
if m.UserLibraries != nil {
ids, ok := m.UserLibraries[userID]
if !ok {
@@ -284,15 +283,7 @@ func (m *MockLibraryRepo) GetUserLibraries(ctx context.Context, userID string) (
})
return libraries, nil
}
- // Fallback: return all libraries
- var libraries model.Libraries
- for _, lib := range m.Data {
- libraries = append(libraries, lib)
- }
- slices.SortFunc(libraries, func(a, b model.Library) int {
- return a.ID - b.ID
- })
- return libraries, nil
+ return m.GetAll()
}
func (m *MockLibraryRepo) SetUserLibraries(ctx context.Context, userID string, libraryIDs []int) error {
@@ -305,13 +296,11 @@ func (m *MockLibraryRepo) SetUserLibraries(ctx context.Context, userID string, l
if userID == "admin-1" {
return fmt.Errorf("%w: cannot manually assign libraries to admin users", model.ErrValidation)
}
- // Validate all library IDs exist
for _, id := range libraryIDs {
if _, exists := m.Data[id]; !exists {
return fmt.Errorf("%w: library ID %d does not exist", model.ErrValidation, id)
}
}
- // Store per-user assignments
if m.UserLibraries == nil {
m.UserLibraries = make(map[string][]int)
}
diff --git a/ui/src/user/UserCreate.jsx b/ui/src/user/UserCreate.jsx
index ce69b6542..b6370ad9b 100644
--- a/ui/src/user/UserCreate.jsx
+++ b/ui/src/user/UserCreate.jsx
@@ -51,17 +51,9 @@ const UserCreate = (props) => {
[mutate, notify, redirect],
)
- // Custom validation function
- const validateUserForm = (values) => {
- const errors = {}
- // Library selection is optional for non-admin users since they will be auto-assigned to default libraries
- // No validation required for library selection
- return errors
- }
-
return (
} {...props}>
-
+
{
[mutate, notify, permissions, redirect, refresh],
)
- // Custom validation function
- const validateForm = (values) => {
- return validateUserForm(values, translate)
- }
-
return (
} undoable={false} {...props}>
}
save={save}
- validate={validateForm}
>
{permissions === 'admin' && (
{
- const errors = {}
- return errors
-}
diff --git a/ui/src/user/userValidation.test.js b/ui/src/user/userValidation.test.js
deleted file mode 100644
index f1d1aadba..000000000
--- a/ui/src/user/userValidation.test.js
+++ /dev/null
@@ -1,43 +0,0 @@
-import { describe, it, expect, vi } from 'vitest'
-import { validateUserForm } from './userValidation'
-
-describe('User Validation Utilities', () => {
- const mockTranslate = vi.fn((key) => key)
-
- describe('validateUserForm', () => {
- it('should not return errors for admin users', () => {
- const values = {
- isAdmin: true,
- libraryIds: [],
- }
- const errors = validateUserForm(values, mockTranslate)
- expect(errors).toEqual({})
- })
-
- it('should not return errors for non-admin users with libraries', () => {
- const values = {
- isAdmin: false,
- libraryIds: [1, 2, 3],
- }
- const errors = validateUserForm(values, mockTranslate)
- expect(errors).toEqual({})
- })
-
- it('should not return errors for non-admin users without libraries', () => {
- const values = {
- isAdmin: false,
- libraryIds: [],
- }
- const errors = validateUserForm(values, mockTranslate)
- expect(errors).toEqual({})
- })
-
- it('should not return errors for non-admin users with undefined libraryIds', () => {
- const values = {
- isAdmin: false,
- }
- const errors = validateUserForm(values, mockTranslate)
- expect(errors).toEqual({})
- })
- })
-})