From 9bb7b3fbdd19d702614453cd0210efffd801bc40 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 1 Mar 2024 10:37:17 +0100 Subject: [PATCH] Add a new test for "Unspecified" pronouns Signed-off-by: Gergely Nagy --- tests/integration/user_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/integration/user_test.go b/tests/integration/user_test.go index 11df76034e..3255f68e34 100644 --- a/tests/integration/user_test.go +++ b/tests/integration/user_test.go @@ -589,4 +589,25 @@ func TestUserPronouns(t *testing.T) { assert.Equal(t, newPronouns, user2New.Pronouns) }) }) + + t.Run("unspecified", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + // Set the pronouns to Unspecified (an empty string) via the API + pronouns := "" + req := NewRequestWithJSON(t, "PATCH", "/api/v1/admin/users/user2", &api.EditUserOption{ + LoginName: "user2", + SourceID: 0, + Pronouns: &pronouns, + }).AddTokenAuth(adminToken) + MakeRequest(t, req, http.StatusOK) + + // Verify that the profile page does not display any pronouns, nor the separator + req = NewRequest(t, "GET", "/user2") + resp := MakeRequest(t, req, http.StatusOK) + htmlDoc := NewHTMLParser(t, resp.Body) + + userName := strings.TrimSpace(htmlDoc.Find(".profile-avatar-name .username").Text()) + assert.Contains(t, userName, "user2") + }) }