Approval-based snapshot testing library for Go (mirror)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: tui improvements

+58 -52
__snapshots__/test_combined_ignore_and_scrub.snap.new __snapshots__/test_combined_ignore_and_scrub.snap
+53 -47
cmd/tui/main.go
··· 17 17 var ( 18 18 titleStyle = lipgloss.NewStyle(). 19 19 Bold(true). 20 - Foreground(lipgloss.Color("205")). 20 + Foreground(lipgloss.AdaptiveColor{Light: "5", Dark: "5"}). // Magenta 21 21 Padding(0, 1) 22 22 23 23 counterStyle = lipgloss.NewStyle(). 24 - Foreground(lipgloss.Color("240")). 24 + Foreground(lipgloss.AdaptiveColor{Light: "8", Dark: "8"}). // Bright black/gray 25 25 Padding(0, 1) 26 26 27 27 helpStyle = lipgloss.NewStyle(). 28 - Foreground(lipgloss.Color("241")). 29 - Background(lipgloss.Color("236")). 28 + Foreground(lipgloss.AdaptiveColor{Light: "8", Dark: "8"}). 29 + Background(lipgloss.AdaptiveColor{Light: "0", Dark: "0"}). 30 30 Padding(0, 0) 31 31 32 32 statusBarStyle = lipgloss.NewStyle(). 33 - Background(lipgloss.Color("236")). 34 - Foreground(lipgloss.Color("230")) 33 + Background(lipgloss.AdaptiveColor{Light: "0", Dark: "0"}). 34 + Foreground(lipgloss.AdaptiveColor{Light: "7", Dark: "7"}) 35 35 36 36 contentStyle = lipgloss.NewStyle(). 37 37 Padding(1, 2) 38 38 39 39 // Action styles with semantic colors 40 40 acceptStyle = lipgloss.NewStyle(). 41 - Foreground(lipgloss.Color("10")). // Green 41 + Foreground(lipgloss.AdaptiveColor{Light: "2", Dark: "2"}). // Green 42 42 Bold(true) 43 43 44 44 rejectStyle = lipgloss.NewStyle(). 45 - Foreground(lipgloss.Color("9")). // Red 45 + Foreground(lipgloss.AdaptiveColor{Light: "1", Dark: "1"}). // Red 46 46 Bold(true) 47 47 48 48 skipStyle = lipgloss.NewStyle(). 49 - Foreground(lipgloss.Color("11")). // Yellow 49 + Foreground(lipgloss.AdaptiveColor{Light: "3", Dark: "3"}). // Yellow 50 50 Bold(true) 51 51 52 52 keyStyle = lipgloss.NewStyle(). 53 - Foreground(lipgloss.Color("241")) 53 + Foreground(lipgloss.AdaptiveColor{Light: "8", Dark: "8"}) 54 54 55 55 helpTextStyle = lipgloss.NewStyle(). 56 - Foreground(lipgloss.Color("240")) 56 + Foreground(lipgloss.AdaptiveColor{Light: "8", Dark: "8"}) 57 57 ) 58 58 59 59 type model struct { ··· 344 344 ) 345 345 headerStyled := statusBarStyle.Width(m.width).Render(header) 346 346 347 - // Footer with scroll info only 348 - // TODO: maybe add snapshot file name to footer? 347 + // Footer with snapshot filename and scroll info 348 + snapshotFile := files.SnapshotFileName(m.snapshots[m.current]) + ".snap.new" 349 + fileInfo := helpStyle.Render(snapshotFile) 349 350 scrollInfo := fmt.Sprintf("%3.f%%", m.viewport.ScrollPercent()*100) 350 351 scrollStyled := helpStyle.Render(scrollInfo) 351 352 352 - // Create footer with just scroll info on the right 353 + // Calculate spacing between filename and scroll percentage 354 + totalFooterWidth := lipgloss.Width(fileInfo) + lipgloss.Width(scrollStyled) 355 + spacing := max(m.width-totalFooterWidth-2, 1) 356 + 357 + // Create footer with filename on left and scroll info on right 353 358 footer := lipgloss.JoinHorizontal(lipgloss.Bottom, 354 - strings.Repeat(" ", max(m.width-lipgloss.Width(scrollStyled)-1, 0)), 359 + fileInfo, 360 + strings.Repeat(" ", spacing), 355 361 scrollStyled, 356 362 ) 357 363 footerStyled := statusBarStyle.Width(m.width).Render(footer) ··· 376 382 return b 377 383 } 378 384 385 + func acceptAll() error { 386 + snapshots, err := files.ListNewSnapshots() 387 + if err != nil { 388 + return err 389 + } 390 + 391 + for _, testName := range snapshots { 392 + if err := files.AcceptSnapshot(testName); err != nil { 393 + return err 394 + } 395 + } 396 + 397 + fmt.Printf(pretty.Success("✓ Accepted %d snapshot(s)\n"), len(snapshots)) 398 + return nil 399 + } 400 + 401 + func rejectAll() error { 402 + snapshots, err := files.ListNewSnapshots() 403 + if err != nil { 404 + return err 405 + } 406 + 407 + for _, testName := range snapshots { 408 + if err := files.RejectSnapshot(testName); err != nil { 409 + return err 410 + } 411 + } 412 + 413 + fmt.Printf(pretty.Warning("⊘ Rejected %d snapshot(s)\n"), len(snapshots)) 414 + return nil 415 + } 416 + 379 417 func main() { 380 418 if len(os.Args) > 1 { 381 419 switch os.Args[1] { ··· 433 471 os.Exit(1) 434 472 } 435 473 } 436 - 437 - func acceptAll() error { 438 - snapshots, err := files.ListNewSnapshots() 439 - if err != nil { 440 - return err 441 - } 442 - 443 - for _, testName := range snapshots { 444 - if err := files.AcceptSnapshot(testName); err != nil { 445 - return err 446 - } 447 - } 448 - 449 - fmt.Printf(pretty.Success("✓ Accepted %d snapshot(s)\n"), len(snapshots)) 450 - return nil 451 - } 452 - 453 - func rejectAll() error { 454 - snapshots, err := files.ListNewSnapshots() 455 - if err != nil { 456 - return err 457 - } 458 - 459 - for _, testName := range snapshots { 460 - if err := files.RejectSnapshot(testName); err != nil { 461 - return err 462 - } 463 - } 464 - 465 - fmt.Printf(pretty.Warning("⊘ Rejected %d snapshot(s)\n"), len(snapshots)) 466 - return nil 467 - }
+5 -5
internal/pretty/pretty.go
··· 7 7 ) 8 8 9 9 const ( 10 - colorRed = "\033[31m" 11 - colorGreen = "\033[32m" 12 - colorYellow = "\033[33m" 13 - colorBlue = "\033[34m" 14 - colorGray = "\033[90m" 10 + colorRed = "\033[91m" // Bright red (ANSI color 9) 11 + colorGreen = "\033[92m" // Bright green (ANSI color 10) 12 + colorYellow = "\033[93m" // Bright yellow (ANSI color 11) 13 + colorBlue = "\033[94m" // Bright blue (ANSI color 12) 14 + colorGray = "\033[90m" // Bright black/gray (ANSI color 8) 15 15 colorReset = "\033[0m" 16 16 colorBold = "\033[1m" 17 17 )