Show conflicts to parent branch
This commit is contained in:
48
tui_test.go
48
tui_test.go
@@ -327,6 +327,54 @@ func TestDashboardRendersDescriptionAndMetadata(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDashboardShowsConflictStateAndFiles(t *testing.T) {
|
||||
m := NewApp(nil, "o", "r", false, 50, 10*time.Second)
|
||||
m.screen, m.width, m.height = dashboardScreen, 100, 40
|
||||
m.details = PRDetails{
|
||||
PullRequest: PullRequest{RepoWithOwner: "o/r", Number: 1, Title: "Conflict"},
|
||||
BaseRef: "main", HeadRef: "feature", Mergeable: "CONFLICTING",
|
||||
ConflictFiles: []string{"src/one.go", "docs/two.md"},
|
||||
}
|
||||
plain := ansi.Strip(strings.Join(m.dashboardLines(), "\n"))
|
||||
for _, wanted := range []string{
|
||||
"conflicts", "2 conflicting files", "Conflicting files (2)", "src/one.go", "docs/two.md",
|
||||
} {
|
||||
if !strings.Contains(plain, wanted) {
|
||||
t.Fatalf("conflict dashboard is missing %q:\n%s", wanted, plain)
|
||||
}
|
||||
}
|
||||
|
||||
m.details.Mergeable = "MERGEABLE"
|
||||
m.details.ConflictFiles = nil
|
||||
plain = ansi.Strip(strings.Join(m.dashboardLines(), "\n"))
|
||||
if !strings.Contains(plain, "conflicts") || !strings.Contains(plain, "none") ||
|
||||
strings.Contains(plain, "Conflicting files (") {
|
||||
t.Fatalf("clean dashboard conflict state is unclear:\n%s", plain)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDashboardWrapsConflictScanWarning(t *testing.T) {
|
||||
m := NewApp(nil, "o", "r", false, 50, 10*time.Second)
|
||||
m.screen, m.width, m.height = dashboardScreen, 48, 30
|
||||
m.details = PRDetails{
|
||||
PullRequest: PullRequest{RepoWithOwner: "o/r", Number: 1, Title: "Conflict"},
|
||||
BaseRef: "main", HeadRef: "feature", Mergeable: "CONFLICTING",
|
||||
ConflictFileError: "fetch merge inputs: fatal: could not read Username for 'https://github.com': terminal prompts disabled",
|
||||
}
|
||||
lines := dashboardMetadataLines("conflicts", conflictStateText(m.details), m.width-2)
|
||||
plain := ansi.Strip(strings.Join(lines, "\n"))
|
||||
normalized := strings.Join(strings.Fields(plain), " ")
|
||||
if !strings.Contains(normalized, "file scan unavailable") ||
|
||||
!strings.Contains(normalized, "terminal prompts disabled") {
|
||||
t.Fatalf("wrapped conflict warning lost information:\n%s", plain)
|
||||
}
|
||||
for index, line := range lines {
|
||||
if width := ansi.StringWidth(line); width > m.width-2 {
|
||||
t.Fatalf("dashboard line %d width = %d:\n%s", index, width, plain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDashboardCompactsSubmittedReviewsByDefault(t *testing.T) {
|
||||
m := NewApp(nil, "o", "r", false, 50, 10*time.Second)
|
||||
m.width = 100
|
||||
|
||||
Reference in New Issue
Block a user