Skip to content

Commit 0677c81

Browse files
committed
add more tests
1 parent 99c4b1c commit 0677c81

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

templates/repo/view_list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
{{else}}
4343
<a class="entry-name" href="{{$.TreeLink}}/{{PathEscapeSegments $entry.Name}}" title="{{$entry.Name}}">{{$entry.Name}}</a>
4444
{{if $entry.IsLink}}
45-
<a class="flex-text-inline" href="{{$.TreeLink}}/{{PathEscapeSegments $entry.Name}}?follow_symlink=1">{{svg "octicon-link" 12}}</a>
45+
<a class="entry-symbol-link flex-text-inline" href="{{$.TreeLink}}/{{PathEscapeSegments $entry.Name}}?follow_symlink=1">{{svg "octicon-link" 12}}</a>
4646
{{end}}
4747
{{end}}
4848
{{end}}

tests/integration/repo_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
"github.com/PuerkitoBio/goquery"
2929
"github.com/stretchr/testify/assert"
30+
"github.com/stretchr/testify/require"
3031
)
3132

3233
func TestRepoView(t *testing.T) {
@@ -41,6 +42,7 @@ func TestRepoView(t *testing.T) {
4142
t.Run("BlameFileInRepo", testBlameFileInRepo)
4243
t.Run("ViewRepoDirectory", testViewRepoDirectory)
4344
t.Run("ViewRepoDirectoryReadme", testViewRepoDirectoryReadme)
45+
t.Run("ViewRepoSymlink", testViewRepoSymlink)
4446
t.Run("MarkDownReadmeImage", testMarkDownReadmeImage)
4547
t.Run("MarkDownReadmeImageSubfolder", testMarkDownReadmeImageSubfolder)
4648
t.Run("GeneratedSourceLink", testGeneratedSourceLink)
@@ -412,6 +414,21 @@ func testViewRepoDirectoryReadme(t *testing.T) {
412414
missing("symlink-loop", "/user2/readme-test/src/branch/symlink-loop/")
413415
}
414416

417+
func testViewRepoSymlink(t *testing.T) {
418+
session := loginUser(t, "user2")
419+
req := NewRequest(t, "GET", "/user2/readme-test/src/branch/symlink")
420+
resp := session.MakeRequest(t, req, http.StatusOK)
421+
422+
htmlDoc := NewHTMLParser(t, resp.Body)
423+
AssertHTMLElement(t, htmlDoc, ".entry-symbol-link", true)
424+
followSymbolLinkHref := htmlDoc.Find(".entry-symbol-link").AttrOr("href", "")
425+
require.Equal(t, "/user2/readme-test/src/branch/symlink/README.md?follow_symlink=1", followSymbolLinkHref)
426+
427+
req = NewRequest(t, "GET", followSymbolLinkHref)
428+
resp = session.MakeRequest(t, req, http.StatusSeeOther)
429+
assert.Equal(t, "/user2/readme-test/src/branch/symlink/some/other/path/awefulcake.txt?follow_symlink=1", resp.Header().Get("Location"))
430+
}
431+
415432
func testMarkDownReadmeImage(t *testing.T) {
416433
defer tests.PrintCurrentTest(t)()
417434

0 commit comments

Comments
 (0)