Repository navigation
test(sleep): pin the night-caption label and date pairing (#2199) - #2224
Merged
Merged
Conversation
The Sleep nav header stacks two lines that are computed from opposite ends
of the night: `calendarNightsAgo` counts from the WAKE day (the key navDays
groups by) while `clockLabelFor` prints the ONSET day. For a real night those
are different calendar dates, so the pairing only reads correctly if every row
resolves its own night.
Nothing pinned that pairing. The existing fixtures wake at 07:00 from an 01:00
onset the same calendar day, so onset and wake answer every anchor question
identically and the suite could not have caught a row that dated itself from
the wrong night.
This adds a cross-midnight fixture and asserts the reporter's own three rows
verbatim, passing a null hero label so it walks the stage-less path that used
to borrow the newest night's date.
Last night Sun 13 Sep
1 night ago Sat 12 Sep
2 nights ago Fri 11 Sep
Test only, no behaviour change. Passes on main as of #2201.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test-only. Pins the caption pairing reported in #2199.
What was not pinned
The Sleep nav header stacks two lines computed from opposite ends of the night:
calendarNightsAgo, the keynavDaysgroups by)clockLabelFor)Individually both are covered. What nothing asserted is that they agree row by row, which is the only thing a reader ever sees. The reporter's screen had a correctly counted "1 night ago" sitting above a date belonging to a different night, and no test asserted that combination.
The fixtures made that hard to see.
nightOnwakes at 07:00 from an 01:00 onset on the same calendar day, so onset and wake answer every anchor question identically and the two rules are indistinguishable.What this adds
A
crossMidnightNightfixture (onset 22:50, wake 06:48 the next morning) and the reporter's own three rows asserted verbatim, with a Monday pinned as today:The hero label is passed as
nullso it walks the stage-less path, the one that used to borrow the newest night's date.Mutation-checked
A regression pin that does not go red on the regression is worth nothing, so I broke the source two ways and confirmed this test catches both.
1. Reintroduce the borrow (
navDays.getOrNull(offset)togetOrNull(0)):That failure message is the reporter's bug in their own terms.
2. Anchor the label on onset instead of wake (
endTstostartTs):Worth being accurate about what is new here: neither mutation is caught only by this test.
navHeaderClockLabel_datesTheBrowsedNight_notTheNewestOnealso fails on the first, andtwoNightsEitherSideOfTheRollKeepDistinctLabelson the second. An earlier draft of this description claimed the existing suite could not have caught a row dating itself from the wrong night, and the mutation run disproved that. What this test adds is the pairing: the two lines asserted together, per row, on nights that actually cross midnight, phrased so a failure reads back as the symptom a reporter would describe.Verification
tests="14" skipped="0" failures="0" errors="0"on unmutated main, with the new case present in the result XML rather than filtered out, and the result timestamp checked against the clock. Passes as of #2201, so this locks in current behaviour rather than describing a pending change.Known limit
This covers
navHeaderClockLabel, not its call site. The original defect was a call-site expression (night?.clockLabel ?: model?.clockLabel), andSleepScreen.ktcould regress the same way by passing the model's label as the first argument, which no unit test here would catch. The comment above that call site is currently the only thing guarding it.No production code is touched, so there is no parity twin to add. The Swift side has its own
nightRelativeLabeland would want the same cross-midnight fixture, which is worth doing separately if this shape proves useful.