From 67aca34124450c37a63ee21f4878d09d2cf3fad0 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 3 Jun 2026 21:19:48 +0200 Subject: [PATCH] test(api/v2): port full v1 admin projects coverage Bring TestHumaAdminProjects to 1:1 parity with v1 TestAdmin_ListProjects by asserting owner hydration ("username":"user1", never "owner":null) and project field presence ("id":, "title":) on the response body, in addition to the existing gate personas and ownership/archived visibility cardinality checks. --- pkg/webtests/huma_admin_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/webtests/huma_admin_test.go b/pkg/webtests/huma_admin_test.go index 36f25de15..37531298b 100644 --- a/pkg/webtests/huma_admin_test.go +++ b/pkg/webtests/huma_admin_test.go @@ -88,6 +88,15 @@ func TestHumaAdminProjects(t *testing.T) { assert.True(t, ids[6], "expected project 6 in the admin list, got items %v", ids) // Project 22 is archived, proving the list includes archived projects. assert.True(t, ids[22], "expected archived project 22 in the admin list, got items %v", ids) + + // Ported from v1 TestAdmin_ListProjects (admin_test.go:222-226): the + // response body must carry project fields and a hydrated owner. + body := res.Body.String() + assert.Contains(t, body, `"id":`) + assert.Contains(t, body, `"title":`) + // Owner is xorm:"-" and must be hydrated explicitly (project 1 is owned by user1). + assert.Contains(t, body, `"username":"user1"`) + assert.NotContains(t, body, `"owner":null`) }) t.Run("unauthenticated caller gets 401", func(t *testing.T) {