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.
Fix/select zero and date today #1757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/select zero and date today #1757
Changes from all commits
facc45f454d53c327601fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two tests are flaky when the suite runs in the first minute after midnight
Both tests (lines 44 and 79) construct
recentDateasDate.now() - 60_000(one minute ago). If the test runner starts between00:00:00and00:00:59, that timestamp falls on the previous calendar day,isToday(recentDate)returnsfalse, and the assertionexpect(component.formattedDate).toBe('today')fails.🛠️ Proposed fix — anchor to a point safely within today
Apply the same change at line 79. Alternatively, inject a fake clock (e.g.,
jasmine.clock()) and pin the current time to a fixed midday value for the full test case.Also applies to: 78-89
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
startOfToday()as theformatDistanceStrictbase gives misleading distances for dates near midnightformatDistanceStrict(date, startOfToday(), { addSuffix: true })measures elapsed time from midnight (00:00), not from the current moment. A date of "yesterday 11:59 PM" is only 1 minute before midnight, so at 3 PM today it would render as "1 minute ago" instead of the expected ~15 hours. The parallelDateTimeDisplayComponentusesformatDistanceToNow(current time as reference), which is the correct anchor for a relative-time label.🐛 Proposed fix — use the current time as reference
startOfTodaycan then be removed from the import if it has no other uses.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Number(...) || 48silently ignores an explicit0, preventing users from disabling relative formattingNumber(0) || 48evaluates to48because0is falsy. A widget config of{ formatDistanceWithinHours: 0 }is intended to disable relative formatting (the guard on line 33 is> 0), but the fallback overwrites it.🐛 Proposed fix — use nullish coalescing
📝 Committable suggestion
🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.