vole
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software:2222/vole.git
A free and open-source forge that lives in your Git repo.
|
cd71b776
Keenan Nemetz
13d ago
|
1 | package server_test |
| 2 | ||
| 3 | // The global bar: which destinations it offers, and which one it says you are on. | |
| 4 | ||
| 5 | import ( | |
| 6 | "net/http" | |
| 7 | "strings" | |
| 8 | "testing" | |
| 9 | ) | |
| 10 | ||
|
796ac8c0
Keenan Nemetz
12d ago
|
11 | // TestHomeIsTheGlobalDestination: the bar needs a text destination for the |
|
6c03e6d3
Keenan Nemetz
10d ago
|
12 | // landing page. The emblem links there too, but a mark is not a label. Home is |
| 13 | // current only on the landing page: a repository page has its own tabs saying | |
| 14 | // where the reader is, so the global bar must not claim they are on Home. | |
|
796ac8c0
Keenan Nemetz
12d ago
|
15 | func TestHomeIsTheGlobalDestination(t *testing.T) { |
|
cd71b776
Keenan Nemetz
13d ago
|
16 | t.Parallel() |
| 17 | f := newFixture(t) | |
| 18 | f.publish(f.repo) | |
| 19 | ||
|
6c03e6d3
Keenan Nemetz
10d ago
|
20 | code, body := f.get("/") |
| 21 | if code != http.StatusOK { | |
| 22 | t.Fatalf("/ = %d", code) | |
| 23 | } | |
| 24 | if !strings.Contains(body, ">Home</a>") { | |
| 25 | t.Fatalf("/ has no Home link:\n%s", body) | |
| 26 | } | |
| 27 | if !strings.Contains(body, `class="active" href="/" aria-current="page"`) { | |
| 28 | t.Fatalf("/ does not mark Home current:\n%s", body) | |
| 29 | } | |
| 30 | if !strings.Contains(body, `class="icon"`) { | |
| 31 | t.Fatalf("/ renders the Home link without an icon") | |
| 32 | } | |
| 33 | ||
| 34 | // A repository page is not the landing page. Its own header tabs carry the | |
| 35 | // context, so Home must not take that role from them. | |
|
ed03b3d1
Keenan Nemetz
11h ago
|
36 | code, body = f.get("/" + f.repo) |
|
6c03e6d3
Keenan Nemetz
10d ago
|
37 | if code != http.StatusOK { |
|
ed03b3d1
Keenan Nemetz
11h ago
|
38 | t.Fatalf("/%s = %d", f.repo, code) |
|
6c03e6d3
Keenan Nemetz
10d ago
|
39 | } |
| 40 | if strings.Contains(body, `class="active" href="/"`) { | |
| 41 | t.Fatalf("repository page marks Home current:\n%s", body) | |
|
cd71b776
Keenan Nemetz
13d ago
|
42 | } |
| 43 | ||
|
6c03e6d3
Keenan Nemetz
10d ago
|
44 | // Activity is a different destination, so it takes over, which is what makes |
| 45 | // the bar say where you are. | |
|
ed03b3d1
Keenan Nemetz
11h ago
|
46 | code, body = f.get("/-/activity") |
|
cd71b776
Keenan Nemetz
13d ago
|
47 | if code != http.StatusOK { |
|
ed03b3d1
Keenan Nemetz
11h ago
|
48 | t.Fatalf("/-/activity = %d", code) |
|
cd71b776
Keenan Nemetz
13d ago
|
49 | } |
| 50 | if strings.Contains(body, `class="active" href="/"`) { | |
|
ed03b3d1
Keenan Nemetz
11h ago
|
51 | t.Fatalf("/-/activity marks Home current:\n%s", body) |
|
cd71b776
Keenan Nemetz
13d ago
|
52 | } |
|
ed03b3d1
Keenan Nemetz
11h ago
|
53 | if !strings.Contains(body, `class="active" href="/-/activity"`) { |
| 54 | t.Fatalf("/-/activity does not mark Activity current:\n%s", body) | |
|
cd71b776
Keenan Nemetz
13d ago
|
55 | } |
| 56 | } |