forgejo/tests/integration/api_nodeinfo_test.go

41 lines
1 KiB
Go
Raw Normal View History

// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package integration
import (
"context"
"net/http"
"net/url"
"testing"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
2022-06-20 01:48:17 +02:00
"code.gitea.io/gitea/routers"
"github.com/stretchr/testify/assert"
)
func TestNodeinfo(t *testing.T) {
2022-06-20 01:48:17 +02:00
setting.Federation.Enabled = true
c = routers.NormalRoutes(context.TODO())
2022-06-20 01:48:17 +02:00
defer func() {
setting.Federation.Enabled = false
c = routers.NormalRoutes(context.TODO())
2022-06-20 01:48:17 +02:00
}()
2022-06-20 01:48:17 +02:00
onGiteaRun(t, func(*testing.T, *url.URL) {
req := NewRequestf(t, "GET", "/api/v1/nodeinfo")
resp := MakeRequest(t, req, http.StatusOK)
VerifyJSONSchema(t, resp, "nodeinfo_2.1.json")
var nodeinfo api.NodeInfo
DecodeJSON(t, resp, &nodeinfo)
assert.True(t, nodeinfo.OpenRegistrations)
[BRANDING] Update nodeinfo branding - Change the values for the nodeinfo API, to use branded values. - Resolves https://codeberg.org/forgejo/forgejo/issues/257 (cherry picked from commit 4608c57688d8b12dbc265dd21bfe7cd269efb116) (cherry picked from commit e837e8a52943f803a40cd0151e24f7fe8edb11ec) (cherry picked from commit 6601328d3ce9b57dbaa768dd2d41295293ff94f9) (cherry picked from commit c6be21d4870e6b748a85f0da19bd4b717875b224) (cherry picked from commit 5adc6ffee2e6f1af72039747df809aa6ebd2198f) (cherry picked from commit 2ff8d166ac1e56ab7a349d70f875bd2ae9763418) (cherry picked from commit b6a90e7e5af0e998cbbf1fc1edb901ae31090999) (cherry picked from commit d1089e706cda009a6a23462adf498fd24a609b0a) Conflicts: tests/integration/api_nodeinfo_test.go (cherry picked from commit 7a29df737d979abed4d37f084e3a92ee788d2c6e) (cherry picked from commit 3655a30c60229167bc007e139d0461a5648741d5) (cherry picked from commit c90d61141016ffbbaaa6b4f4657dacf5446f30c0) (cherry picked from commit 0274bd8860bd00de628fba990e42bf7385ddf5b9) (cherry picked from commit fdb786b71decd1c968f7c473c94463140f192fc3) (cherry picked from commit 4f08f100a19886210b89d1cacfd09e6db0e48fb7) (cherry picked from commit 56a27118227521fae93e052bb77265fb10c6dcf8) (cherry picked from commit 3b2cfa452df0d2651a75c5e3fcd442c38acff109) (cherry picked from commit 773ddcf956a897bbaa75aff3087f8a64b254239c) (cherry picked from commit b3c12e6bccb4ea65f7fa1ab38abaa313013aac9d) (cherry picked from commit 1315177082a6b32cb04719124d76105ed656d09f) (cherry picked from commit 3f1007795ce769ce16f2c74454ad4459723378cf) (cherry picked from commit 352bda0147a02c81f1a59412a0ab9f34993cb127) (cherry picked from commit 3d8c153ded7547f2343d0da6051b296c9265f286)
2023-02-04 11:20:21 +01:00
assert.Equal(t, "forgejo", nodeinfo.Software.Name)
assert.Equal(t, 25, nodeinfo.Usage.Users.Total)
Scoped labels (#22585) Add a new "exclusive" option per label. This makes it so that when the label is named `scope/name`, no other label with the same `scope/` prefix can be set on an issue. The scope is determined by the last occurence of `/`, so for example `scope/alpha/name` and `scope/beta/name` are considered to be in different scopes and can coexist. Exclusive scopes are not enforced by any database rules, however they are enforced when editing labels at the models level, automatically removing any existing labels in the same scope when either attaching a new label or replacing all labels. In menus use a circle instead of checkbox to indicate they function as radio buttons per scope. Issue filtering by label ensures that only a single scoped label is selected at a time. Clicking with alt key can be used to remove a scoped label, both when editing individual issues and batch editing. Label rendering refactor for consistency and code simplification: * Labels now consistently have the same shape, emojis and tooltips everywhere. This includes the label list and label assignment menus. * In label list, show description below label same as label menus. * Don't use exactly black/white text colors to look a bit nicer. * Simplify text color computation. There is no point computing luminance in linear color space, as this is a perceptual problem and sRGB is closer to perceptually linear. * Increase height of label assignment menus to show more labels. Showing only 3-4 labels at a time leads to a lot of scrolling. * Render all labels with a new RenderLabel template helper function. Label creation and editing in multiline modal menu: * Change label creation to open a modal menu like label editing. * Change menu layout to place name, description and colors on separate lines. * Don't color cancel button red in label editing modal menu. * Align text to the left in model menu for better readability and consistent with settings layout elsewhere. Custom exclusive scoped label rendering: * Display scoped label prefix and suffix with slightly darker and lighter background color respectively, and a slanted edge between them similar to the `/` symbol. * In menus exclusive labels are grouped with a divider line. --------- Co-authored-by: Yarden Shoham <hrsi88@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 20:17:39 +01:00
assert.Equal(t, 18, nodeinfo.Usage.LocalPosts)
assert.Equal(t, 2, nodeinfo.Usage.LocalComments)
})
}