Skip to content

Fix TestFormatDueDate year-boundary flake#514

Merged
robzolkos merged 2 commits into
mainfrom
fix/format-due-date-year-boundary
Jul 2, 2026
Merged

Fix TestFormatDueDate year-boundary flake#514
robzolkos merged 2 commits into
mainfrom
fix/format-due-date-year-boundary

Conversation

@robzolkos

@robzolkos robzolkos commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Problem

TestFormatDueDate fails on any run after June, blocking CI on main and every open PR:

Error:    "Sat, Jan 2, 2027" should not contain "2027"
Messages: same-year dates should omit year

The "same year" case built its date with now.AddDate(0, 6, 0) (6 months ahead). From July onward that lands in the next calendar year, so formatDueDate correctly includes the year — and the NotContains(year) assertion fails. It's a latent test bug that started firing as the calendar rolled forward; the production formatDueDate is unaffected.

Fix

Pick a same-year date in the opposite half of the current year (Feb if now is in H2, Nov if now is in H1). That guarantees it stays in the current calendar year and clear of the today/tomorrow/yesterday window no matter when in the year the suite runs.

Verification

  • Before: TestFormatDueDate red (reproduces on clean main).
  • After: TestFormatDueDate and the full internal/tui/workspace/views package green.
  • gofmt/go vet clean.

Summary by cubic

Fixes a flaky TestFormatDueDate and makes it fully deterministic by driving it from a fixed now. Keeps CI green without changing formatDueDate behavior.

  • Bug Fixes
    • Extracted formatDueDateAt(iso, now) and have formatDueDate call it with time.Now() to remove midnight/New‑Year races.
    • Assert the same‑year case using Feb 15 of the current year, safely away from today/tomorrow/yesterday.

Written for commit 2fc8ef5. Summary will update on new commits.

Review in cubic

The same-year assertion used now.AddDate(0, 6, 0), which crosses into the
next calendar year for any run after June — so from July onward the date
carried a year and the 'should not contain year' assertion failed.

Pick a date in the opposite half of the current year instead, keeping it
same-year and clear of the today/tomorrow/yesterday window regardless of
when in the year the suite runs.
Copilot AI review requested due to automatic review settings July 2, 2026 18:46
@github-actions github-actions Bot added tui Terminal UI tests Tests (unit and e2e) labels Jul 2, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes a flaky TestFormatDueDate in the TUI workspace views by ensuring the “same year” test date never crosses into the next calendar year, keeping CI stable without changing production formatDueDate behavior.

Changes:

  • Replaces the “6 months ahead” same-year test date with a deterministic month selection (Feb vs Nov) based on current month.
  • Uses a fixed day-of-month (15th) to keep assertions stable and away from the today/tomorrow/yesterday window.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/tui/workspace/views/detail_test.go Outdated
Address review: the test still read time.Now() while formatDueDate computed
its own time.Now() internally, leaving a residual midnight/New-Year race
where the two calls could observe different years.

Extract formatDueDateAt(iso, now) as a testable seam (formatDueDate stays a
thin wrapper passing time.Now()), and drive the test from a fixed reference
now so none of the relative-label cases depend on the wall clock.
@github-actions github-actions Bot added the bug Something isn't working label Jul 2, 2026
@robzolkos robzolkos merged commit 2da04b8 into main Jul 2, 2026
26 checks passed
@robzolkos robzolkos deleted the fix/format-due-date-year-boundary branch July 2, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working tests Tests (unit and e2e) tui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants