File view with blame information shown in the left gutter beside each line.

barerepo / server / e2e/tabs_test.go
68 lines · 2.1kb · 133728eaa05486504991b230f9d4c7e986b7defc
log files threads runs releases config jump to file t
133728e barerepo 1mo
1
package e2e
133728e barerepo 1mo
2
133728e barerepo 1mo
3
import (
133728e barerepo 1mo
4
"net/http"
133728e barerepo 1mo
5
"net/url"
133728e barerepo 1mo
6
"os/exec"
133728e barerepo 1mo
7
"strings"
133728e barerepo 1mo
8
"testing"
133728e barerepo 1mo
9
)
133728e barerepo 1mo
10
133728e barerepo 1mo
11
// Every mockup carries the open thread count in the tab strip, not only the threads page itself.
133728e barerepo 1mo
12
func TestTheOpenThreadCountIsOnEveryRepositoryPage(t *testing.T) {
133728e barerepo 1mo
13
if _, err := exec.LookPath("git"); err != nil {
133728e barerepo 1mo
14
t.Skip("git is not installed")
133728e barerepo 1mo
15
}
133728e barerepo 1mo
16
in := newInstance(t)
133728e barerepo 1mo
17
john := in.account("john")
133728e barerepo 1mo
18
seed(t, in, john, "john", "johnbot")
133728e barerepo 1mo
19
133728e barerepo 1mo
20
for i := 0; i < 2; i++ {
133728e barerepo 1mo
21
resp := post(t, in, "john", "/john/johnbot/threads", url.Values{
133728e barerepo 1mo
22
"title": {"something is wrong"},
133728e barerepo 1mo
23
"body": {"it does the thing"},
133728e barerepo 1mo
24
})
133728e barerepo 1mo
25
if resp.StatusCode != http.StatusFound {
133728e barerepo 1mo
26
t.Fatalf("opening a thread answered %d", resp.StatusCode)
133728e barerepo 1mo
27
}
133728e barerepo 1mo
28
}
133728e barerepo 1mo
29
133728e barerepo 1mo
30
for _, path := range []string{"", "/files", "/runs", "/config", "/releases", "/threads"} {
133728e barerepo 1mo
31
code, _, body := get(t, in.http.URL+"/john/johnbot"+path)
133728e barerepo 1mo
32
if code != http.StatusOK {
133728e barerepo 1mo
33
t.Errorf("%s answered %d", path, code)
133728e barerepo 1mo
34
continue
133728e barerepo 1mo
35
}
133728e barerepo 1mo
36
if !strings.Contains(body, "threads 2") {
133728e barerepo 1mo
37
t.Errorf("the tab strip on %q does not carry the open count", path)
133728e barerepo 1mo
38
}
133728e barerepo 1mo
39
}
133728e barerepo 1mo
40
133728e barerepo 1mo
41
// The thread page footer says it too, per thread.html.
133728e barerepo 1mo
42
if _, _, body := get(t, in.http.URL+"/john/johnbot/thread/1"); !strings.Contains(body, "2 open") {
133728e barerepo 1mo
43
t.Errorf("the thread page footer does not say how many are open:\n%s", body)
133728e barerepo 1mo
44
}
133728e barerepo 1mo
45
}
133728e barerepo 1mo
46
133728e barerepo 1mo
47
// Chapter 24 puts the open proposal count on each repository row of a profile.
133728e barerepo 1mo
48
func TestAProfileRowNamesTheOpenProposalCount(t *testing.T) {
133728e barerepo 1mo
49
if _, err := exec.LookPath("git"); err != nil {
133728e barerepo 1mo
50
t.Skip("git is not installed")
133728e barerepo 1mo
51
}
133728e barerepo 1mo
52
in := newInstance(t)
133728e barerepo 1mo
53
john := in.account("john")
133728e barerepo 1mo
54
seed(t, in, john, "john", "johnbot")
133728e barerepo 1mo
55
133728e barerepo 1mo
56
if _, _, body := get(t, in.http.URL+"/john"); strings.Contains(body, "proposal") {
133728e barerepo 1mo
57
t.Fatalf("a repository with no proposals counts them anyway:\n%s", body)
133728e barerepo 1mo
58
}
133728e barerepo 1mo
59
133728e barerepo 1mo
60
work := clone(t, in, john, "/john/johnbot")
133728e barerepo 1mo
61
commit(t, work, "package main\n\nfunc main() {}\n", "a proposal")
133728e barerepo 1mo
62
run(t, work, "git", "push", "-q", in.url(john, "/john/johnbot"), "HEAD:refs/proposals/new")
133728e barerepo 1mo
63
133728e barerepo 1mo
64
_, _, body := get(t, in.http.URL+"/john")
133728e barerepo 1mo
65
if !strings.Contains(body, "1 proposal") {
133728e barerepo 1mo
66
t.Errorf("the profile row does not name the open proposal:\n%s", body)
133728e barerepo 1mo
67
}
133728e barerepo 1mo
68
}
history · rawbarerepo 0.1.0