Skip to content

add basic snapshot tests#93

Merged
dhth merged 4 commits intomainfrom
add-snapshot-tests
Aug 17, 2025
Merged

add basic snapshot tests#93
dhth merged 4 commits intomainfrom
add-snapshot-tests

Conversation

@dhth
Copy link
Owner

@dhth dhth commented Aug 17, 2025

Summary by CodeRabbit

  • New Features

    • No user-facing changes in this release.
  • Tests

    • Added extensive snapshot tests covering many UI views (task lists, logs, creation/editing flows, help, debug/edge cases) to improve rendering and behavior stability.
  • Chores

    • Added test-specific dependencies to support snapshot testing.
    • CI updated to run tests on both Linux and macOS via a matrix to catch cross-OS issues.

@coderabbitai
Copy link

coderabbitai bot commented Aug 17, 2025

Walkthrough

Adds a direct dependency (github.com/gkampitakis/go-snaps) and several indirect dependencies in go.mod, introduces a comprehensive snapshot-based test suite for internal UI views with deterministic time handling and test helpers, and expands CI workflows to run tests on both ubuntu-latest and macos-latest. No production API changes.

Changes

Cohort / File(s) Summary of Changes
Dependencies
go.mod
Added direct dependency github.com/gkampitakis/go-snaps v0.5.14 and several indirect dependencies (github.com/gkampitakis/ciinfo, github.com/gkampitakis/go-diff, github.com/goccy/go-yaml, github.com/kr/pretty, github.com/kr/text, github.com/maruel/natural, github.com/rogpeppe/go-internal, github.com/tidwall/gjson, github.com/tidwall/match, github.com/tidwall/pretty, github.com/tidwall/sjson). No existing dependency versions were changed.
UI View Snapshot Tests
internal/ui/view_test.go
Added extensive snapshot tests for multiple UI views (task list, task log, inactive tasks, create/update task forms, finish/edit/manual time logs, help, edge cases, and context messages). Introduced deterministic reference time, a test time provider, and helper constructors for Model, Task, and TaskLogEntry. Tests use snaps.MatchStandaloneSnapshot.
CI Workflows
.github/workflows/main.yml , .github/workflows/pr.yml
Test jobs changed from a single runner to a matrix strategy: runs now on ubuntu-latest and macos-latest via strategy.matrix.os with runs-on: ${{ matrix.os }}; job steps otherwise unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 5e0b199 and 05a0cf9.

⛔ Files ignored due to path filters (20)
  • internal/ui/__snapshots__/TestCreateTaskViewWithNoInput_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestCreateTaskView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestEditActiveTLView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestEditSavedTLView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestEmptyInactiveTaskListView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestFinishActiveTLViewWhereEndTimeBeforeBeginTime_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestFinishActiveTLViewWhereNoTimeTracked_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestFinishActiveTLViewWithWarningContext_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestFinishActiveTLView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestHelpView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestInactiveTaskListViewWithTasks_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestManualTasklogEntryView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskListViewDebugMode_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskListViewEmpty_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskListViewWithErrorMessage_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskListViewWithInfoContext_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskListViewWithTasks_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskLogViewEmpty_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskLogViewWithEntries_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestUpdateTaskView_1.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • .github/workflows/main.yml (1 hunks)
  • .github/workflows/pr.yml (1 hunks)
  • internal/ui/view_test.go (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/ui/view_test.go (5)
internal/ui/model.go (1)
  • Model (100-138)
internal/ui/theme.go (1)
  • DefaultTheme (52-99)
internal/ui/styles.go (1)
  • NewStyle (46-107)
internal/types/types.go (4)
  • TestTimeProvider (73-75)
  • TimeProvider (63-65)
  • Task (17-27)
  • TaskLogEntry (29-39)
internal/ui/initial.go (1)
  • InitialModel (18-119)
🔇 Additional comments (1)
internal/ui/view_test.go (1)

153-499: LGTM: solid snapshot coverage with deterministic time source

Good breadth across views, clean setup, and deterministic time via TestTimeProvider/referenceTime. This should catch regressions with minimal flakiness once colors are disabled.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-snapshot-tests

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 3c4cf98 and 5e0b199.

⛔ Files ignored due to path filters (22)
  • go.sum is excluded by !**/*.sum
  • internal/ui/__snapshots__/TestCreateTaskViewWithNoInput_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestCreateTaskView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestEditActiveTLView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestEditSavedTLView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestEmptyInactiveTaskListView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestFinishActiveTLViewWhereEndTimeBeforeBeginTime_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestFinishActiveTLViewWhereNoTimeTracked_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestFinishActiveTLViewWithWarningContext_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestFinishActiveTLView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestHelpView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestInactiveTaskListViewWithTasks_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestInsufficientDimensionsView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestManualTasklogEntryView_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskListViewDebugMode_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskListViewEmpty_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskListViewWithErrorMessage_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskListViewWithInfoContext_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskListViewWithTasks_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskLogViewEmpty_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestTaskLogViewWithEntries_1.snap is excluded by !**/*.snap
  • internal/ui/__snapshots__/TestUpdateTaskView_1.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • go.mod (3 hunks)
  • internal/ui/view_test.go (2 hunks)
🔇 Additional comments (6)
go.mod (2)

10-10: Add go-snaps as a direct (test) dependency: looks good

This aligns with the snapshot-based tests added in this PR.


27-29: Transitive deps pulled by go-snaps: acceptable footprint

These indirect additions are expected for snapshot diffs/YAML handling. No red flags.

Also applies to: 32-36, 49-49, 52-55

internal/ui/view_test.go (4)

14-14: Good: deterministic reference time

Pinning referenceTime makes duration-dependent rendering reproducible across runs.


16-148: Thorough table-driven tests for duration validity

Covers key paths (thresholds, boundaries, invalid/empty inputs). Nice.


269-288: No compile-time gotcha: taskInputs and tLInputs are slices
Verified in internal/ui/model.go that both fields are declared as []textinput.Model, so calls like m.taskInputs[…].SetValue(...) and m.tLInputs[…].SetValue(...) are valid.


153-499: Snapshots Verified

All snapshot files are present under internal/ui/__snapshots__, and each snaps.MatchStandaloneSnapshot invocation in view_test.go has a corresponding .snap file. No missing snapshots—CI should pass without errors.

@dhth dhth requested a review from Copilot August 17, 2025 16:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive snapshot testing infrastructure to improve UI rendering stability and catch regressions. It introduces snapshot tests covering various views (task lists, logs, creation/editing flows, help, debug scenarios) and updates CI to test on both Linux and macOS platforms.

  • Adds extensive snapshot tests for all major UI views and edge cases
  • Integrates go-snaps library for snapshot testing functionality
  • Updates CI workflows to run tests on both Ubuntu and macOS to catch cross-platform rendering differences

Reviewed Changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/ui/view_test.go Adds comprehensive snapshot tests covering empty states, populated lists, form views, error conditions, and debug scenarios
internal/ui/snapshots/*.snap Generated snapshot files capturing expected UI output for various test scenarios
go.mod Adds go-snaps dependency and its transitive dependencies for snapshot testing
.github/workflows/pr.yml Updates CI to run tests on both Ubuntu and macOS using a matrix strategy
.github/workflows/main.yml Updates CI to run tests on both Ubuntu and macOS using a matrix strategy

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@dhth dhth merged commit d75892e into main Aug 17, 2025
@dhth dhth deleted the add-snapshot-tests branch August 17, 2025 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants