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>
This commit is contained in:
parent
d59495a4db
commit
51caba694a
2 changed files with 11 additions and 8 deletions
|
@ -12,12 +12,12 @@
|
|||
{{if eq .SignedUserID .ContextUser.ID}}
|
||||
<p id="visibility-hint">
|
||||
{{if .ContextUser.KeepActivityPrivate}}
|
||||
{{ctx.Locale.Tr "user.public_activity.visibility_hint.self_private" "/user/settings#keep-activity-private"}}
|
||||
{{ctx.Locale.Tr "user.public_activity.visibility_hint.self_private" (print AppSubUrl "/user/settings#keep-activity-private")}}
|
||||
{{else}}
|
||||
{{if eq .ContextUser.Visibility 2}}
|
||||
{{ctx.Locale.Tr "user.public_activity.visibility_hint.self_private_profile" "/user/settings#visibility-setting"}}
|
||||
{{ctx.Locale.Tr "user.public_activity.visibility_hint.self_private_profile" (print AppSubUrl "/user/settings#visibility-setting")}}
|
||||
{{else}}
|
||||
{{ctx.Locale.Tr "user.public_activity.visibility_hint.self_public" "/user/settings#keep-activity-private"}}
|
||||
{{ctx.Locale.Tr "user.public_activity.visibility_hint.self_public" (print AppSubUrl "/user/settings#keep-activity-private")}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
</p>
|
||||
|
|
|
@ -8,7 +8,9 @@ import (
|
|||
"strconv"
|
||||
"testing"
|
||||
|
||||
"forgejo.org/modules/setting"
|
||||
"forgejo.org/modules/structs"
|
||||
"forgejo.org/modules/test"
|
||||
"forgejo.org/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -23,6 +25,7 @@ import (
|
|||
// - Profile visibility
|
||||
// - Public activity visibility
|
||||
func TestUserProfileActivity(t *testing.T) {
|
||||
defer test.MockVariableValue(&setting.AppSubURL, "/sub")()
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
// This test needs multiple users with different access statuses to check for all possible states
|
||||
userAdmin := loginUser(t, "user1")
|
||||
|
@ -52,7 +55,7 @@ func TestUserProfileActivity(t *testing.T) {
|
|||
|
||||
// When profile activity is configured as public, but the profile is private, tell the user about this and link to visibility settings.
|
||||
hintLink := testUser2ActivityVisibility(t, userRegular, "Your activity is only visible to you and the instance administrators because your profile is private. Configure.", true)
|
||||
assert.Equal(t, "/user/settings#visibility-setting", hintLink)
|
||||
assert.Equal(t, "/sub/user/settings#visibility-setting", hintLink)
|
||||
|
||||
// When the profile is private, tell the admin about this.
|
||||
testUser2ActivityVisibility(t, userAdmin, "This activity is visible to you because you're an administrator, but the user wants it to remain private.", true)
|
||||
|
@ -76,7 +79,7 @@ func TestUserProfileActivity(t *testing.T) {
|
|||
testUser2ActivityVisibility(t, userGuest, "This user has disabled the public visibility of the activity.", false)
|
||||
|
||||
// Verify that Configure link is correct
|
||||
assert.Equal(t, "/user/settings#keep-activity-private", hintLink)
|
||||
assert.Equal(t, "/sub/user/settings#keep-activity-private", hintLink)
|
||||
}
|
||||
|
||||
// testChangeUserActivityVisibility allows to easily change visibility of public activity for a user
|
||||
|
@ -112,11 +115,11 @@ func testUser2ActivityVisibility(t *testing.T, session *TestSession, hint string
|
|||
assert.Equal(t, availability, page.Find("#activity-feed").Length() > 0)
|
||||
|
||||
// Check availability of RSS feed button too
|
||||
assert.Equal(t, availability, page.Find("#profile-avatar-card a[href='/user2.rss']").Length() > 0)
|
||||
assert.Equal(t, availability, page.Find("#profile-avatar-card a[href='/sub/user2.rss']").Length() > 0)
|
||||
|
||||
// Check that the current tab is displayed and is active regardless of it's actual availability
|
||||
// For example, on /<user> it wouldn't be available to guest, but it should be still present on /<user>?tab=activity
|
||||
assert.Positive(t, page.Find("overflow-menu .active.item[href='/user2?tab=activity']").Length())
|
||||
assert.Positive(t, page.Find("overflow-menu .active.item[href='/sub/user2?tab=activity']").Length())
|
||||
if hintLinkExists {
|
||||
return hintLink
|
||||
}
|
||||
|
@ -128,5 +131,5 @@ func testUser2ActivityButtonsAvailability(t *testing.T, session *TestSession, bu
|
|||
t.Helper()
|
||||
response := session.MakeRequest(t, NewRequest(t, "GET", "/user2"), http.StatusOK)
|
||||
page := NewHTMLParser(t, response.Body)
|
||||
assert.Equal(t, buttons, page.Find("overflow-menu .item[href='/user2?tab=activity']").Length() > 0)
|
||||
assert.Equal(t, buttons, page.Find("overflow-menu .item[href='/sub/user2?tab=activity']").Length() > 0)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue