[TESTS] webhook forms keep submitted data when invalid

This commit is contained in:
oliverpool 2024-03-23 22:43:44 +01:00
parent 1e050d01c0
commit 635230ca5d
3 changed files with 42 additions and 15 deletions

View file

@ -330,7 +330,16 @@ func testWebhookForms(name string, session *TestSession, validFields map[string]
}
}
session.MakeRequest(t, NewRequestWithValues(t, "POST", "/user2/repo1/settings/hooks/"+name+"/new", payload), http.StatusUnprocessableEntity)
resp := session.MakeRequest(t, NewRequestWithValues(t, "POST", "/user2/repo1/settings/hooks/"+name+"/new", payload), http.StatusUnprocessableEntity)
// check that the invalid form is pre-filled
htmlForm = NewHTMLParser(t, resp.Body).Find(`form[action^="/user2/repo1/settings/hooks/"]`)
for k, v := range payload {
if k == "_csrf" || k == "events" || v == "" {
// the 'events' is a radio input, which is buggy below
continue
}
assert.Equal(t, v, assertInput(t, htmlForm, k), "input %q did not contain value %q", k, v)
}
if t.Failed() {
t.Log(invalidPatch)
}