mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-05-16 20:00:52 +00:00
Compare commits
13 commits
cd6ae89cd9
...
f866bf8dbe
Author | SHA1 | Date | |
---|---|---|---|
f866bf8dbe | |||
28d186a13d | |||
fbbbd36535 | |||
ff328f0f6f | |||
d0708b0051 | |||
baa7c8f975 | |||
85f2727872 | |||
787b16a7be | |||
d50efa626a | |||
9bc866124b | |||
b08aef967e | |||
47ea0f5f98 | |||
3e3f7c3f47 |
78
package-lock.json
generated
78
package-lock.json
generated
|
@ -67,7 +67,7 @@
|
|||
"@eslint-community/eslint-plugin-eslint-comments": "4.3.0",
|
||||
"@playwright/test": "1.43.0",
|
||||
"@stoplight/spectral-cli": "6.11.1",
|
||||
"@stylistic/eslint-plugin-js": "1.7.2",
|
||||
"@stylistic/eslint-plugin-js": "1.8.0",
|
||||
"@stylistic/stylelint-plugin": "2.1.2",
|
||||
"@vitejs/plugin-vue": "5.0.4",
|
||||
"@vue/test-utils": "2.4.5",
|
||||
|
@ -87,7 +87,7 @@
|
|||
"eslint-plugin-vue-scoped-css": "2.8.0",
|
||||
"eslint-plugin-wc": "2.1.0",
|
||||
"happy-dom": "14.7.1",
|
||||
"markdownlint-cli": "0.39.0",
|
||||
"markdownlint-cli": "0.40.0",
|
||||
"postcss-html": "1.6.0",
|
||||
"stylelint": "16.4.0",
|
||||
"stylelint-declaration-block-no-ignored-properties": "2.8.0",
|
||||
|
@ -2126,12 +2126,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-js": {
|
||||
"version": "1.7.2",
|
||||
"resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-1.7.2.tgz",
|
||||
"integrity": "sha512-ZYX7C5p7zlHbACwFLU+lISVh6tdcRP/++PWegh2Sy0UgMT5kU0XkPa2tKWEtJYzZmPhJxu9LxbnWcnE/tTwSDQ==",
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-1.8.0.tgz",
|
||||
"integrity": "sha512-jdvnzt+pZPg8TfclZlTZPiUbbima93ylvQ+wNgHLNmup3obY6heQvgewSu9i2CfS61BnRByv+F9fxQLPoNeHag==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/eslint": "^8.56.8",
|
||||
"@types/eslint": "^8.56.10",
|
||||
"acorn": "^8.11.3",
|
||||
"escape-string-regexp": "^4.0.0",
|
||||
"eslint-visitor-keys": "^3.4.3",
|
||||
|
@ -2224,9 +2224,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@types/eslint": {
|
||||
"version": "8.56.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.9.tgz",
|
||||
"integrity": "sha512-W4W3KcqzjJ0sHg2vAq9vfml6OhsJ53TcUjUqfzzZf/EChUtwspszj/S0pzMxnfRcO55/iGq47dscXw71Fxc4Zg==",
|
||||
"version": "8.56.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz",
|
||||
"integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==",
|
||||
"dependencies": {
|
||||
"@types/estree": "*",
|
||||
"@types/json-schema": "*"
|
||||
|
@ -8212,9 +8212,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/markdown-it": {
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.0.0.tgz",
|
||||
"integrity": "sha512-seFjF0FIcPt4P9U39Bq1JYblX0KZCjDLFFQPHpL5AzHpqPEKtosxmdq/LTVZnjfH7tjt9BxStm+wXcDBNuYmzw==",
|
||||
"version": "14.1.0",
|
||||
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz",
|
||||
"integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"argparse": "^2.0.1",
|
||||
|
@ -8222,20 +8222,20 @@
|
|||
"linkify-it": "^5.0.0",
|
||||
"mdurl": "^2.0.0",
|
||||
"punycode.js": "^2.3.1",
|
||||
"uc.micro": "^2.0.0"
|
||||
"uc.micro": "^2.1.0"
|
||||
},
|
||||
"bin": {
|
||||
"markdown-it": "bin/markdown-it.mjs"
|
||||
}
|
||||
},
|
||||
"node_modules/markdownlint": {
|
||||
"version": "0.33.0",
|
||||
"resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.33.0.tgz",
|
||||
"integrity": "sha512-4lbtT14A3m0LPX1WS/3d1m7Blg+ZwiLq36WvjQqFGsX3Gik99NV+VXp/PW3n+Q62xyPdbvGOCfjPqjW+/SKMig==",
|
||||
"version": "0.34.0",
|
||||
"resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.34.0.tgz",
|
||||
"integrity": "sha512-qwGyuyKwjkEMOJ10XN6OTKNOVYvOIi35RNvDLNxTof5s8UmyGHlCdpngRHoRGNvQVGuxO3BJ7uNSgdeX166WXw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"markdown-it": "14.0.0",
|
||||
"markdownlint-micromark": "0.1.8"
|
||||
"markdown-it": "14.1.0",
|
||||
"markdownlint-micromark": "0.1.9"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
|
@ -8245,20 +8245,22 @@
|
|||
}
|
||||
},
|
||||
"node_modules/markdownlint-cli": {
|
||||
"version": "0.39.0",
|
||||
"resolved": "https://registry.npmjs.org/markdownlint-cli/-/markdownlint-cli-0.39.0.tgz",
|
||||
"integrity": "sha512-ZuFN7Xpsbn1Nbp0YYkeLOfXOMOfLQBik2lKRy8pVI/llmKQ2uW7x+8k5OMgF6o7XCsTDSYC/OOmeJ+3qplvnJQ==",
|
||||
"version": "0.40.0",
|
||||
"resolved": "https://registry.npmjs.org/markdownlint-cli/-/markdownlint-cli-0.40.0.tgz",
|
||||
"integrity": "sha512-JXhI3dRQcaqwiFYpPz6VJ7aKYheD53GmTz9y4D/d0F1MbZDGOp9pqKlbOfUX/pHP/iAoeiE4wYRmk8/kjLakxA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"commander": "~11.1.0",
|
||||
"commander": "~12.0.0",
|
||||
"get-stdin": "~9.0.0",
|
||||
"glob": "~10.3.10",
|
||||
"ignore": "~5.3.0",
|
||||
"glob": "~10.3.12",
|
||||
"ignore": "~5.3.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"jsonc-parser": "~3.2.1",
|
||||
"markdownlint": "~0.33.0",
|
||||
"minimatch": "~9.0.3",
|
||||
"run-con": "~1.3.2"
|
||||
"jsonpointer": "5.0.1",
|
||||
"markdownlint": "~0.34.0",
|
||||
"minimatch": "~9.0.4",
|
||||
"run-con": "~1.3.2",
|
||||
"toml": "~3.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"markdownlint": "markdownlint.js"
|
||||
|
@ -8268,12 +8270,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/markdownlint-cli/node_modules/commander": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
||||
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-12.0.0.tgz",
|
||||
"integrity": "sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/markdownlint-cli/node_modules/glob": {
|
||||
|
@ -8305,12 +8307,12 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/markdownlint-micromark": {
|
||||
"version": "0.1.8",
|
||||
"resolved": "https://registry.npmjs.org/markdownlint-micromark/-/markdownlint-micromark-0.1.8.tgz",
|
||||
"integrity": "sha512-1ouYkMRo9/6gou9gObuMDnvZM8jC/ly3QCFQyoSPCS2XV1ZClU0xpKbL1Ar3bWWRT1RnBZkWUEiNKrI2CwiBQA==",
|
||||
"version": "0.1.9",
|
||||
"resolved": "https://registry.npmjs.org/markdownlint-micromark/-/markdownlint-micromark-0.1.9.tgz",
|
||||
"integrity": "sha512-5hVs/DzAFa8XqYosbEAEg6ok6MF2smDj89ztn9pKkCtdKHVdPQuGMH7frFfYL9mLkvfFe4pTyAMffLbjf3/EyA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/DavidAnson"
|
||||
|
@ -11831,6 +11833,12 @@
|
|||
"resolved": "https://registry.npmjs.org/toastify-js/-/toastify-js-1.12.0.tgz",
|
||||
"integrity": "sha512-HeMHCO9yLPvP9k0apGSdPUWrUbLnxUKNFzgUoZp1PHCLploIX/4DSQ7V8H25ef+h4iO9n0he7ImfcndnN6nDrQ=="
|
||||
},
|
||||
"node_modules/toml": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz",
|
||||
"integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
"@eslint-community/eslint-plugin-eslint-comments": "4.3.0",
|
||||
"@playwright/test": "1.43.0",
|
||||
"@stoplight/spectral-cli": "6.11.1",
|
||||
"@stylistic/eslint-plugin-js": "1.7.2",
|
||||
"@stylistic/eslint-plugin-js": "1.8.0",
|
||||
"@stylistic/stylelint-plugin": "2.1.2",
|
||||
"@vitejs/plugin-vue": "5.0.4",
|
||||
"@vue/test-utils": "2.4.5",
|
||||
|
@ -86,7 +86,7 @@
|
|||
"eslint-plugin-vue-scoped-css": "2.8.0",
|
||||
"eslint-plugin-wc": "2.1.0",
|
||||
"happy-dom": "14.7.1",
|
||||
"markdownlint-cli": "0.39.0",
|
||||
"markdownlint-cli": "0.40.0",
|
||||
"postcss-html": "1.6.0",
|
||||
"stylelint": "16.4.0",
|
||||
"stylelint-declaration-block-no-ignored-properties": "2.8.0",
|
||||
|
|
1
release-notes/8.0.0/3608.md
Normal file
1
release-notes/8.0.0/3608.md
Normal file
|
@ -0,0 +1 @@
|
|||
Fix text selection color
|
|
@ -60,7 +60,9 @@
|
|||
{
|
||||
"description": "Group nodejs packages",
|
||||
"matchDepNames": ["node", "docker.io/node", "docker.io/library/node"],
|
||||
"groupName": "nodejs packages"
|
||||
"groupName": "nodejs packages",
|
||||
"versionCompatibility": "^(?<version>[^-]+)(?<compatibility>-.*)?$",
|
||||
"versioning": "node"
|
||||
},
|
||||
{
|
||||
"description": "Automerge renovate updates",
|
||||
|
@ -71,20 +73,12 @@
|
|||
},
|
||||
{
|
||||
"description": "Split minor and patch updates",
|
||||
"matchDepNames": [
|
||||
"vue",
|
||||
"github.com/urfave/cli/v2",
|
||||
"swagger-ui-dist"
|
||||
],
|
||||
"matchDepNames": ["vue", "github.com/urfave/cli/v2", "swagger-ui-dist"],
|
||||
"separateMinorPatch": true
|
||||
},
|
||||
{
|
||||
"description": "Automerge patch updates",
|
||||
"matchDepNames": [
|
||||
"vue",
|
||||
"github.com/urfave/cli/v2",
|
||||
"swagger-ui-dist"
|
||||
],
|
||||
"matchDepNames": ["vue", "github.com/urfave/cli/v2", "swagger-ui-dist"],
|
||||
"matchUpdateTypes": ["patch"],
|
||||
"automerge": true
|
||||
},
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
shared_user "code.gitea.io/gitea/routers/web/shared/user"
|
||||
"code.gitea.io/gitea/services/context"
|
||||
user_service "code.gitea.io/gitea/services/user"
|
||||
)
|
||||
|
@ -27,6 +28,12 @@ func BlockedUsers(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
err = shared_user.LoadHeaderCount(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadHeaderCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["BlockedUsers"] = blockedUsers
|
||||
|
||||
ctx.HTML(http.StatusOK, tplBlockedUsers)
|
||||
|
|
|
@ -109,7 +109,7 @@ func RemoveDependency(ctx *context.Context) {
|
|||
}
|
||||
|
||||
// Dependency Type
|
||||
depTypeStr := ctx.Req.PostForm.Get("dependencyType")
|
||||
depTypeStr := ctx.Req.PostFormValue("dependencyType")
|
||||
|
||||
var depType issues_model.DependencyType
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
{{if .RepoCount}}
|
||||
<div class="ui small label">{{.RepoCount}}</div>
|
||||
{{end}}
|
||||
<span hidden test-name="repository-count">{{.RepoCount}}</span>
|
||||
</a>
|
||||
{{if .CanReadProjects}}
|
||||
<a class="{{if .PageIsViewProjects}}active {{end}}item" href="{{$.Org.HomeLink}}/-/projects">
|
||||
|
@ -13,6 +14,7 @@
|
|||
{{if .ProjectCount}}
|
||||
<div class="ui small label">{{.ProjectCount}}</div>
|
||||
{{end}}
|
||||
<span hidden test-name="project-count">{{.ProjectCount}}</span>
|
||||
</a>
|
||||
{{end}}
|
||||
{{if and .IsPackageEnabled .CanReadPackages}}
|
||||
|
@ -31,6 +33,7 @@
|
|||
<div class="ui small label">{{.NumMembers}}</div>
|
||||
</a>
|
||||
{{end}}
|
||||
<span hidden test-name="member-count">{{.NumMembers}}</span>
|
||||
{{if .IsOrganizationMember}}
|
||||
<a class="{{if $.PageIsOrgTeams}}active {{end}}item" href="{{$.OrgLink}}/teams">
|
||||
{{svg "octicon-people"}} {{ctx.Locale.Tr "org.teams"}}
|
||||
|
@ -39,6 +42,7 @@
|
|||
{{end}}
|
||||
</a>
|
||||
{{end}}
|
||||
<span hidden test-name="team-count">{{.NumTeams}}</span>
|
||||
{{if .IsOrganizationOwner}}
|
||||
<a id="settings-btn" class="{{if .PageIsOrgSettings}}active {{end}}right item" href="{{.OrgLink}}/settings">
|
||||
{{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings"}}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
{{if .RepoCount}}
|
||||
<div class="ui small label">{{.RepoCount}}</div>
|
||||
{{end}}
|
||||
<span hidden test-name="repository-count">{{.RepoCount}}</span>
|
||||
</a>
|
||||
{{if or .ContextUser.IsIndividual .CanReadProjects}}
|
||||
<a href="{{.ContextUser.HomeLink}}/-/projects" class="{{if .PageIsViewProjects}}active {{end}}item">
|
||||
|
@ -17,6 +18,7 @@
|
|||
{{if .ProjectCount}}
|
||||
<div class="ui small label">{{.ProjectCount}}</div>
|
||||
{{end}}
|
||||
<span hidden test-name="project-count">{{.ProjectCount}}</span>
|
||||
</a>
|
||||
{{end}}
|
||||
{{if and .IsPackageEnabled (or .ContextUser.IsIndividual .CanReadPackages)}}
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
|
@ -194,6 +195,93 @@ func TestNewIssue(t *testing.T) {
|
|||
testNewIssue(t, session, "user2", "repo1", "Title", "Description")
|
||||
}
|
||||
|
||||
func TestIssueDependencies(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
session := loginUser(t, owner.Name)
|
||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
||||
|
||||
repo, _, f := CreateDeclarativeRepoWithOptions(t, owner, DeclarativeRepoOptions{})
|
||||
defer f()
|
||||
|
||||
createIssue := func(t *testing.T, title string) api.Issue {
|
||||
t.Helper()
|
||||
|
||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues", owner.Name, repo.Name)
|
||||
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateIssueOption{
|
||||
Body: "",
|
||||
Title: title,
|
||||
}).AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusCreated)
|
||||
|
||||
var apiIssue api.Issue
|
||||
DecodeJSON(t, resp, &apiIssue)
|
||||
|
||||
return apiIssue
|
||||
}
|
||||
addDependency := func(t *testing.T, issue, dependency api.Issue) {
|
||||
t.Helper()
|
||||
|
||||
urlStr := fmt.Sprintf("/%s/%s/issues/%d/dependency/add", owner.Name, repo.Name, issue.Index)
|
||||
req := NewRequestWithValues(t, "POST", urlStr, map[string]string{
|
||||
"_csrf": GetCSRF(t, session, fmt.Sprintf("/%s/%s/issues/%d", owner.Name, repo.Name, issue.Index)),
|
||||
"newDependency": fmt.Sprintf("%d", dependency.Index),
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
}
|
||||
removeDependency := func(t *testing.T, issue, dependency api.Issue) {
|
||||
t.Helper()
|
||||
|
||||
urlStr := fmt.Sprintf("/%s/%s/issues/%d/dependency/delete", owner.Name, repo.Name, issue.Index)
|
||||
req := NewRequestWithValues(t, "POST", urlStr, map[string]string{
|
||||
"_csrf": GetCSRF(t, session, fmt.Sprintf("/%s/%s/issues/%d", owner.Name, repo.Name, issue.Index)),
|
||||
"removeDependencyID": fmt.Sprintf("%d", dependency.Index),
|
||||
"dependencyType": "blockedBy",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
}
|
||||
|
||||
assertHasDependency := func(t *testing.T, issueID, dependencyID int64, hasDependency bool) {
|
||||
t.Helper()
|
||||
|
||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/dependencies", owner.Name, repo.Name, issueID)
|
||||
req := NewRequest(t, "GET", urlStr)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var issues []api.Issue
|
||||
DecodeJSON(t, resp, &issues)
|
||||
|
||||
if hasDependency {
|
||||
assert.NotEmpty(t, issues)
|
||||
assert.EqualValues(t, issues[0].Index, dependencyID)
|
||||
} else {
|
||||
assert.Empty(t, issues)
|
||||
}
|
||||
}
|
||||
|
||||
t.Run("Add dependency", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
issue1 := createIssue(t, "issue #1")
|
||||
issue2 := createIssue(t, "issue #2")
|
||||
addDependency(t, issue1, issue2)
|
||||
|
||||
assertHasDependency(t, issue1.Index, issue2.Index, true)
|
||||
})
|
||||
|
||||
t.Run("Remove dependency", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
issue1 := createIssue(t, "issue #1")
|
||||
issue2 := createIssue(t, "issue #2")
|
||||
addDependency(t, issue1, issue2)
|
||||
removeDependency(t, issue1, issue2)
|
||||
|
||||
assertHasDependency(t, issue1.Index, issue2.Index, false)
|
||||
})
|
||||
}
|
||||
|
||||
func TestIssueCommentClose(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
session := loginUser(t, "user2")
|
||||
|
|
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)
|
||||
}
|
|
@ -141,6 +141,7 @@
|
|||
/* other colors */
|
||||
--color-gold: #b1983b;
|
||||
--color-white: #ffffff;
|
||||
--color-pure-black: #000000;
|
||||
--color-diff-removed-word-bg: #783030;
|
||||
--color-diff-added-word-bg: #255c39;
|
||||
--color-diff-removed-row-bg: #432121;
|
||||
|
@ -304,7 +305,7 @@ i.grey.icon.icon.icon.icon {
|
|||
}
|
||||
::selection {
|
||||
background: var(--steel-100) !important;
|
||||
color: var(--color-white) !important;
|
||||
color: var(--color-pure-black) !important;
|
||||
}
|
||||
strong.attention-important, svg.attention-important {
|
||||
color: var(--color-violet-light);
|
||||
|
|
Loading…
Reference in a new issue