diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-07-22 18:54:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-22 10:54:48 +0000 |
commit | a7e82735742096fabd97eb6faa0389d2dc49464d (patch) | |
tree | 66772b53ea94918f55ebbf7a66a745d8013805c6 /tests | |
parent | acc74c2fc6e67ca72293da1540226c3931700566 (diff) | |
download | gitea-a7e82735742096fabd97eb6faa0389d2dc49464d.tar.gz gitea-a7e82735742096fabd97eb6faa0389d2dc49464d.zip |
Fix the truncate and alignment problem for some admin tables (#26042)
Some "text truncate email" code were just copied&pasted, they are not
suitable for most admin tables.
For the table layouts, some "max-width" helpers could be very helpful.
At least, we can get rid of the confusing "email" CSS class.
![image](https://github.com/go-gitea/gitea/assets/2114189/0b0bd068-56fc-41cf-b4a3-ed45eb797401)
![image](https://github.com/go-gitea/gitea/assets/2114189/e7f843a3-5f46-4205-b383-4c7ef647ce83)
![image](https://github.com/go-gitea/gitea/assets/2114189/ce8d65e1-7e03-466e-a03b-9bd33815da91)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/auth_ldap_test.go | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/tests/integration/auth_ldap_test.go b/tests/integration/auth_ldap_test.go index d2160a3dbe..25395f5721 100644 --- a/tests/integration/auth_ldap_test.go +++ b/tests/integration/auth_ldap_test.go @@ -226,45 +226,20 @@ func TestLDAPUserSync(t *testing.T) { addAuthSourceLDAP(t, "", "") auth.SyncExternalUsers(context.Background(), true) - session := loginUser(t, "user1") // Check if users exists - for _, u := range gitLDAPUsers { - req := NewRequest(t, "GET", "/admin/users?q="+u.UserName) - resp := session.MakeRequest(t, req, http.StatusOK) - - htmlDoc := NewHTMLParser(t, resp.Body) - - tr := htmlDoc.doc.Find("table.table tbody tr") - if !assert.True(t, tr.Length() == 1) { - continue - } - tds := tr.Find("td") - if !assert.True(t, tds.Length() > 0) { - continue - } - assert.Equal(t, u.UserName, strings.TrimSpace(tds.Find("td:nth-child(2) a").Text())) - assert.Equal(t, u.Email, strings.TrimSpace(tds.Find("td:nth-child(3) span").Text())) - if u.IsAdmin { - assert.True(t, tds.Find("td:nth-child(5) svg").HasClass("octicon-check")) - } else { - assert.True(t, tds.Find("td:nth-child(5) svg").HasClass("octicon-x")) - } - if u.IsRestricted { - assert.True(t, tds.Find("td:nth-child(6) svg").HasClass("octicon-check")) - } else { - assert.True(t, tds.Find("td:nth-child(6) svg").HasClass("octicon-x")) - } + for _, gitLDAPUser := range gitLDAPUsers { + dbUser, err := user_model.GetUserByName(db.DefaultContext, gitLDAPUser.UserName) + assert.NoError(t, err) + assert.Equal(t, gitLDAPUser.UserName, dbUser.Name) + assert.Equal(t, gitLDAPUser.Email, dbUser.Email) + assert.Equal(t, gitLDAPUser.IsAdmin, dbUser.IsAdmin) + assert.Equal(t, gitLDAPUser.IsRestricted, dbUser.IsRestricted) } // Check if no users exist - for _, u := range otherLDAPUsers { - req := NewRequest(t, "GET", "/admin/users?q="+u.UserName) - resp := session.MakeRequest(t, req, http.StatusOK) - - htmlDoc := NewHTMLParser(t, resp.Body) - - tr := htmlDoc.doc.Find("table.table tbody tr") - assert.True(t, tr.Length() == 0) + for _, otherLDAPUser := range otherLDAPUsers { + _, err := user_model.GetUserByName(db.DefaultContext, otherLDAPUser.UserName) + assert.True(t, user_model.IsErrUserNotExist(err)) } } |