package plan3test
import (
"strconv"
"strings"
"testing"
"amadan.net/oficina/equipo/internal/equipo"
"amadan.net/oficina/equipo/internal/equipo/library"
"amadan.net/oficina/equipo/internal/taskplan"
)
func TestPlaybookForms(t *testing.T) {
f := newFixture(t)
base := f.createTask(t)
w := formPost(t, f, owner, "/playbooks", playbookForm(playbookInput("Browser saved"), "browser", 0))
expectHTTP(t, w, 303)
path := w.Header().Get("Location")
id := strings.TrimSuffix(strings.TrimPrefix(path, "/playbooks/"), "/edit")
row, err := f.Store.Playbook(ctx, owner, id)
must(t, err)
in := library.PlaybookFields(row)
in.Steps[0].Instructions = "Browser edit"
expectHTTP(t, formPost(t, f, owner, path, playbookForm(in, "edit", 1)), 303)
expectHTTP(t, formPost(t, f, owner, path, playbookForm(in, "edit", 1)), 303)
expectHTTP(t, formPost(t, f, owner, path, playbookForm(in, "stale", 1)), 409)
v := actionForm("default", 0)
v.Set("project_id", strconv.FormatInt(base.ProjectID, 10))
v.Set("kind", "bug")
v.Set("playbook_id", row.ID)
expectHTTP(t, formPost(t, f, owner, "/playbooks/defaults", v), 303)
f.exec(t, "UPDATE members SET role='member' WHERE address=?", peer.Address)
w = f.get(t, peer, "/playbooks/"+id)
expectHTTP(t, w, 200)
if !strings.Contains(w.Body.String(), "