summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
author0ko <0ko@noreply.codeberg.org>2025-01-04 09:45:08 +0100
committer0ko <0ko@noreply.codeberg.org>2025-01-04 09:45:08 +0100
commit339814f3bcb33a793d8b69caae8f2e93a4ec1b82 (patch)
treeea8aeb3617c05776eac6d073f9b8aa5e7f322655 /tests
parentMerge pull request 'chore: update ignores' (#6462) from viceice/chore/ignores... (diff)
downloadforgejo-339814f3bcb33a793d8b69caae8f2e93a4ec1b82.tar.xz
forgejo-339814f3bcb33a793d8b69caae8f2e93a4ec1b82.zip
fix(ui): show oauth divider on signup page (#6463)
Fix a minor UI bug introduced in https://codeberg.org/forgejo/forgejo/pulls/6112. The condition `if .EnableInternalSignIn` was added to display of the divider, but it is only available when `oauth_container.tmpl` is called from signIn page, it is not relevant to signUp page. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6463 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/signin_test.go6
-rw-r--r--tests/integration/signup_test.go26
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/integration/signin_test.go b/tests/integration/signin_test.go
index c986b844f0..f8e2e079ca 100644
--- a/tests/integration/signin_test.go
+++ b/tests/integration/signin_test.go
@@ -1,4 +1,5 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
+// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package integration
@@ -97,6 +98,9 @@ func TestSigninWithRememberMe(t *testing.T) {
func TestDisableSignin(t *testing.T) {
defer tests.PrepareTestEnv(t)()
+ // Mock alternative auth ways as enabled
+ defer test.MockVariableValue(&setting.Service.EnableOpenIDSignIn, true)()
+ defer test.MockVariableValue(&setting.Service.EnableOpenIDSignUp, true)()
t.Run("Disabled", func(t *testing.T) {
defer test.MockVariableValue(&setting.Service.EnableInternalSignIn, false)()
@@ -107,6 +111,7 @@ func TestDisableSignin(t *testing.T) {
resp := MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
htmlDoc.AssertElement(t, "form[action='/user/login']", false)
+ htmlDoc.AssertElement(t, ".divider-text", false)
})
t.Run("Signin", func(t *testing.T) {
@@ -126,6 +131,7 @@ func TestDisableSignin(t *testing.T) {
resp := MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
htmlDoc.AssertElement(t, "form[action='/user/login']", true)
+ htmlDoc.AssertElement(t, ".divider-text", true)
})
t.Run("Signin", func(t *testing.T) {
diff --git a/tests/integration/signup_test.go b/tests/integration/signup_test.go
index d5df41fabf..39533bbf89 100644
--- a/tests/integration/signup_test.go
+++ b/tests/integration/signup_test.go
@@ -1,4 +1,5 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
+// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package integration
@@ -207,3 +208,28 @@ func TestSignupImageCaptcha(t *testing.T) {
unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "captcha-test", IsActive: true})
}
+
+func TestSignupFormUI(t *testing.T) {
+ defer tests.PrepareTestEnv(t)()
+ t.Run("UI", func(t *testing.T) {
+ // Mock alternative auth ways as enabled
+ defer test.MockVariableValue(&setting.Service.EnableOpenIDSignIn, true)()
+ defer test.MockVariableValue(&setting.Service.EnableOpenIDSignUp, true)()
+ t.Run("Internal registration enabled", func(t *testing.T) {
+ defer test.MockVariableValue(&setting.Service.AllowOnlyExternalRegistration, false)()
+ req := NewRequest(t, "GET", "/user/sign_up")
+ resp := MakeRequest(t, req, http.StatusOK)
+ htmlDoc := NewHTMLParser(t, resp.Body)
+ htmlDoc.AssertElement(t, "form[action='/user/sign_up'] input#user_name", true)
+ htmlDoc.AssertElement(t, ".divider-text", true)
+ })
+ t.Run("Internal registration disabled", func(t *testing.T) {
+ defer test.MockVariableValue(&setting.Service.AllowOnlyExternalRegistration, true)()
+ req := NewRequest(t, "GET", "/user/sign_up")
+ resp := MakeRequest(t, req, http.StatusOK)
+ htmlDoc := NewHTMLParser(t, resp.Body)
+ htmlDoc.AssertElement(t, "form[action='/user/sign_up'] input#user_name", false)
+ htmlDoc.AssertElement(t, ".divider-text", false)
+ })
+ })
+}