mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
fix(ui): do not wrongly highlight devtest link in navbar menu (#10357)
Fix copypaste induced bug. Followup to https://codeberg.org/forgejo/forgejo/pulls/10263. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10357 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: floss4good <floss4good@noreply.codeberg.org>
This commit is contained in:
parent
ff4038970d
commit
fe53015fe4
2 changed files with 14 additions and 1 deletions
|
|
@ -208,7 +208,7 @@
|
|||
{{end}}
|
||||
{{if $showDevtest}}
|
||||
<li>
|
||||
<a {{if .PageIsAdmin}}class="active"{{end}} href="{{AppSubUrl}}/devtest">
|
||||
<a href="{{AppSubUrl}}/devtest">
|
||||
{{svg "octicon-beaker"}}
|
||||
Development pages
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,9 @@ func TestNavbarItems(t *testing.T) {
|
|||
|
||||
page := NewHTMLParser(t, regularUser.MakeRequest(t, NewRequest(t, "GET", testPage), http.StatusOK).Body)
|
||||
page.AssertElement(t, `details.dropdown a[href="/devtest"]`, true)
|
||||
|
||||
testNavbarUserMenuActiveItem(t, regularUser, "/user/settings")
|
||||
testNavbarUserMenuActiveItem(t, adminUser, "/admin")
|
||||
})
|
||||
|
||||
t.Run(`User dropdown - default conditions`, func(t *testing.T) {
|
||||
|
|
@ -119,5 +122,15 @@ func TestNavbarItems(t *testing.T) {
|
|||
for _, assertion := range assertions {
|
||||
page.AssertElement(t, assertion.selector, assertion.exists)
|
||||
}
|
||||
|
||||
testNavbarUserMenuActiveItem(t, regularUser, "/user/settings")
|
||||
testNavbarUserMenuActiveItem(t, adminUser, "/admin")
|
||||
})
|
||||
}
|
||||
|
||||
// When visiting certain pages, the corresponding entry of user menu is highlighted
|
||||
func testNavbarUserMenuActiveItem(t *testing.T, session *TestSession, url string) {
|
||||
page := NewHTMLParser(t, session.MakeRequest(t, NewRequest(t, "GET", url), http.StatusOK).Body)
|
||||
// AssertElement will only pass if there's just one such element
|
||||
page.AssertElement(t, "#navbar details.dropdown li > .active", true)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue