forgejo/tests/integration/user_profile_activity_test.go

143 lines
6.8 KiB
Go
Raw Normal View History

Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
// Copyright 2024 The Forgejo Authors. All rights reserved.
feat(ui): better activity messages for cases of private profiles (#5638) * added a message for the case where the user's profile is private but the Public activity is not hidden The activity is still hidden anyway because the profile is private, but previously the message would say: `Your activity is visible to everyone, except for interactions in private spaces...` which I would consider as a flaw of the original implementation. Now it will say: `Your activity is only visible to you and the instance administrators because your profile is private...` * started showing the message for admins that the activity they see should remain private in the case where the whole profile is private, not just the activity tab. Previously it would say: This activity is visible to everyone, but as an administrator you can also see interactions in private spaces.` which I would also consider as a flaw of the original implementation. Now it will say: `This activity is visible to you because you're an administrator, but the user wants it to remain private.` * added test cases * bumped up the number of our GPL-licensed files Preview For both screenshots, Forgejo would previously display misinformation. Change 1: User viewing their private profile, but activity isn't configured as hidden https://codeberg.org/attachments/6659c80c-15dd-48be-a379-db737fd1dd5e Change 2: Admin viewing user's private profile https://codeberg.org/attachments/220da57f-b658-4474-9ad2-049e8438a0af Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5638 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-10-21 14:39:29 +00:00
// SPDX-License-Identifier: GPL-3.0-or-later
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
package integration
import (
"net/http"
"net/url"
feat(ui): better activity messages for cases of private profiles (#5638) * added a message for the case where the user's profile is private but the Public activity is not hidden The activity is still hidden anyway because the profile is private, but previously the message would say: `Your activity is visible to everyone, except for interactions in private spaces...` which I would consider as a flaw of the original implementation. Now it will say: `Your activity is only visible to you and the instance administrators because your profile is private...` * started showing the message for admins that the activity they see should remain private in the case where the whole profile is private, not just the activity tab. Previously it would say: This activity is visible to everyone, but as an administrator you can also see interactions in private spaces.` which I would also consider as a flaw of the original implementation. Now it will say: `This activity is visible to you because you're an administrator, but the user wants it to remain private.` * added test cases * bumped up the number of our GPL-licensed files Preview For both screenshots, Forgejo would previously display misinformation. Change 1: User viewing their private profile, but activity isn't configured as hidden https://codeberg.org/attachments/6659c80c-15dd-48be-a379-db737fd1dd5e Change 2: Admin viewing user's private profile https://codeberg.org/attachments/220da57f-b658-4474-9ad2-049e8438a0af Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5638 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-10-21 14:39:29 +00:00
"strconv"
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
"testing"
feat(ui): better activity messages for cases of private profiles (#5638) * added a message for the case where the user's profile is private but the Public activity is not hidden The activity is still hidden anyway because the profile is private, but previously the message would say: `Your activity is visible to everyone, except for interactions in private spaces...` which I would consider as a flaw of the original implementation. Now it will say: `Your activity is only visible to you and the instance administrators because your profile is private...` * started showing the message for admins that the activity they see should remain private in the case where the whole profile is private, not just the activity tab. Previously it would say: This activity is visible to everyone, but as an administrator you can also see interactions in private spaces.` which I would also consider as a flaw of the original implementation. Now it will say: `This activity is visible to you because you're an administrator, but the user wants it to remain private.` * added test cases * bumped up the number of our GPL-licensed files Preview For both screenshots, Forgejo would previously display misinformation. Change 1: User viewing their private profile, but activity isn't configured as hidden https://codeberg.org/attachments/6659c80c-15dd-48be-a379-db737fd1dd5e Change 2: Admin viewing user's private profile https://codeberg.org/attachments/220da57f-b658-4474-9ad2-049e8438a0af Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5638 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-10-21 14:39:29 +00:00
"code.gitea.io/gitea/modules/structs"
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
"github.com/stretchr/testify/assert"
)
// TestUserProfileActivity ensures visibility and correctness of elements related to activity of a user:
// - RSS feed button (doesn't test `other.ENABLE_FEED:false`)
// - Public activity tab
// - Banner/hint in the tab
// - "Configure" link in the hint
feat(ui): better activity messages for cases of private profiles (#5638) * added a message for the case where the user's profile is private but the Public activity is not hidden The activity is still hidden anyway because the profile is private, but previously the message would say: `Your activity is visible to everyone, except for interactions in private spaces...` which I would consider as a flaw of the original implementation. Now it will say: `Your activity is only visible to you and the instance administrators because your profile is private...` * started showing the message for admins that the activity they see should remain private in the case where the whole profile is private, not just the activity tab. Previously it would say: This activity is visible to everyone, but as an administrator you can also see interactions in private spaces.` which I would also consider as a flaw of the original implementation. Now it will say: `This activity is visible to you because you're an administrator, but the user wants it to remain private.` * added test cases * bumped up the number of our GPL-licensed files Preview For both screenshots, Forgejo would previously display misinformation. Change 1: User viewing their private profile, but activity isn't configured as hidden https://codeberg.org/attachments/6659c80c-15dd-48be-a379-db737fd1dd5e Change 2: Admin viewing user's private profile https://codeberg.org/attachments/220da57f-b658-4474-9ad2-049e8438a0af Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5638 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-10-21 14:39:29 +00:00
// These elements might depend on the following:
// - Profile visibility
// - Public activity visibility
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
func TestUserProfileActivity(t *testing.T) {
onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) {
// This test needs multiple users with different access statuses to check for all possible states
userAdmin := loginUser(t, "user1")
userRegular := loginUser(t, "user2")
// Activity availability should be the same for guest and another non-admin user, so this is not tested separately
userGuest := emptyTestSession(t)
feat(ui): better activity messages for cases of private profiles (#5638) * added a message for the case where the user's profile is private but the Public activity is not hidden The activity is still hidden anyway because the profile is private, but previously the message would say: `Your activity is visible to everyone, except for interactions in private spaces...` which I would consider as a flaw of the original implementation. Now it will say: `Your activity is only visible to you and the instance administrators because your profile is private...` * started showing the message for admins that the activity they see should remain private in the case where the whole profile is private, not just the activity tab. Previously it would say: This activity is visible to everyone, but as an administrator you can also see interactions in private spaces.` which I would also consider as a flaw of the original implementation. Now it will say: `This activity is visible to you because you're an administrator, but the user wants it to remain private.` * added test cases * bumped up the number of our GPL-licensed files Preview For both screenshots, Forgejo would previously display misinformation. Change 1: User viewing their private profile, but activity isn't configured as hidden https://codeberg.org/attachments/6659c80c-15dd-48be-a379-db737fd1dd5e Change 2: Admin viewing user's private profile https://codeberg.org/attachments/220da57f-b658-4474-9ad2-049e8438a0af Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5638 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-10-21 14:39:29 +00:00
// = Public profile, public activity =
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
// Set activity visibility of user2 to public. This is the default, but won't hurt to set it before testing.
testChangeUserActivityVisibility(t, userRegular, "off")
// Verify availability of RSS button and activity tab
testUser2ActivityButtonsAvailability(t, userAdmin, true)
testUser2ActivityButtonsAvailability(t, userRegular, true)
testUser2ActivityButtonsAvailability(t, userGuest, true)
// Verify the hint for all types of users: admin, self, guest
testUser2ActivityVisibility(t, userAdmin, "This activity is visible to everyone, but as an administrator you can also see interactions in private spaces.", true)
hintLink := testUser2ActivityVisibility(t, userRegular, "Your activity is visible to everyone, except for interactions in private spaces. Configure.", true)
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
testUser2ActivityVisibility(t, userGuest, "", true)
// When viewing own profile, the user is offered to configure activity visibility. Verify that the link is correct and works, also check that it links back to the activity tab.
linkCorrect := assert.EqualValues(t, "/user/settings#keep-activity-private", hintLink)
if linkCorrect {
page := NewHTMLParser(t, userRegular.MakeRequest(t, NewRequest(t, "GET", hintLink), http.StatusOK).Body)
activityLink, exists := page.Find(".field:has(.checkbox#keep-activity-private) .help a").Attr("href")
assert.True(t, exists)
assert.EqualValues(t, "/user2?tab=activity", activityLink)
}
feat(ui): better activity messages for cases of private profiles (#5638) * added a message for the case where the user's profile is private but the Public activity is not hidden The activity is still hidden anyway because the profile is private, but previously the message would say: `Your activity is visible to everyone, except for interactions in private spaces...` which I would consider as a flaw of the original implementation. Now it will say: `Your activity is only visible to you and the instance administrators because your profile is private...` * started showing the message for admins that the activity they see should remain private in the case where the whole profile is private, not just the activity tab. Previously it would say: This activity is visible to everyone, but as an administrator you can also see interactions in private spaces.` which I would also consider as a flaw of the original implementation. Now it will say: `This activity is visible to you because you're an administrator, but the user wants it to remain private.` * added test cases * bumped up the number of our GPL-licensed files Preview For both screenshots, Forgejo would previously display misinformation. Change 1: User viewing their private profile, but activity isn't configured as hidden https://codeberg.org/attachments/6659c80c-15dd-48be-a379-db737fd1dd5e Change 2: Admin viewing user's private profile https://codeberg.org/attachments/220da57f-b658-4474-9ad2-049e8438a0af Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5638 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-10-21 14:39:29 +00:00
// = Private profile, but public activity =
// Set profile visibility of user2 to private
testChangeUserProfileVisibility(t, userRegular, structs.VisibleTypePrivate)
// 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.EqualValues(t, "/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)
// Set profile visibility of user2 back to public
testChangeUserProfileVisibility(t, userRegular, structs.VisibleTypePublic)
// = Private acitivty =
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
// Set activity visibility of user2 to private
testChangeUserActivityVisibility(t, userRegular, "on")
// Verify availability of RSS button and activity tab
testUser2ActivityButtonsAvailability(t, userAdmin, true)
testUser2ActivityButtonsAvailability(t, userRegular, true)
testUser2ActivityButtonsAvailability(t, userGuest, false)
// Verify the hint for all types of users: admin, self, guest
testUser2ActivityVisibility(t, userAdmin, "This activity is visible to you because you're an administrator, but the user wants it to remain private.", true)
hintLink = testUser2ActivityVisibility(t, userRegular, "Your activity is only visible to you and the instance administrators. Configure.", true)
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
testUser2ActivityVisibility(t, userGuest, "This user has disabled the public visibility of the activity.", false)
// Verify that Configure link is correct
assert.EqualValues(t, "/user/settings#keep-activity-private", hintLink)
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
})
}
// testChangeUserActivityVisibility allows to easily change visibility of public activity for a user
func testChangeUserActivityVisibility(t *testing.T, session *TestSession, newState string) {
t.Helper()
session.MakeRequest(t, NewRequestWithValues(t, "POST", "/user/settings",
map[string]string{
"_csrf": GetCSRF(t, session, "/user/settings"),
"keep_activity_private": newState,
}), http.StatusSeeOther)
}
feat(ui): better activity messages for cases of private profiles (#5638) * added a message for the case where the user's profile is private but the Public activity is not hidden The activity is still hidden anyway because the profile is private, but previously the message would say: `Your activity is visible to everyone, except for interactions in private spaces...` which I would consider as a flaw of the original implementation. Now it will say: `Your activity is only visible to you and the instance administrators because your profile is private...` * started showing the message for admins that the activity they see should remain private in the case where the whole profile is private, not just the activity tab. Previously it would say: This activity is visible to everyone, but as an administrator you can also see interactions in private spaces.` which I would also consider as a flaw of the original implementation. Now it will say: `This activity is visible to you because you're an administrator, but the user wants it to remain private.` * added test cases * bumped up the number of our GPL-licensed files Preview For both screenshots, Forgejo would previously display misinformation. Change 1: User viewing their private profile, but activity isn't configured as hidden https://codeberg.org/attachments/6659c80c-15dd-48be-a379-db737fd1dd5e Change 2: Admin viewing user's private profile https://codeberg.org/attachments/220da57f-b658-4474-9ad2-049e8438a0af Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5638 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2024-10-21 14:39:29 +00:00
// testChangeUserProfileVisibility allows to easily change visibility of user's profile
func testChangeUserProfileVisibility(t *testing.T, session *TestSession, newValue structs.VisibleType) {
t.Helper()
session.MakeRequest(t, NewRequestWithValues(t, "POST", "/user/settings", map[string]string{
"_csrf": GetCSRF(t, session, "/user/settings"),
"visibility": strconv.Itoa(int(newValue)),
}), http.StatusSeeOther)
}
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
// testUser2ActivityVisibility checks visibility of UI elements on /<user>?tab=activity
// It also returns the account visibility link if it is present on the page.
func testUser2ActivityVisibility(t *testing.T, session *TestSession, hint string, availability bool) string {
t.Helper()
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
response := session.MakeRequest(t, NewRequest(t, "GET", "/user2?tab=activity"), http.StatusOK)
page := NewHTMLParser(t, response.Body)
// Check hint visibility and correctness
testSelectorEquals(t, page, "#visibility-hint", hint)
hintLink, hintLinkExists := page.Find("#visibility-hint a").Attr("href")
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
// Check that the hint aligns with the actual feed availability
assert.EqualValues(t, availability, page.Find("#activity-feed").Length() > 0)
// Check availability of RSS feed button too
assert.EqualValues(t, availability, page.Find("#profile-avatar-card a[href='/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())
if hintLinkExists {
return hintLink
}
return ""
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
}
// testUser2ActivityButtonsAvailability checks visibility of Public activity tab on main profile page
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
func testUser2ActivityButtonsAvailability(t *testing.T, session *TestSession, buttons bool) {
t.Helper()
Better logic for showing user feed/public activity elements (#4189) There are a few changes of template logic which defines when which elements should be shown on profile page. The motivation is to have the elements when needed and don't when they're not relevant. ## Changes ### RSS button Now displayed if: * feeds are enabled AND one or more of: * the current user is an admin * the current user is viewing their profile * the activity is publicly available So, basically in cases when the .rss feed actually contains any events. Before this change this button was constantly shown and was giving an empty feed if it was unavailable. ### Public activity tab The tab is displayed if: * the current user is an admin * the current user is viewing their profile * the activity is publicly available * the current tab is this exact tab, for example, in case it was accessed by adding `?tab=activity` to the URL, so that the UI is not broken w/o a highlighted tab So, this tab is not displayed when it's not going to contain any information, but still can be accessed. ### Banner "This user has disabled the public visibility of the activity." For admins: * always show the big blue banner to warn that sharing a screenshot of this publicly is bad idea For self: * always display a little note about the current visibility status with a "Change" link For others: * only display a little note to explain why the activity is not shown ### Heatmap and activity feed Elements are only displayed when relevant, instead of keeping empty leftovers, for easier testing. This template change is also covered by test. **Everything in this Changes section is covered by test unless I forgot something.** ## Preview There's obviously too many states to screenshot, here are highlights: ![](https://codeberg.org/attachments/47559531-9bcd-46c0-90d4-8b51512da752) _Warning admin for why they're seeing the information_ ![](https://codeberg.org/attachments/3107bf62-955b-4fe5-bce3-6305a928afe1) _Viewing self - private_ ![](https://codeberg.org/attachments/afb63ead-fb0b-4fc7-9d8b-c6c09e9ae62b) _Viewing self - public_ ![](https://codeberg.org/attachments/df3c090a-7490-4827-b33b-771fd4fa0a9f) _Don't have access to the information_ ![](https://codeberg.org/attachments/2dd2b0ac-2fe0-4453-aa4b-e91fd08f4411) _The tab is not shown when the activity can't be accessed_ ![](https://codeberg.org/attachments/ed4c61de-b3b7-4523-b92b-bc76e1d8b7c5) _Can't access the RSS feed_ ![](https://codeberg.org/attachments/5a27f2be-d79c-4fb4-85a5-758348398f1b) _Can access the RSS feed_ Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4189 Reviewed-by: Otto <otto@codeberg.org>
2024-06-24 08:19:11 +00:00
response := session.MakeRequest(t, NewRequest(t, "GET", "/user2"), http.StatusOK)
page := NewHTMLParser(t, response.Body)
assert.EqualValues(t, buttons, page.Find("overflow-menu .item[href='/user2?tab=activity']").Length() > 0)
}