mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-03-25 14:03:05 -04:00
Replaced dropdowns in the navbar with JS-less ones from https://codeberg.org/forgejo/forgejo/pulls/7906. Also made some changes to the dropdown component: * fixed variable name * painted backgrounds (hover, focus) are now consistently applied to the actual interactive items (`<a>`, `<button>`), not to `<li>`. This is consistent with how backgrounds are conditionally applied to pre-selected (`.active`) items and is better, as it allows to place additional things to `<li>`... * ...`<hr>` can now be placed in some `<li>` instead of requiring splitting into multiple `<ul>`. This is simpler in code and I am guessing this should be better for a11y as screen readers can cast one continuous list instead of multiple ones. But have no hard proof that this is actually better. My main motivation was to avoid ugly mistake-prone tmpl logic where unconditional `<ul>` was getting closed and reopened inside of a condition. I should note that on mobile all items, including these dropdowns, are hidden in another dropdown, and it stays JS-dependand for now. So this PR only makes this part of the UI JS-less for desktop. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10025 Reviewed-by: Robert Wolff <mahlzahn@posteo.de> Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: 0ko <0ko@noreply.codeberg.org> Co-committed-by: 0ko <0ko@noreply.codeberg.org>
34 lines
1 KiB
Go
34 lines
1 KiB
Go
// Copyright 2024-2025 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package integration
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"forgejo.org/models/unittest"
|
|
"forgejo.org/modules/translation"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// This test verifies common elements that are visible on all pages but most
|
|
// likely to be first seen on `/`
|
|
func TestCommonNavigationElements(t *testing.T) {
|
|
require.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
session := loginUser(t, "user1")
|
|
locale := translation.NewLocale("en-US")
|
|
|
|
response := session.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK)
|
|
page := NewHTMLParser(t, response.Body)
|
|
|
|
// After footer: index.js
|
|
page.AssertElement(t, "script[src^='/assets/js/index.js']", true)
|
|
onerror, _ := page.Find("script[src^='/assets/js/index.js']").Attr("onerror")
|
|
expected := fmt.Sprintf("alert('%s'.replace('{path}', this.src))", locale.TrString("alert.asset_load_failed"))
|
|
assert.Equal(t, expected, onerror)
|
|
}
|