Add dashboard / description page

This commit is contained in:
2026-07-28 09:58:49 +02:00
parent 60d64dedb2
commit 43fa047765
9 changed files with 465 additions and 51 deletions

View File

@@ -89,12 +89,17 @@ func TestGetPullRequestUsesOriginalLineAndMetadata(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte(`{"data":{"repository":{"pullRequest":{
"id":"pr","number":9,"title":"Fix","url":"u","body":"body","isDraft":false,
"updatedAt":"2026-01-01T00:00:00Z","mergeable":"MERGEABLE","reviewDecision":"APPROVED",
"createdAt":"2025-12-01T00:00:00Z","updatedAt":"2026-01-01T00:00:00Z",
"mergeable":"MERGEABLE","mergeStateStatus":"CLEAN","reviewDecision":"APPROVED",
"additions":12,"deletions":4,"changedFiles":3,
"baseRefName":"main","headRefName":"fix","author":{"login":"zam"},
"assignees":{"nodes":[{"login":"sam"}]},
"labels":{"nodes":[{"name":"bug"},{"name":"backend"}]},
"milestone":{"title":"v2"},
"comments":{"totalCount":5},
"reviewRequests":{"nodes":[{"requestedReviewer":{"login":"lee"}}]},
"latestReviews":{"nodes":[{"state":"CHANGES_REQUESTED","author":{"login":"pat"}}]},
"commits":{"nodes":[{"commit":{"statusCheckRollup":{"state":"FAILURE"}}}]},
"commits":{"totalCount":7,"nodes":[{"commit":{"statusCheckRollup":{"state":"FAILURE"}}}]},
"reviewThreads":{"pageInfo":{"hasNextPage":false},"nodes":[{
"id":"t","isResolved":false,"isOutdated":true,"path":"main.go",
"line":null,"originalLine":42,"diffSide":"RIGHT",
@@ -118,6 +123,12 @@ func TestGetPullRequestUsesOriginalLineAndMetadata(t *testing.T) {
if got.CheckState != "FAILURE" || got.BaseRef != "main" || got.HeadRef != "fix" || got.ReviewDecision != "APPROVED" {
t.Fatalf("unexpected metadata: %#v", got)
}
if got.MergeState != "CLEAN" || got.Additions != 12 || got.Deletions != 4 ||
got.ChangedFiles != 3 || got.CommitCount != 7 || got.CommentCount != 5 ||
got.Milestone != "v2" || strings.Join(got.Labels, ",") != "bug,backend" ||
got.CreatedAt.IsZero() {
t.Fatalf("unexpected dashboard metadata: %#v", got)
}
if len(got.Threads) != 1 || got.Threads[0].Line != 42 || got.Threads[0].StartLine != 40 ||
got.Threads[0].DiffSide != "RIGHT" || !got.Threads[0].IsTruncated {
t.Fatalf("unexpected thread: %#v", got.Threads)