Compare commits
10 commits
ad0b97c7c2
...
b72593e7da
Author | SHA1 | Date | |
---|---|---|---|
b72593e7da | |||
|
fcf85b12af | ||
|
2949bbcad1 | ||
|
d758633c91 | ||
|
d449fcff0a | ||
|
a7400b1812 | ||
|
a6d31a30a2 | ||
|
4b79a98910 | ||
|
9d1ffeaf8d | ||
|
9db70035b1 |
13 changed files with 199 additions and 12 deletions
|
@ -89,10 +89,10 @@ RUN addgroup \
|
||||||
-s /bin/bash \
|
-s /bin/bash \
|
||||||
-u 1000 \
|
-u 1000 \
|
||||||
-G git \
|
-G git \
|
||||||
git && \
|
_gitea && \
|
||||||
echo "git:*" | chpasswd -e
|
echo "_gitea:*" | chpasswd -e
|
||||||
|
|
||||||
ENV USER git
|
ENV USER _gitea
|
||||||
ENV GITEA_CUSTOM /data/gitea
|
ENV GITEA_CUSTOM /data/gitea
|
||||||
|
|
||||||
VOLUME ["/data"]
|
VOLUME ["/data"]
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -27,7 +27,7 @@ DIFF ?= diff --unified
|
||||||
XGO_VERSION := go-1.21.x
|
XGO_VERSION := go-1.21.x
|
||||||
|
|
||||||
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.49.0
|
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.49.0
|
||||||
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0
|
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v2/cmd/editorconfig-checker@2.8.0
|
||||||
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.6.0
|
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.6.0
|
||||||
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1
|
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1
|
||||||
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
|
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
|
||||||
|
|
|
@ -4,14 +4,22 @@ A minor or major Forgejo release is published every [three months](https://forge
|
||||||
|
|
||||||
A [patch or minor release](https://semver.org/spec/v2.0.0.html) (e.g. upgrading from v7.0.0 to v7.0.1 or v7.1.0) does not require manual intervention. But [major releases](https://semver.org/spec/v2.0.0.html#spec-item-8) where the first version number changes (e.g. upgrading from v1.21 to v7.0) contain breaking changes and the release notes explain how to deal with them.
|
A [patch or minor release](https://semver.org/spec/v2.0.0.html) (e.g. upgrading from v7.0.0 to v7.0.1 or v7.1.0) does not require manual intervention. But [major releases](https://semver.org/spec/v2.0.0.html#spec-item-8) where the first version number changes (e.g. upgrading from v1.21 to v7.0) contain breaking changes and the release notes explain how to deal with them.
|
||||||
|
|
||||||
## 7.0.1
|
## 7.0.2
|
||||||
|
|
||||||
This is a bug fix release. See the documentation for more information on the [upgrade procedure](https://forgejo.org/docs/v7.0/admin/upgrade/).
|
This is a bug fix release. See the documentation for more information on the [upgrade procedure](https://forgejo.org/docs/v7.0/admin/upgrade/).
|
||||||
|
|
||||||
In addition to the following notable bug fixes, you can browse the [full list of commits](https://codeberg.org/forgejo/forgejo/compare/v7.0.0...v7.0.1) included in this release.
|
In addition to the following notable bug fixes, you can browse the [full list of commits](https://codeberg.org/forgejo/forgejo/compare/v7.0.1...v7.0.2) included in this release.
|
||||||
|
|
||||||
* **Bug fixes:**
|
* **Bug fixes:**
|
||||||
* The regression in the [`fogejo admin user create`](https://forgejo.org/docs/v7.0/admin/command-line/#admin-user-create) CLI command [is fixed](https://codeberg.org/forgejo/forgejo/issues/3399) and it is backward compatible.
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3562): a v7.0.0 regression where subscribing to or unsubscribing from an issue in a repository with no code produced an internal server error.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/issues/3559): a v7.0.0 regression makes all the refs sent in Gitea webhooks to be full refs and might break Woodpecker CI pipelines triggered on tag (`CI_COMMIT_TAG` contained the full ref). This issue [has been fixed](https://github.com/woodpecker-ci/woodpecker/pull/3664) in the `main` branch of Woodpecker CI as well.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3555): the webhook branch filter wrongly applied the match on the full ref for branch creation and deletion (wrongly skipping events).
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3537): toggling the WIP state of a pull request is possible from the sidebar, but not from the footer.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3565): when mentioning a user, the markup post-processor does not handle the case where the mentioned user does not exist: it tries to skip to the next node, which in turn, ended up skipping the rest of the line.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3570): excessive and unnecessary database queries when a user with no repositories is viewing their dashboard.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3580): duplicate status check contexts show in the branch protection settings.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3497): profile info fails to render german singular translation.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3504): inline attachments of [incoming emails](https://forgejo.org/docs/v7.0/user/incoming/) (as they occur for example with Apple Mail) are not attached to comments.
|
||||||
|
|
||||||
## 7.0.1
|
## 7.0.1
|
||||||
|
|
||||||
|
@ -39,6 +47,7 @@ $ git -C forgejo log --oneline --no-merges origin/v1.21/forgejo..origin/v7.0/for
|
||||||
* Running the [`forgejo doctor check --fix`](https://forgejo.org/docs/v7.0/admin/command-line/#doctor-check) CLI command or setting [`[cron.gc_lfs].ENABLED=true`](https://forgejo.org/docs/v7.0/admin/config-cheat-sheet/#cron---garbage-collect-lfs-pointers-in-repositories-crongc_lfs) (the default is `false`) will corrupt the LFS storage. The workaround is to not run the doctor CLI command and disable the `cron.gc_lfs`. This regression will be [fixed in 7.0.1](https://codeberg.org/forgejo/forgejo/issues/3438).
|
* Running the [`forgejo doctor check --fix`](https://forgejo.org/docs/v7.0/admin/command-line/#doctor-check) CLI command or setting [`[cron.gc_lfs].ENABLED=true`](https://forgejo.org/docs/v7.0/admin/config-cheat-sheet/#cron---garbage-collect-lfs-pointers-in-repositories-crongc_lfs) (the default is `false`) will corrupt the LFS storage. The workaround is to not run the doctor CLI command and disable the `cron.gc_lfs`. This regression will be [fixed in 7.0.1](https://codeberg.org/forgejo/forgejo/issues/3438).
|
||||||
* The [`forgejo admin user create`](https://forgejo.org/docs/v7.0/admin/command-line/#admin-user-create) CLI command [requires a password](https://codeberg.org/forgejo/forgejo/commit/b122c6ef8b9254120432aed373cbe075331132ac) change by default when creating the first user and the `--admin` flag is not specified. The `--must-change-password=false` argument must be given to not require a password change. This regression will be [fixed in 7.0.1](https://codeberg.org/forgejo/forgejo/issues/3399).
|
* The [`forgejo admin user create`](https://forgejo.org/docs/v7.0/admin/command-line/#admin-user-create) CLI command [requires a password](https://codeberg.org/forgejo/forgejo/commit/b122c6ef8b9254120432aed373cbe075331132ac) change by default when creating the first user and the `--admin` flag is not specified. The `--must-change-password=false` argument must be given to not require a password change. This regression will be [fixed in 7.0.1](https://codeberg.org/forgejo/forgejo/issues/3399).
|
||||||
* **Breaking changes requiring manual intervention:**
|
* **Breaking changes requiring manual intervention:**
|
||||||
|
* [Forgejo webhooks](https://codeberg.org/forgejo/forgejo/issues/3055) now always send full refs (starting with `refs/`) instead of sending short refs in some cases. This new behavior may require changes when the receiving end assumes a short ref will be received (for instance some versions of Woodpecker CI when receiving webhook payloads when a tag is set).
|
||||||
* [MySQL 8.0 or PostgreSQL 12](https://codeberg.org/forgejo/forgejo/commit/e94f9fcafdcf284561e7fb33f60156a69c4ad6a5) are the minimum supported versions. The database must be migrated before upgrading. The requirements regarding SQLite did not change.
|
* [MySQL 8.0 or PostgreSQL 12](https://codeberg.org/forgejo/forgejo/commit/e94f9fcafdcf284561e7fb33f60156a69c4ad6a5) are the minimum supported versions. The database must be migrated before upgrading. The requirements regarding SQLite did not change.
|
||||||
* The `per_page` parameter is [no longer a synonym for `limit`](https://codeberg.org/forgejo/forgejo/commit/0aab2d38a7d91bc8caff332e452364468ce52d9a) in the [/repos/{owner}/{repo}/releases](https://code.forgejo.org/api/swagger/#/repository/repoListReleases) API endpoint.
|
* The `per_page` parameter is [no longer a synonym for `limit`](https://codeberg.org/forgejo/forgejo/commit/0aab2d38a7d91bc8caff332e452364468ce52d9a) in the [/repos/{owner}/{repo}/releases](https://code.forgejo.org/api/swagger/#/repository/repoListReleases) API endpoint.
|
||||||
* The date format of the `created` and `last_update` fields of the [`/repos/{owner}/{repo}/push_mirrors`](https://code.forgejo.org/api/swagger/#/repository/repoListPushMirrors) and [/repos/{owner}/{repo}/push_mirrors](https://code.forgejo.org/api/swagger/#/repository/repoAddPushMirror) API endpoint changed [to be timestamps instead of numbers](https://codeberg.org/forgejo/forgejo/commit/0ee7cbf725f45650136be45f8e0f74d395f73b5c).
|
* The date format of the `created` and `last_update` fields of the [`/repos/{owner}/{repo}/push_mirrors`](https://code.forgejo.org/api/swagger/#/repository/repoListPushMirrors) and [/repos/{owner}/{repo}/push_mirrors](https://code.forgejo.org/api/swagger/#/repository/repoAddPushMirror) API endpoint changed [to be timestamps instead of numbers](https://codeberg.org/forgejo/forgejo/commit/0ee7cbf725f45650136be45f8e0f74d395f73b5c).
|
||||||
|
|
1
release-notes/8.0.0/3583.md
Normal file
1
release-notes/8.0.0/3583.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Settings: OAuth2 applications: Consistently check input on client side
|
|
@ -1 +0,0 @@
|
||||||
Fixed that inline attachments of emails (as they occur for example with Apple Mail) are not attached to comments.
|
|
|
@ -1 +0,0 @@
|
||||||
Fixed a bug where subscribing to or unsubscribing from an issue in a repository with no code produced an internal server error.
|
|
|
@ -1 +0,0 @@
|
||||||
Fixed an issue that resulted in excessive and unnecessary database queries when a user with no repositories was viewing their dashboard.
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
|
shared_user "code.gitea.io/gitea/routers/web/shared/user"
|
||||||
"code.gitea.io/gitea/services/context"
|
"code.gitea.io/gitea/services/context"
|
||||||
user_service "code.gitea.io/gitea/services/user"
|
user_service "code.gitea.io/gitea/services/user"
|
||||||
)
|
)
|
||||||
|
@ -27,6 +28,12 @@ func BlockedUsers(ctx *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = shared_user.LoadHeaderCount(ctx)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("LoadHeaderCount", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ctx.Data["BlockedUsers"] = blockedUsers
|
ctx.Data["BlockedUsers"] = blockedUsers
|
||||||
|
|
||||||
ctx.HTML(http.StatusOK, tplBlockedUsers)
|
ctx.HTML(http.StatusOK, tplBlockedUsers)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
{{if .RepoCount}}
|
{{if .RepoCount}}
|
||||||
<div class="ui small label">{{.RepoCount}}</div>
|
<div class="ui small label">{{.RepoCount}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<span hidden test-name="repository-count">{{.RepoCount}}</span>
|
||||||
</a>
|
</a>
|
||||||
{{if .CanReadProjects}}
|
{{if .CanReadProjects}}
|
||||||
<a class="{{if .PageIsViewProjects}}active {{end}}item" href="{{$.Org.HomeLink}}/-/projects">
|
<a class="{{if .PageIsViewProjects}}active {{end}}item" href="{{$.Org.HomeLink}}/-/projects">
|
||||||
|
@ -13,6 +14,7 @@
|
||||||
{{if .ProjectCount}}
|
{{if .ProjectCount}}
|
||||||
<div class="ui small label">{{.ProjectCount}}</div>
|
<div class="ui small label">{{.ProjectCount}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<span hidden test-name="project-count">{{.ProjectCount}}</span>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and .IsPackageEnabled .CanReadPackages}}
|
{{if and .IsPackageEnabled .CanReadPackages}}
|
||||||
|
@ -31,6 +33,7 @@
|
||||||
<div class="ui small label">{{.NumMembers}}</div>
|
<div class="ui small label">{{.NumMembers}}</div>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<span hidden test-name="member-count">{{.NumMembers}}</span>
|
||||||
{{if .IsOrganizationMember}}
|
{{if .IsOrganizationMember}}
|
||||||
<a class="{{if $.PageIsOrgTeams}}active {{end}}item" href="{{$.OrgLink}}/teams">
|
<a class="{{if $.PageIsOrgTeams}}active {{end}}item" href="{{$.OrgLink}}/teams">
|
||||||
{{svg "octicon-people"}} {{ctx.Locale.Tr "org.teams"}}
|
{{svg "octicon-people"}} {{ctx.Locale.Tr "org.teams"}}
|
||||||
|
@ -39,6 +42,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<span hidden test-name="team-count">{{.NumTeams}}</span>
|
||||||
{{if .IsOrganizationOwner}}
|
{{if .IsOrganizationOwner}}
|
||||||
<a id="settings-btn" class="{{if .PageIsOrgSettings}}active {{end}}right item" href="{{.OrgLink}}/settings">
|
<a id="settings-btn" class="{{if .PageIsOrgSettings}}active {{end}}right item" href="{{.OrgLink}}/settings">
|
||||||
{{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings"}}
|
{{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings"}}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
{{if .Title}}{{.Title}}{{else}}{{ctx.Locale.Tr "actions.runs.empty_commit_message"}}{{end}}
|
{{if .Title}}{{.Title}}{{else}}{{ctx.Locale.Tr "actions.runs.empty_commit_message"}}{{end}}
|
||||||
</a>
|
</a>
|
||||||
<div class="flex-item-body">
|
<div class="flex-item-body">
|
||||||
<b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b>:
|
<b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b> -
|
||||||
{{- if .ScheduleID -}}
|
{{- if .ScheduleID -}}
|
||||||
{{ctx.Locale.Tr "actions.runs.scheduled"}}
|
{{ctx.Locale.Tr "actions.runs.scheduled"}}
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
{{if .RepoCount}}
|
{{if .RepoCount}}
|
||||||
<div class="ui small label">{{.RepoCount}}</div>
|
<div class="ui small label">{{.RepoCount}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<span hidden test-name="repository-count">{{.RepoCount}}</span>
|
||||||
</a>
|
</a>
|
||||||
{{if or .ContextUser.IsIndividual .CanReadProjects}}
|
{{if or .ContextUser.IsIndividual .CanReadProjects}}
|
||||||
<a href="{{.ContextUser.HomeLink}}/-/projects" class="{{if .PageIsViewProjects}}active {{end}}item">
|
<a href="{{.ContextUser.HomeLink}}/-/projects" class="{{if .PageIsViewProjects}}active {{end}}item">
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
{{if .ProjectCount}}
|
{{if .ProjectCount}}
|
||||||
<div class="ui small label">{{.ProjectCount}}</div>
|
<div class="ui small label">{{.ProjectCount}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<span hidden test-name="project-count">{{.ProjectCount}}</span>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and .IsPackageEnabled (or .ContextUser.IsIndividual .CanReadPackages)}}
|
{{if and .IsPackageEnabled (or .ContextUser.IsIndividual .CanReadPackages)}}
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="field {{if .Err_RedirectURI}}error{{end}}">
|
<div class="field {{if .Err_RedirectURI}}error{{end}}">
|
||||||
<label for="redirect-uris">{{ctx.Locale.Tr "settings.oauth2_redirect_uris"}}</label>
|
<label for="redirect-uris">{{ctx.Locale.Tr "settings.oauth2_redirect_uris"}}</label>
|
||||||
<textarea name="redirect_uris" id="redirect-uris"></textarea>
|
<textarea name="redirect_uris" id="redirect-uris" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="field ui checkbox {{if .Err_ConfidentialClient}}error{{end}}">
|
<div class="field ui checkbox {{if .Err_ConfidentialClient}}error{{end}}">
|
||||||
<label>{{ctx.Locale.Tr "settings.oauth2_confidential_client"}}</label>
|
<label>{{ctx.Locale.Tr "settings.oauth2_confidential_client"}}</label>
|
||||||
|
|
167
tests/integration/user_count_test.go
Normal file
167
tests/integration/user_count_test.go
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/models/db"
|
||||||
|
"code.gitea.io/gitea/models/organization"
|
||||||
|
project_model "code.gitea.io/gitea/models/project"
|
||||||
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
|
"code.gitea.io/gitea/models/unittest"
|
||||||
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
|
"code.gitea.io/gitea/modules/optional"
|
||||||
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
type userCountTest struct {
|
||||||
|
doer *user_model.User
|
||||||
|
user *user_model.User
|
||||||
|
session *TestSession
|
||||||
|
repoCount int64
|
||||||
|
projectCount int64
|
||||||
|
memberCount int64
|
||||||
|
teamCount int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (countTest *userCountTest) Init(t *testing.T, doerID, userID int64) {
|
||||||
|
countTest.doer = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: doerID})
|
||||||
|
countTest.user = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID})
|
||||||
|
countTest.session = loginUser(t, countTest.doer.Name)
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
countTest.repoCount, err = repo_model.CountRepository(db.DefaultContext, &repo_model.SearchRepoOptions{
|
||||||
|
Actor: countTest.doer,
|
||||||
|
OwnerID: countTest.user.ID,
|
||||||
|
Private: true,
|
||||||
|
Collaborate: optional.Some(false),
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
var projectType project_model.Type
|
||||||
|
if countTest.user.IsOrganization() {
|
||||||
|
projectType = project_model.TypeOrganization
|
||||||
|
} else {
|
||||||
|
projectType = project_model.TypeIndividual
|
||||||
|
}
|
||||||
|
countTest.projectCount, err = db.Count[project_model.Project](db.DefaultContext, project_model.SearchOptions{
|
||||||
|
OwnerID: countTest.user.ID,
|
||||||
|
IsClosed: optional.Some(false),
|
||||||
|
Type: projectType,
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
if !countTest.user.IsOrganization() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
org := (*organization.Organization)(countTest.user)
|
||||||
|
|
||||||
|
isMember, err := org.IsOrgMember(db.DefaultContext, countTest.doer.ID)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
countTest.memberCount, err = organization.CountOrgMembers(db.DefaultContext, &organization.FindOrgMembersOpts{
|
||||||
|
OrgID: org.ID,
|
||||||
|
PublicOnly: !isMember,
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
teams, err := org.LoadTeams(db.DefaultContext)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
countTest.teamCount = int64(len(teams))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (countTest *userCountTest) getCount(doc *goquery.Document, name string) (int64, error) {
|
||||||
|
selection := doc.Find(fmt.Sprintf("[test-name=\"%s\"]", name))
|
||||||
|
|
||||||
|
if selection.Length() != 1 {
|
||||||
|
return 0, fmt.Errorf("%s was not found", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
return strconv.ParseInt(selection.Text(), 10, 64)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (countTest *userCountTest) TestPage(t *testing.T, page string, orgLink bool) {
|
||||||
|
t.Run(page, func(t *testing.T) {
|
||||||
|
var userLink string
|
||||||
|
|
||||||
|
if orgLink {
|
||||||
|
userLink = countTest.user.OrganisationLink()
|
||||||
|
} else {
|
||||||
|
userLink = countTest.user.HomeLink()
|
||||||
|
}
|
||||||
|
|
||||||
|
req := NewRequestf(t, "GET", "%s/%s", userLink, page)
|
||||||
|
resp := countTest.session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
|
||||||
|
repoCount, err := countTest.getCount(htmlDoc.doc, "repository-count")
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, countTest.repoCount, repoCount)
|
||||||
|
|
||||||
|
projectCount, err := countTest.getCount(htmlDoc.doc, "project-count")
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, countTest.projectCount, projectCount)
|
||||||
|
|
||||||
|
if !countTest.user.IsOrganization() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
memberCount, err := countTest.getCount(htmlDoc.doc, "member-count")
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, countTest.memberCount, memberCount)
|
||||||
|
|
||||||
|
teamCount, err := countTest.getCount(htmlDoc.doc, "team-count")
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, countTest.teamCount, teamCount)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrontendHeaderCountUser(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
countTest := new(userCountTest)
|
||||||
|
countTest.Init(t, 2, 2)
|
||||||
|
|
||||||
|
countTest.TestPage(t, "", false)
|
||||||
|
countTest.TestPage(t, "?tab=repositories", false)
|
||||||
|
countTest.TestPage(t, "-/projects", false)
|
||||||
|
countTest.TestPage(t, "-/packages", false)
|
||||||
|
countTest.TestPage(t, "?tab=activity", false)
|
||||||
|
countTest.TestPage(t, "?tab=stars", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFrontendHeaderCountOrg(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
countTest := new(userCountTest)
|
||||||
|
countTest.Init(t, 15, 17)
|
||||||
|
|
||||||
|
countTest.TestPage(t, "", false)
|
||||||
|
countTest.TestPage(t, "-/projects", false)
|
||||||
|
countTest.TestPage(t, "-/packages", false)
|
||||||
|
countTest.TestPage(t, "members", true)
|
||||||
|
countTest.TestPage(t, "teams", true)
|
||||||
|
|
||||||
|
countTest.TestPage(t, "settings", true)
|
||||||
|
countTest.TestPage(t, "settings/hooks", true)
|
||||||
|
countTest.TestPage(t, "settings/labels", true)
|
||||||
|
countTest.TestPage(t, "settings/applications", true)
|
||||||
|
countTest.TestPage(t, "settings/packages", true)
|
||||||
|
countTest.TestPage(t, "settings/actions/runners", true)
|
||||||
|
countTest.TestPage(t, "settings/actions/secrets", true)
|
||||||
|
countTest.TestPage(t, "settings/actions/variables", true)
|
||||||
|
countTest.TestPage(t, "settings/blocked_users", true)
|
||||||
|
countTest.TestPage(t, "settings/delete", true)
|
||||||
|
}
|
Loading…
Reference in a new issue