Refactor frontend components and enhance API integration
- Updated frontend-nuxt.mdc to specify usage of composables for API calls. - Added new AuthCard and ConfirmModal components for improved UI consistency. - Introduced UserAvatar component for user profile display, replacing previous Gravatar implementation. - Implemented useFormSubmit composable for handling form submissions with loading and error states. - Enhanced vitest.config.ts to include coverage reporting for composables and components. - Removed deprecated useAdminApi and useAuth composables to streamline API interactions. - Updated login and setup pages to utilize new components and composables for better user experience.
This commit is contained in:
@@ -52,9 +52,9 @@ func TestAdminGetUser_Found(t *testing.T) {
|
||||
admin, st := newTestAdmin(t)
|
||||
createUser(t, st, "alice", "pass", app.Auths{app.AUTH_MAP, app.AUTH_UPLOAD})
|
||||
|
||||
auths, found := admin.GetUser(context.Background(), "alice")
|
||||
if !found {
|
||||
t.Fatal("expected found")
|
||||
auths, found, err := admin.GetUser(context.Background(), "alice")
|
||||
if err != nil || !found {
|
||||
t.Fatalf("expected found, err=%v", err)
|
||||
}
|
||||
if !auths.Has(app.AUTH_MAP) {
|
||||
t.Fatal("expected map auth")
|
||||
@@ -63,7 +63,10 @@ func TestAdminGetUser_Found(t *testing.T) {
|
||||
|
||||
func TestAdminGetUser_NotFound(t *testing.T) {
|
||||
admin, _ := newTestAdmin(t)
|
||||
_, found := admin.GetUser(context.Background(), "ghost")
|
||||
_, found, err := admin.GetUser(context.Background(), "ghost")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if found {
|
||||
t.Fatal("expected not found")
|
||||
}
|
||||
@@ -78,9 +81,9 @@ func TestCreateOrUpdateUser_New(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
auths, found := admin.GetUser(ctx, "bob")
|
||||
if !found {
|
||||
t.Fatal("expected user to exist")
|
||||
auths, found, err := admin.GetUser(ctx, "bob")
|
||||
if err != nil || !found {
|
||||
t.Fatalf("expected user to exist, err=%v", err)
|
||||
}
|
||||
if !auths.Has(app.AUTH_MAP) {
|
||||
t.Fatal("expected map auth")
|
||||
@@ -97,9 +100,9 @@ func TestCreateOrUpdateUser_Update(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
auths, found := admin.GetUser(ctx, "alice")
|
||||
if !found {
|
||||
t.Fatal("expected user")
|
||||
auths, found, err := admin.GetUser(ctx, "alice")
|
||||
if err != nil || !found {
|
||||
t.Fatalf("expected user, err=%v", err)
|
||||
}
|
||||
if !auths.Has(app.AUTH_ADMIN) {
|
||||
t.Fatal("expected admin auth after update")
|
||||
@@ -139,9 +142,9 @@ func TestDeleteUser(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
_, found := admin.GetUser(ctx, "alice")
|
||||
if found {
|
||||
t.Fatal("expected user to be deleted")
|
||||
_, found, err := admin.GetUser(ctx, "alice")
|
||||
if err != nil || found {
|
||||
t.Fatalf("expected user to be deleted, err=%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,9 +213,9 @@ func TestMapCRUD(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
mi, found := admin.GetMap(ctx, 1)
|
||||
if !found || mi == nil {
|
||||
t.Fatal("expected map")
|
||||
mi, found, err := admin.GetMap(ctx, 1)
|
||||
if err != nil || !found || mi == nil {
|
||||
t.Fatalf("expected map, err=%v", err)
|
||||
}
|
||||
if mi.Name != "world" {
|
||||
t.Fatalf("expected world, got %s", mi.Name)
|
||||
@@ -285,7 +288,10 @@ func TestWipe(t *testing.T) {
|
||||
|
||||
func TestGetMap_NotFound(t *testing.T) {
|
||||
admin, _ := newTestAdmin(t)
|
||||
_, found := admin.GetMap(context.Background(), 999)
|
||||
_, found, err := admin.GetMap(context.Background(), 999)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if found {
|
||||
t.Fatal("expected not found")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user