forked from forgejo/forgejo
Improved comment rendering in "Files" view by adding Comments to DiffLine
Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
parent
58fb672d0d
commit
066086c390
9 changed files with 112 additions and 26 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
dmp "github.com/sergi/go-diff/diffmatchpatch"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func assertEqual(t *testing.T, s1 string, s2 template.HTML) {
|
||||
|
@ -34,3 +35,28 @@ func TestDiffToHTML(t *testing.T) {
|
|||
{Type: dmp.DiffEqual, Text: " biz"},
|
||||
}, DiffLineDel))
|
||||
}
|
||||
|
||||
func TestDiff_LoadComments(t *testing.T) {
|
||||
assert.NoError(t, PrepareTestDatabase())
|
||||
issue := AssertExistsAndLoadBean(t, &Issue{ID: 2}).(*Issue)
|
||||
user := AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
|
||||
diff := &Diff{
|
||||
Files: []*DiffFile{
|
||||
{
|
||||
Name: "README.md",
|
||||
Sections: []*DiffSection{
|
||||
{
|
||||
Lines: []*DiffLine{
|
||||
{
|
||||
LeftIdx: 4,
|
||||
RightIdx: 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
assert.NoError(t, diff.LoadComments(issue, user))
|
||||
assert.Len(t, diff.Files[0].Sections[0].Lines[0].Comments, 2)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue