package e2e import ( "net/url" "os" "path/filepath" "strings" "testing" ) // TestIssueMRWebFormat covers the format picker on the issue and merge // request create forms (#160). Neither form offered --format before; a // browser session could only ever write markdown. func TestIssueMRWebFormat(t *testing.T) { inst := startInstanceWith(t, "[web]\nmode = \"accounts\"\n") aliceKey := inst.newKey(t, "alice") inst.admin(t, "admin", "user", "create", "alice", "--key", aliceKey+".pub", "--email", "alice@example.test", "--verified") if _, errOut, code := inst.ssh(t, aliceKey, "", "repo", "create", "alice/app"); code != 0 { t.Fatalf("repo create: %s", errOut) } env := inst.gitEnv(aliceKey) work := t.TempDir() mustGit(t, work, env, "clone", inst.sshURL("alice/app"), "w") dir := filepath.Join(work, "w") mustGit(t, dir, env, "checkout", "-q", "-b", "main") os.WriteFile(filepath.Join(dir, "a.txt"), []byte("a\n"), 0o644) mustGit(t, dir, env, "add", ".") mustGit(t, dir, env, "commit", "-q", "-m", "base") mustGit(t, dir, env, "push", "-q", "origin", "main") mustGit(t, dir, env, "checkout", "-q", "-b", "topic") os.WriteFile(filepath.Join(dir, "b.txt"), []byte("b\n"), 0o644) mustGit(t, dir, env, "add", ".") mustGit(t, dir, env, "commit", "-q", "-m", "topic") mustGit(t, dir, env, "push", "-q", "origin", "topic") alice := inst.login(t, aliceKey) base := inst.base() + "/alice/app" const orgBody = "Some /emphasis/ here.\n" // The picker is on both forms, defaulting to Markdown. for _, form := range []string{base + "/issues/new", base + "/mrs/new"} { if _, body := browserGet(t, alice, form); !strings.Contains(body, `name="format"`) || !strings.Contains(body, `