mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-10-20 16:49:03 +02:00
Signed-off-by: choksi2212 <choksi2212@users.noreply.github.com> Co-authored-by: choksi2212 <choksi2212@users.noreply.github.com>
40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/pocket-id/pocket-id/backend/internal/dto"
|
|
"github.com/pocket-id/pocket-id/backend/internal/utils"
|
|
)
|
|
|
|
func TestUserGroupListSearchMatchesFriendlyName(t *testing.T) {
|
|
_, groupService := newTestUserService(t)
|
|
|
|
_, err := groupService.Create(t.Context(), dto.UserGroupCreateDto{
|
|
Name: "qa_team",
|
|
FriendlyName: "QA Engineering",
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
// A search for the friendly name must find the group, since the
|
|
// friendly name is the name shown in the UI.
|
|
groups, pagination, err := groupService.List(t.Context(), "Engineering", utils.ListRequestOptions{})
|
|
require.NoError(t, err)
|
|
require.Len(t, groups, 1)
|
|
require.Equal(t, "QA Engineering", groups[0].FriendlyName)
|
|
require.EqualValues(t, 1, pagination.TotalItems)
|
|
|
|
// The internal name must remain searchable too.
|
|
groups, _, err = groupService.List(t.Context(), "qa_team", utils.ListRequestOptions{})
|
|
require.NoError(t, err)
|
|
require.Len(t, groups, 1)
|
|
require.Equal(t, "QA Engineering", groups[0].FriendlyName)
|
|
|
|
// A fragment matching neither field returns nothing.
|
|
groups, _, err = groupService.List(t.Context(), "Design", utils.ListRequestOptions{})
|
|
require.NoError(t, err)
|
|
require.Empty(t, groups)
|
|
}
|