loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(ui): prepend AppSubURL to visibility hint URLs (#7379)

- If configured, add `AppSubUrl` to the visibility hint URLs shown to the user on the profile activity page.
- Resolves https://codeberg.org/forgejo/forgejo/issues/7327
- Integration testing adjusted.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7379
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>

authored by

Gusted
Gusted
and committed by
0ko
51caba69 d59495a4

+11 -8
+3 -3
templates/user/profile.tmpl
··· 12 12 {{if eq .SignedUserID .ContextUser.ID}} 13 13 <p id="visibility-hint"> 14 14 {{if .ContextUser.KeepActivityPrivate}} 15 - {{ctx.Locale.Tr "user.public_activity.visibility_hint.self_private" "/user/settings#keep-activity-private"}} 15 + {{ctx.Locale.Tr "user.public_activity.visibility_hint.self_private" (print AppSubUrl "/user/settings#keep-activity-private")}} 16 16 {{else}} 17 17 {{if eq .ContextUser.Visibility 2}} 18 - {{ctx.Locale.Tr "user.public_activity.visibility_hint.self_private_profile" "/user/settings#visibility-setting"}} 18 + {{ctx.Locale.Tr "user.public_activity.visibility_hint.self_private_profile" (print AppSubUrl "/user/settings#visibility-setting")}} 19 19 {{else}} 20 - {{ctx.Locale.Tr "user.public_activity.visibility_hint.self_public" "/user/settings#keep-activity-private"}} 20 + {{ctx.Locale.Tr "user.public_activity.visibility_hint.self_public" (print AppSubUrl "/user/settings#keep-activity-private")}} 21 21 {{end}} 22 22 {{end}} 23 23 </p>
+8 -5
tests/integration/user_profile_activity_test.go
··· 8 8 "strconv" 9 9 "testing" 10 10 11 + "forgejo.org/modules/setting" 11 12 "forgejo.org/modules/structs" 13 + "forgejo.org/modules/test" 12 14 "forgejo.org/tests" 13 15 14 16 "github.com/stretchr/testify/assert" ··· 23 25 // - Profile visibility 24 26 // - Public activity visibility 25 27 func TestUserProfileActivity(t *testing.T) { 28 + defer test.MockVariableValue(&setting.AppSubURL, "/sub")() 26 29 defer tests.PrepareTestEnv(t)() 27 30 // This test needs multiple users with different access statuses to check for all possible states 28 31 userAdmin := loginUser(t, "user1") ··· 52 55 53 56 // When profile activity is configured as public, but the profile is private, tell the user about this and link to visibility settings. 54 57 hintLink := testUser2ActivityVisibility(t, userRegular, "Your activity is only visible to you and the instance administrators because your profile is private. Configure.", true) 55 - assert.Equal(t, "/user/settings#visibility-setting", hintLink) 58 + assert.Equal(t, "/sub/user/settings#visibility-setting", hintLink) 56 59 57 60 // When the profile is private, tell the admin about this. 58 61 testUser2ActivityVisibility(t, userAdmin, "This activity is visible to you because you're an administrator, but the user wants it to remain private.", true) ··· 76 79 testUser2ActivityVisibility(t, userGuest, "This user has disabled the public visibility of the activity.", false) 77 80 78 81 // Verify that Configure link is correct 79 - assert.Equal(t, "/user/settings#keep-activity-private", hintLink) 82 + assert.Equal(t, "/sub/user/settings#keep-activity-private", hintLink) 80 83 } 81 84 82 85 // testChangeUserActivityVisibility allows to easily change visibility of public activity for a user ··· 112 115 assert.Equal(t, availability, page.Find("#activity-feed").Length() > 0) 113 116 114 117 // Check availability of RSS feed button too 115 - assert.Equal(t, availability, page.Find("#profile-avatar-card a[href='/user2.rss']").Length() > 0) 118 + assert.Equal(t, availability, page.Find("#profile-avatar-card a[href='/sub/user2.rss']").Length() > 0) 116 119 117 120 // Check that the current tab is displayed and is active regardless of it's actual availability 118 121 // For example, on /<user> it wouldn't be available to guest, but it should be still present on /<user>?tab=activity 119 - assert.Positive(t, page.Find("overflow-menu .active.item[href='/user2?tab=activity']").Length()) 122 + assert.Positive(t, page.Find("overflow-menu .active.item[href='/sub/user2?tab=activity']").Length()) 120 123 if hintLinkExists { 121 124 return hintLink 122 125 } ··· 128 131 t.Helper() 129 132 response := session.MakeRequest(t, NewRequest(t, "GET", "/user2"), http.StatusOK) 130 133 page := NewHTMLParser(t, response.Body) 131 - assert.Equal(t, buttons, page.Find("overflow-menu .item[href='/user2?tab=activity']").Length() > 0) 134 + assert.Equal(t, buttons, page.Find("overflow-menu .item[href='/sub/user2?tab=activity']").Length() > 0) 132 135 }