From ca5f3028763f82dfe2491d3e408afbc369ec2a73 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 29 May 2023 23:00:21 +0800 Subject: [PATCH] Fix admin config page error, use tests to cover the admin config and 500 error page (#24965) The admin config page has been broken for many many times, a little refactoring would make this page panic. So, add a test for it, and add another test to cover the 500 error page. Co-authored-by: Giteabot --- modules/test/utils.go | 5 ++++ options/locale/locale_en-US.ini | 2 -- routers/common/errpage.go | 2 +- routers/common/errpage_test.go | 41 ++++++++++++++++++++++++++ templates/admin/config.tmpl | 10 ------- tests/integration/admin_config_test.go | 23 +++++++++++++++ 6 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 routers/common/errpage_test.go create mode 100644 tests/integration/admin_config_test.go diff --git a/modules/test/utils.go b/modules/test/utils.go index 7686d3f289..282895eaa9 100644 --- a/modules/test/utils.go +++ b/modules/test/utils.go @@ -5,9 +5,14 @@ package test import ( "net/http" + "strings" ) // RedirectURL returns the redirect URL of a http response. func RedirectURL(resp http.ResponseWriter) string { return resp.Header().Get("Location") } + +func IsNormalPageCompleted(s string) bool { + return strings.Contains(s, `