mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-20 16:10:50 +00:00
feat(ui): messages for empty usercards (#7947)
Show a message about list being empty, so the page doesn't look broken-ish empty. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7947 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Otto <otto@codeberg.org> Co-authored-by: 0ko <0ko@noreply.codeberg.org> Co-committed-by: 0ko <0ko@noreply.codeberg.org>
This commit is contained in:
parent
2b30c83a0c
commit
765e7bd1b6
6 changed files with 74 additions and 30 deletions
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func testRepoStarringOrWatching(t *testing.T, action, listURI string) {
|
||||
func testRepoStarringOrWatching(t *testing.T, action, listURI string, expectEmpty bool) {
|
||||
t.Helper()
|
||||
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
@ -50,6 +50,12 @@ func testRepoStarringOrWatching(t *testing.T, action, listURI string) {
|
|||
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||
htmlDoc.AssertElement(t, ".user-cards .list .card > a[href='/user5']", true)
|
||||
|
||||
if expectEmpty {
|
||||
// Verify which user-cards elements are present
|
||||
htmlDoc.AssertElement(t, ".user-cards > .list", true)
|
||||
htmlDoc.AssertElement(t, ".user-cards > div", false)
|
||||
}
|
||||
|
||||
// Unstar/unwatch the repo as user5
|
||||
req = NewRequestWithValues(t, "POST", fmt.Sprintf("/user2/repo1/action/%s", oppositeAction), map[string]string{
|
||||
"_csrf": GetCSRF(t, session, "/user2/repo1"),
|
||||
|
@ -73,15 +79,22 @@ func testRepoStarringOrWatching(t *testing.T, action, listURI string) {
|
|||
|
||||
// Verify that "user5" is not among the stargazers/watchers
|
||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||
htmlDoc.AssertElement(t, ".user-cards .list .item.ui.segment > a[href='/user5']", false)
|
||||
htmlDoc.AssertElement(t, ".user-cards .list .item.ui.segment > a[href='/user2']", false)
|
||||
|
||||
if expectEmpty {
|
||||
// Verify which user-cards elements are present
|
||||
htmlDoc.AssertElement(t, ".user-cards > .list", false)
|
||||
htmlDoc.AssertElement(t, ".user-cards > div", true)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRepoStarUnstarUI(t *testing.T) {
|
||||
testRepoStarringOrWatching(t, "star", "stars")
|
||||
testRepoStarringOrWatching(t, "star", "stars", true)
|
||||
}
|
||||
|
||||
func TestRepoWatchUnwatchUI(t *testing.T) {
|
||||
testRepoStarringOrWatching(t, "watch", "watchers")
|
||||
testRepoStarringOrWatching(t, "watch", "watchers", false)
|
||||
// Empty list state is not checked because repo is watched by many users
|
||||
}
|
||||
|
||||
func TestDisabledStars(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue