vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Move channel forms off the releases page
ea6ce9fe5d829a7f4153793f0a096d00331f7e29 · Keenan Nemetz · 17d ago · parent de72893e
Move channel forms off the releases page Create and edit channels on focused release subpages, leaving the releases page with the read-only channel list and its row actions. The new-release target is now a grouped branch and tag picker instead of a free-text field, matching the channel form's selection of annotated releases.
server/channels_test.go +30−9
| @@ -53,8 +53,8 @@ func TestChannelPageAndTree(t *testing.T) { | |||
| 53 | 53 | t.Fatalf("releases page does not show %q:\n%s", want, page) | |
| 54 | 54 | } | |
| 55 | 55 | } | |
| 56 | if strings.Contains(page, `name="channel"`) { | ||
| 57 | t.Fatalf("anonymous releases page exposes the channel form:\n%s", page) | ||
| 56 | if strings.Contains(page, "/releases/channels/new") { | ||
| 57 | t.Fatalf("anonymous releases page exposes the channel form link:\n%s", page) | ||
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | 60 | if code, release := f.get("/" + f.repo + "/releases/v1.0.0"); code != 200 || | |
| @@ -107,14 +107,27 @@ func TestChannelWriteFromTheBrowser(t *testing.T) { | |||
| 107 | 107 | f := releaseFixture(t) | |
| 108 | 108 | sess, cookie := f.browserSession(t, f.ownerID) | |
| 109 | 109 | ||
| 110 | // The maintainer sees the form; the list itself stays readable to everyone. | ||
| 110 | // The maintainer sees the link to the form; the list itself stays readable to | ||
| 111 | // everyone. | ||
| 111 | 112 | _, page := f.browserGet(t, "/"+f.repo+"/releases", cookie) | |
| 112 | for _, want := range []string{"New channel", `name="channel"`, `name="tag"`} { | ||
| 113 | for _, want := range []string{"New channel", "/releases/channels/new"} { | ||
| 113 | 114 | if !strings.Contains(page, want) { | |
| 114 | 115 | t.Fatalf("maintainer releases page does not show %q:\n%s", want, page) | |
| 115 | 116 | } | |
| 116 | 117 | } | |
| 117 | 118 | ||
| 119 | // The form selects an annotated release; a channel cannot name a tag that is | ||
| 120 | // not a release, so there is no free-text target to get wrong. | ||
| 121 | _, page = f.browserGet(t, "/"+f.repo+"/releases/channels/new", cookie) | ||
| 122 | for _, want := range []string{`<select name="tag"`, "New channel", `value="v1.0.0"`, `value="v0.9.0"`} { | ||
| 123 | if !strings.Contains(page, want) { | ||
| 124 | t.Fatalf("new channel form does not show %q:\n%s", want, page) | ||
| 125 | } | ||
| 126 | } | ||
| 127 | if strings.Contains(page, `value="scratch-tag"`) { | ||
| 128 | t.Fatalf("channel form offers a lightweight tag:\n%s", page) | ||
| 129 | } | ||
| 130 | |||
| 118 | 131 | resp, body := f.browserPost(t, "/"+f.repo+"/channels", cookie, url.Values{ | |
| 119 | 132 | "csrf": {sess.CSRF}, "channel": {"stable"}, "tag": {"v1.0.0"}, | |
| 120 | 133 | "description": {"Recommended for production."}, | |
| @@ -125,16 +138,16 @@ func TestChannelWriteFromTheBrowser(t *testing.T) { | |||
| 125 | 138 | if got := resp.Header.Get("Location"); got != "/"+f.repo+"/releases#channels" { | |
| 126 | 139 | t.Fatalf("create channel Location = %q", got) | |
| 127 | 140 | } | |
| 128 | _, page = f.get("/" + f.repo + "/releases") | ||
| 129 | for _, want := range []string{"Recommended for production.", "v1.0.0", "/channels/stable"} { | ||
| 141 | _, page = f.browserGet(t, "/"+f.repo+"/releases", cookie) | ||
| 142 | for _, want := range []string{"Recommended for production.", "v1.0.0", "/channels/stable", "/releases/channels/edit?channel=stable"} { | ||
| 130 | 143 | if !strings.Contains(page, want) { | |
| 131 | 144 | t.Fatalf("releases page after create does not show %q:\n%s", want, page) | |
| 132 | 145 | } | |
| 133 | 146 | } | |
| 134 | 147 | ||
| 135 | // The edit link opens the same form with the current target and description. | ||
| 136 | _, page = f.browserGet(t, "/"+f.repo+"/releases?channel=stable", cookie) | ||
| 137 | for _, want := range []string{"Edit channel stable", `value="v1.0.0"`, "Recommended for production."} { | ||
| 148 | // The edit page selects the current target and keeps the description. | ||
| 149 | _, page = f.browserGet(t, "/"+f.repo+"/releases/channels/edit?channel=stable", cookie) | ||
| 150 | for _, want := range []string{"Edit channel stable", `value="v1.0.0" selected`, "Recommended for production."} { | ||
| 138 | 151 | if !strings.Contains(page, want) { | |
| 139 | 152 | t.Fatalf("edit channel form does not show %q:\n%s", want, page) | |
| 140 | 153 | } | |
| @@ -199,6 +212,11 @@ func TestChannelDanglingTarget(t *testing.T) { | |||
| 199 | 212 | if code != 200 || !strings.Contains(page, "dangling") || !strings.Contains(page, "v9.9.9") { | |
| 200 | 213 | t.Fatalf("releases page = %d, want a dangling marker:\n%s", code, page) | |
| 201 | 214 | } | |
| 215 | _, cookie := f.browserSession(t, f.ownerID) | ||
| 216 | if code, form := f.browserGet(t, "/"+f.repo+"/releases/channels/edit?channel=stable", cookie); code.StatusCode != 200 || | ||
| 217 | !strings.Contains(form, "no longer a valid annotated release") || !strings.Contains(form, "v9.9.9") { | ||
| 218 | t.Fatalf("dangling channel form = %d, want the missing target:\n%s", code.StatusCode, form) | ||
| 219 | } | ||
| 202 | 220 | if code, _ := f.get("/" + f.repo + "/channels/stable"); code != 404 { | |
| 203 | 221 | t.Fatalf("dangling channel = %d, want 404", code) | |
| 204 | 222 | } | |
| @@ -240,6 +258,9 @@ func TestChannelMoveRequiresMaintain(t *testing.T) { | |||
| 240 | 258 | }); resp.StatusCode != http.StatusNotFound { | |
| 241 | 259 | t.Fatalf("contributor channel write = %d, want 404", resp.StatusCode) | |
| 242 | 260 | } | |
| 261 | if resp, _ := f.browserGet(t, "/"+f.repo+"/releases/channels/new", contribCookie); resp.StatusCode != http.StatusNotFound { | ||
| 262 | t.Fatalf("contributor channel form = %d, want 404", resp.StatusCode) | ||
| 263 | } | ||
| 243 | 264 | ||
| 244 | 265 | setChannelCLI(t, f, f.addWriter(t), work, "stable", "v1.0.0", "moved") | |
| 245 | 266 | audit, err := os.ReadFile(f.cfg.AuditLog()) | |