forgejo/tests/integration/comment_roles_system_test.go
Renovate Bot fed2d81c44
Some checks failed
/ release (push) Waiting to run
testing / backend-checks (push) Has been skipped
testing / frontend-checks (push) Has been skipped
testing / test-unit (push) Has been skipped
testing / test-e2e (push) Has been skipped
testing / test-mysql (push) Has been skipped
testing / test-pgsql (push) Has been skipped
testing / test-sqlite (push) Has been skipped
testing / test-remote-cacher (redis) (push) Has been skipped
testing / test-remote-cacher (valkey) (push) Has been skipped
testing / test-remote-cacher (garnet) (push) Has been skipped
testing / test-remote-cacher (redict) (push) Has been skipped
testing / security-check (push) Has been skipped
Integration tests for the release process / release-simulation (push) Has been cancelled
Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367)
Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
2025-03-28 22:22:21 +00:00

56 lines
1.6 KiB
Go

// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package integration
import (
"net/http"
"testing"
issues_model "forgejo.org/models/issues"
repo_model "forgejo.org/models/repo"
"forgejo.org/models/unittest"
"forgejo.org/tests"
"github.com/stretchr/testify/assert"
)
// TestSystemCommentRoles verifies that system users don't have role labels.
// As it is not possible to do actions as system users, the tests are done using fixtures.
func TestSystemCommentRoles(t *testing.T) {
defer tests.AddFixtures("tests/integration/fixtures/TestSystemCommentRoles/")()
defer tests.PrepareTestEnv(t)()
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
testCases := []struct {
name string
username string
index int64
roleCount int64
}{
{"user2", "user2", 1000, 1}, // As a verification, also check a normal user with one role.
{"Ghost", "Ghost", 1001, 0}, // System users should not have any roles, so 0.
{"Actions", "forgejo-actions", 1002, 0},
{"APActor", "Ghost", 1003, 0}, // actor is displayed as Ghost, could be a bug.
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{
RepoID: repo.ID,
Index: tc.index,
})
req := NewRequestf(t, "GET", "%s/issues/%d", repo.Link(), issue.Index)
resp := MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
assert.Equal(t, tc.username, htmlDoc.Find("a.author").Text())
assert.EqualValues(t, tc.roleCount, htmlDoc.Find(".role-label").Length())
})
}
}