mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-01 17:38:33 +00:00
chore: improve test quality
- Merge tests together. - Remove unecessary usage of `onGiteaRun`. - Make proper use of `unittest`. - Make proper use of `test.MockVariable`. - I have not checked all of the testing files yet.
This commit is contained in:
parent
ab36ab57e4
commit
582ab21bc3
18 changed files with 620 additions and 784 deletions
|
@ -5,33 +5,33 @@ package integration
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// TestRepoCollaborators is a test for contents of Collaborators tab in the repo settings
|
||||
// It only covers a few elements and can be extended as needed
|
||||
func TestRepoCollaborators(t *testing.T) {
|
||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||
session := loginUser(t, "user2")
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
session := loginUser(t, "user2")
|
||||
|
||||
// Visit Collaborators tab of repo settings
|
||||
response := session.MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/settings/collaboration"), http.StatusOK)
|
||||
page := NewHTMLParser(t, response.Body).Find(".repo-setting-content")
|
||||
// Visit Collaborators tab of repo settings
|
||||
response := session.MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/settings/collaboration"), http.StatusOK)
|
||||
page := NewHTMLParser(t, response.Body).Find(".repo-setting-content")
|
||||
|
||||
// Veirfy header
|
||||
assert.EqualValues(t, "Collaborators", strings.TrimSpace(page.Find("h4").Text()))
|
||||
// Veirfy header
|
||||
assert.EqualValues(t, "Collaborators", strings.TrimSpace(page.Find("h4").Text()))
|
||||
|
||||
// Veirfy button text
|
||||
page = page.Find("#repo-collab-form")
|
||||
assert.EqualValues(t, "Add collaborator", strings.TrimSpace(page.Find("button.primary").Text()))
|
||||
// Veirfy button text
|
||||
page = page.Find("#repo-collab-form")
|
||||
assert.EqualValues(t, "Add collaborator", strings.TrimSpace(page.Find("button.primary").Text()))
|
||||
|
||||
// Veirfy placeholder
|
||||
placeholder, exists := page.Find("#search-user-box input").Attr("placeholder")
|
||||
assert.True(t, exists)
|
||||
assert.EqualValues(t, "Search users...", placeholder)
|
||||
})
|
||||
// Veirfy placeholder
|
||||
placeholder, exists := page.Find("#search-user-box input").Attr("placeholder")
|
||||
assert.True(t, exists)
|
||||
assert.EqualValues(t, "Search users...", placeholder)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue