forked from kevadesu/forgejo
Merge branch 'forgejo' into repocard
This commit is contained in:
commit
df570a1d71
29 changed files with 782 additions and 1947 deletions
17
tests/e2e/repo-activity-contributors.test.e2e.ts
Normal file
17
tests/e2e/repo-activity-contributors.test.e2e.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// @watch start
|
||||
// web_src/js/features/contributors.js
|
||||
// web_src/js/components/RepoContributors.vue
|
||||
// templates/repo/*
|
||||
// @watch end
|
||||
|
||||
import {expect} from '@playwright/test';
|
||||
import {test} from './utils_e2e.ts';
|
||||
|
||||
test('Contributor graph', async ({page}) => {
|
||||
await page.goto('/user2/commits_search_test/activity/contributors');
|
||||
await page.getByRole('link', {name: '2 Commits'}).click();
|
||||
await expect(page.getByRole('cell', {name: 'Bob'})).toHaveCount(2);
|
||||
});
|
|
@ -9,12 +9,15 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -132,3 +135,64 @@ func TestSourceId(t *testing.T) {
|
|||
assert.Len(t, users, 1)
|
||||
assert.Equal(t, "ausersourceid23", users[0].UserName)
|
||||
}
|
||||
|
||||
func TestAdminViewUsersSorted(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
createTimestamp := time.Now().Unix() - 1000
|
||||
updateTimestamp := time.Now().Unix() - 500
|
||||
sess := db.GetEngine(context.Background())
|
||||
|
||||
// Create 10 users with login source 44
|
||||
for i := int64(1); i <= 10; i++ {
|
||||
name := "sorttest" + strconv.Itoa(int(i))
|
||||
user := &user_model.User{
|
||||
Name: name,
|
||||
LowerName: name,
|
||||
LoginName: name,
|
||||
Email: name + "@example.com",
|
||||
Passwd: name + ".password",
|
||||
Type: user_model.UserTypeIndividual,
|
||||
LoginType: auth_model.OAuth2,
|
||||
LoginSource: 44,
|
||||
CreatedUnix: timeutil.TimeStamp(createTimestamp - i),
|
||||
UpdatedUnix: timeutil.TimeStamp(updateTimestamp - i),
|
||||
}
|
||||
if _, err := sess.NoAutoTime().Insert(user); err != nil {
|
||||
t.Fatalf("Failed to create user: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
session := loginUser(t, "user1")
|
||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeReadAdmin)
|
||||
|
||||
testCases := []struct {
|
||||
loginSource int64
|
||||
sortType string
|
||||
expectedUsers []string
|
||||
}{
|
||||
{0, "alphabetically", []string{"the_34-user.with.all.allowedChars", "user1", "user10", "user11"}},
|
||||
{0, "reversealphabetically", []string{"user9", "user8", "user5", "user40"}},
|
||||
{0, "newest", []string{"user40", "user39", "user38", "user37"}},
|
||||
{0, "oldest", []string{"user1", "user2", "user4", "user5"}},
|
||||
{44, "recentupdate", []string{"sorttest1", "sorttest2", "sorttest3", "sorttest4"}},
|
||||
{44, "leastupdate", []string{"sorttest10", "sorttest9", "sorttest8", "sorttest7"}},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
req := NewRequest(
|
||||
t,
|
||||
"GET",
|
||||
fmt.Sprintf("/api/v1/admin/users?sort=%s&limit=4&source_id=%d",
|
||||
testCase.sortType,
|
||||
testCase.loginSource),
|
||||
).AddTokenAuth(token)
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var users []api.User
|
||||
DecodeJSON(t, resp, &users)
|
||||
assert.Len(t, users, 4)
|
||||
for i, user := range users {
|
||||
assert.Equalf(t, testCase.expectedUsers[i], user.UserName, "Sort type: %s, index %d", testCase.sortType, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -902,7 +902,7 @@ func TestRepoFollowSymlink(t *testing.T) {
|
|||
symlinkURL, ok := htmlDoc.Find(".file-actions .button[data-kind='follow-symlink']").Attr("href")
|
||||
if shouldExist {
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, expectedSymlinkURL, symlinkURL) //nolint:testifylint // false positive https://github.com/Antonboom/testifylint/issues/72#issuecomment-2467548358
|
||||
assert.Equal(t, expectedSymlinkURL, symlinkURL)
|
||||
} else {
|
||||
assert.False(t, ok)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue