loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request '[BUG] Fix crash in issue forms' (#3012) from gusted/forgejo-crash into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3012
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>

+57 -3
+6 -3
modules/markup/html.go
··· 1065 1065 1066 1066 next := node.NextSibling 1067 1067 for node != nil && node != next { 1068 - locale, ok := ctx.Ctx.Value(translation.ContextKey).(translation.Locale) 1069 - if !ok { 1070 - locale = translation.NewLocale("en-US") 1068 + locale := translation.NewLocale("en-US") 1069 + if ctx.Ctx != nil { 1070 + ctxLocale, ok := ctx.Ctx.Value(translation.ContextKey).(translation.Locale) 1071 + if ok { 1072 + locale = ctxLocale 1073 + } 1071 1074 } 1072 1075 1073 1076 preview := NewFilePreview(ctx, node, locale)
+51
tests/integration/issue_test.go
··· 18 18 "code.gitea.io/gitea/models/db" 19 19 issues_model "code.gitea.io/gitea/models/issues" 20 20 repo_model "code.gitea.io/gitea/models/repo" 21 + unit_model "code.gitea.io/gitea/models/unit" 21 22 "code.gitea.io/gitea/models/unittest" 22 23 user_model "code.gitea.io/gitea/models/user" 23 24 "code.gitea.io/gitea/modules/indexer/issues" ··· 25 26 "code.gitea.io/gitea/modules/setting" 26 27 api "code.gitea.io/gitea/modules/structs" 27 28 "code.gitea.io/gitea/modules/test" 29 + files_service "code.gitea.io/gitea/services/repository/files" 28 30 "code.gitea.io/gitea/tests" 29 31 30 32 "github.com/PuerkitoBio/goquery" ··· 815 817 assert.Equal(t, "nofollow", rel) 816 818 }) 817 819 } 820 + 821 + func TestIssueForm(t *testing.T) { 822 + onGiteaRun(t, func(t *testing.T, u *url.URL) { 823 + user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) 824 + session := loginUser(t, user2.Name) 825 + repo, _, f := CreateDeclarativeRepo(t, user2, "", 826 + []unit_model.Type{unit_model.TypeCode, unit_model.TypeIssues}, nil, 827 + []*files_service.ChangeRepoFile{ 828 + { 829 + Operation: "create", 830 + TreePath: ".forgejo/issue_template/test.yaml", 831 + ContentReader: strings.NewReader(`name: Test 832 + about: Hello World 833 + body: 834 + - type: checkboxes 835 + id: test 836 + attributes: 837 + label: Test 838 + options: 839 + - label: This is a label 840 + `), 841 + }, 842 + }, 843 + ) 844 + defer f() 845 + 846 + t.Run("Choose list", func(t *testing.T) { 847 + defer tests.PrintCurrentTest(t)() 848 + 849 + req := NewRequest(t, "GET", repo.Link()+"/issues/new/choose") 850 + resp := session.MakeRequest(t, req, http.StatusOK) 851 + htmlDoc := NewHTMLParser(t, resp.Body) 852 + 853 + htmlDoc.AssertElement(t, "a[href$='/issues/new?template=.forgejo%2fissue_template%2ftest.yaml']", true) 854 + }) 855 + 856 + t.Run("Issue template", func(t *testing.T) { 857 + defer tests.PrintCurrentTest(t)() 858 + 859 + req := NewRequest(t, "GET", repo.Link()+"/issues/new?template=.forgejo%2fissue_template%2ftest.yaml") 860 + resp := session.MakeRequest(t, req, http.StatusOK) 861 + htmlDoc := NewHTMLParser(t, resp.Body) 862 + 863 + htmlDoc.AssertElement(t, "#new-issue .field .ui.checkbox input[name='form-field-test-0']", true) 864 + checkboxLabel := htmlDoc.Find("#new-issue .field .ui.checkbox label").Text() 865 + assert.Contains(t, checkboxLabel, "This is a label") 866 + }) 867 + }) 868 + }