1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-05 01:45:22 +02:00

feat(ui): show size constraints of custom avatar (#7998)

Closes #7862
This adds a note for the user profile settings page about the avatar constraints.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7998
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Thomas Böhler <witcher@wiredspace.de>
Co-committed-by: Thomas Böhler <witcher@wiredspace.de>
This commit is contained in:
Thomas Böhler 2025-06-14 16:35:50 +02:00 committed by 0ko
parent 6cdf2cd66e
commit 53d5e6d754
10 changed files with 65 additions and 0 deletions

View file

@ -155,3 +155,51 @@ func TestSettingSecurityAuthSource(t *testing.T) {
assert.Contains(t, resp.Body.String(), `gitlab-active`)
assert.Contains(t, resp.Body.String(), `gitlab-inactive`)
}
func TestUserAvatarSizeNotice(t *testing.T) {
defer tests.PrepareTestEnv(t)()
session := loginUser(t, "user1")
req := NewRequest(t, "GET", "/user/settings")
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
assert.Contains(t,
htmlDoc.doc.Find("form div:has(input#new-avatar) .help").Text(),
"Custom avatar may not exceed 1 MiB in size or be larger than 4096x4096 pixels")
}
func TestRepoAvatarSizeNotice(t *testing.T) {
defer tests.PrepareTestEnv(t)()
session := loginUser(t, "user2")
req := NewRequest(t, "GET", "/user2/repo1/settings")
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
assert.Contains(t,
htmlDoc.doc.Find("form div:has(input[name=\"avatar\"]) .help").Text(),
"Custom avatar may not exceed 1 MiB in size or be larger than 4096x4096 pixels")
}
func TestOrgAvatarSizeNotice(t *testing.T) {
defer tests.PrepareTestEnv(t)()
session := loginUser(t, "user2")
req := NewRequest(t, "GET", "/org/org3/settings")
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
assert.Contains(t,
htmlDoc.doc.Find("form div:has(input[name=\"avatar\"]) .help").Text(),
"Custom avatar may not exceed 1 MiB in size or be larger than 4096x4096 pixels")
}
func TestAdminAvatarSizeNotice(t *testing.T) {
defer tests.PrepareTestEnv(t)()
session := loginUser(t, "user1")
req := NewRequest(t, "GET", "/admin/users/2/edit")
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
assert.Contains(t,
htmlDoc.doc.Find("form div:has(input[name=\"avatar\"]) .help").Text(),
"Custom avatar may not exceed 1 MiB in size or be larger than 4096x4096 pixels")
}