package e2e import ( "net/http" "net/url" "os/exec" "strings" "testing" ) // Every mockup carries the open thread count in the tab strip, not only the threads page itself. func TestTheOpenThreadCountIsOnEveryRepositoryPage(t *testing.T) { if _, err := exec.LookPath("git"); err != nil { t.Skip("git is not installed") } in := newInstance(t) john := in.account("john") seed(t, in, john, "john", "johnbot") for i := 0; i < 2; i++ { resp := post(t, in, "john", "/john/johnbot/threads", url.Values{ "title": {"something is wrong"}, "body": {"it does the thing"}, }) if resp.StatusCode != http.StatusFound { t.Fatalf("opening a thread answered %d", resp.StatusCode) } } for _, path := range []string{"", "/files", "/runs", "/config", "/releases", "/threads"} { code, _, body := get(t, in.http.URL+"/john/johnbot"+path) if code != http.StatusOK { t.Errorf("%s answered %d", path, code) continue } if !strings.Contains(body, "threads 2") { t.Errorf("the tab strip on %q does not carry the open count", path) } } // The thread page footer says it too, per thread.html. if _, _, body := get(t, in.http.URL+"/john/johnbot/thread/1"); !strings.Contains(body, "2 open") { t.Errorf("the thread page footer does not say how many are open:\n%s", body) } } // Chapter 24 puts the open proposal count on each repository row of a profile. func TestAProfileRowNamesTheOpenProposalCount(t *testing.T) { if _, err := exec.LookPath("git"); err != nil { t.Skip("git is not installed") } in := newInstance(t) john := in.account("john") seed(t, in, john, "john", "johnbot") if _, _, body := get(t, in.http.URL+"/john"); strings.Contains(body, "proposal") { t.Fatalf("a repository with no proposals counts them anyway:\n%s", body) } work := clone(t, in, john, "/john/johnbot") commit(t, work, "package main\n\nfunc main() {}\n", "a proposal") run(t, work, "git", "push", "-q", in.url(john, "/john/johnbot"), "HEAD:refs/proposals/new") _, _, body := get(t, in.http.URL+"/john") if !strings.Contains(body, "1 proposal") { t.Errorf("the profile row does not name the open proposal:\n%s", body) } }