mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-04-24 21:06:57 -04:00
feat: improve devtest, link to it from user menu (#10263)
Addition to the user menu in navbar:
* display a link to `/devtest` if the instance run mode is dev instead of prod
* I think this is useful because:
* devtest pages are in general useful in development, but are not easy to discover by newcomers
* if the instance uses incorrect run mode, this entry should annoy it's admin into fixing the issue
Improvements to `/devtest`:
* fix error pages links
* add a few headers and explanation for what this page is for
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10263
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-committed-by: 0ko <0ko@noreply.codeberg.org>
This commit is contained in:
parent
8ee4a7d658
commit
d4068e6bcf
3 changed files with 40 additions and 10 deletions
|
|
@ -194,8 +194,11 @@
|
|||
{{ctx.Locale.Tr "help"}}
|
||||
</a>
|
||||
</li>
|
||||
{{if .IsAdmin}}
|
||||
{{$showDevtest := not .RunModeIsProd}}
|
||||
{{if or .IsAdmin $showDevtest}}
|
||||
<hr>
|
||||
{{end}}
|
||||
{{if .IsAdmin}}
|
||||
<li>
|
||||
<a {{if .PageIsAdmin}}class="active"{{end}} href="{{AppSubUrl}}/admin">
|
||||
{{svg "octicon-server"}}
|
||||
|
|
@ -203,8 +206,16 @@
|
|||
</a>
|
||||
</li>
|
||||
{{end}}
|
||||
{{if $showDevtest}}
|
||||
<li>
|
||||
<a {{if .PageIsAdmin}}class="active"{{end}} href="{{AppSubUrl}}/devtest">
|
||||
{{svg "octicon-beaker"}}
|
||||
Development pages
|
||||
</a>
|
||||
</li>
|
||||
{{end}}
|
||||
<hr>
|
||||
<li>
|
||||
<hr>
|
||||
<a class="link-action" href data-url="{{AppSubUrl}}/user/logout">
|
||||
{{svg "octicon-sign-out"}}
|
||||
{{ctx.Locale.Tr "sign_out"}}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,25 @@
|
|||
{{template "base/head" .}}
|
||||
|
||||
<div role="main" class="page-content ui container">
|
||||
<ul>
|
||||
{{range .SubNames}}
|
||||
<li><a href="{{AppSubUrl}}/devtest/{{.}}">{{.}}</a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
<h1>Development pages</h1>
|
||||
|
||||
<p>Various pages that may be helpful in development or testing</p>
|
||||
|
||||
<article>
|
||||
<h2>Components</h2>
|
||||
<ul>
|
||||
{{range .SubNames}}
|
||||
<li><a href="{{AppSubUrl}}/devtest/{{.}}">{{.}}</a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
<h2>Error pages</h2>
|
||||
<ul>
|
||||
<li><a href="./error/404">Not found</a></li>
|
||||
<li><a href="./error/413">Quota exhaustion</a></li>
|
||||
<li><a href="./error/500">Server error</a></li>
|
||||
<li><a href="{{AppSubUrl}}/devtest/error/404">Not found</a></li>
|
||||
<li><a href="{{AppSubUrl}}/devtest/error/413">Quota exhaustion</a></li>
|
||||
<li><a href="{{AppSubUrl}}/devtest/error/500">Server error</a></li>
|
||||
</ul>
|
||||
</article>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -71,9 +71,18 @@ func TestNavbarItems(t *testing.T) {
|
|||
page.AssertElement(t, `details.dropdown a[href$="?tab=stars"]`, false)
|
||||
})
|
||||
|
||||
t.Run(`User dropdown - instance in dev mode`, func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
defer test.MockVariableValue(&setting.IsProd, false)()
|
||||
|
||||
page := NewHTMLParser(t, regularUser.MakeRequest(t, NewRequest(t, "GET", testPage), http.StatusOK).Body)
|
||||
page.AssertElement(t, `details.dropdown a[href="/devtest"]`, true)
|
||||
})
|
||||
|
||||
t.Run(`User dropdown - default conditions`, func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
// What regular user sees
|
||||
assertions := []struct {
|
||||
selector string
|
||||
exists bool
|
||||
|
|
@ -83,6 +92,7 @@ func TestNavbarItems(t *testing.T) {
|
|||
{`details.dropdown a[href="/notifications/subscriptions"]`, true},
|
||||
{`details.dropdown a[href="/user/settings"]`, true},
|
||||
{`details.dropdown a[href="/admin"]`, false},
|
||||
{`details.dropdown a[href="/devtest"]`, false},
|
||||
{`details.dropdown a[href="https://forgejo.org/docs/latest/"]`, true},
|
||||
{`details.dropdown a[data-url="/user/logout"]`, true},
|
||||
}
|
||||
|
|
@ -91,6 +101,7 @@ func TestNavbarItems(t *testing.T) {
|
|||
page.AssertElement(t, assertion.selector, assertion.exists)
|
||||
}
|
||||
|
||||
// What admin user sees
|
||||
assertions = []struct {
|
||||
selector string
|
||||
exists bool
|
||||
|
|
@ -100,6 +111,7 @@ func TestNavbarItems(t *testing.T) {
|
|||
{`details.dropdown a[href="/notifications/subscriptions"]`, true},
|
||||
{`details.dropdown a[href="/user/settings"]`, true},
|
||||
{`details.dropdown a[href="/admin"]`, true},
|
||||
{`details.dropdown a[href="/devtest"]`, false},
|
||||
{`details.dropdown a[href="https://forgejo.org/docs/latest/"]`, true},
|
||||
{`details.dropdown a[data-url="/user/logout"]`, true},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue