Merge pull request #5692 from deepseek-harness/worktree/task-relative-clock-flake-20261005

test(schedule): pin task-page relative time assertions
This commit is contained in:
Tianyi Cui authored and GitHub committed 2026-10-05 10:06:25 +08:00
commit a78f0ee85b
1 file changed
+6 -7
@@ -116,9 +116,9 @@ function sessionsWithTitles(titles: Partial<Record<SessionId, string>>): Session
afterEach(() => {
try {
cleanup()
vi.restoreAllMocks()
localStorage.clear()
} finally {
vi.restoreAllMocks()
installedStyles?.remove()
installedStyles = undefined
}
@@ -139,10 +139,13 @@ function pinSystemZone(timeZone: string): void {
// the open clock panel calls to bring the staged value into view.
/** Device zone the cases pin: a rule without a stored zone seeds its clock in it. */
const DEVICE_ZONE = 'Asia/Shanghai'
/** Reference instant for static schedule assertions; timers retain their real scheduling. */
const FIXTURE_NOW = Date.parse('2026-09-18T12:00:00.000Z')
/** Elements whose `scrollIntoView` the open pickers called, in call order. */
const scrolledIntoView: Element[] = []
const scrollIntoView = vi.fn(function (this: Element) { scrolledIntoView.push(this) })
beforeEach(() => {
vi.spyOn(Date, 'now').mockReturnValue(FIXTURE_NOW)
pinSystemZone(DEVICE_ZONE)
Element.prototype.scrollIntoView = scrollIntoView
scrollIntoView.mockClear()
@@ -278,9 +281,7 @@ function relativeText(root: HTMLElement): string | null {
/**
* The relative next-run text both the row and the detail render for one instant.
*
* The components sample their reference clock once per mount, so the assertion
* reads the same clock at assert time; every fixture instant is days away, where
* one unit of drift cannot change the rendered value.
* Expected durations use the same pinned clock as component renders.
* @param scheduledAt - stored target instant.
* @param dictionary - active locale dictionary.
* @returns the localized time remaining, or overdue text.
@@ -759,9 +760,7 @@ describe('Task manager catalog', () => {
it('states the time remaining until the next run in each locale', () => {
// The row and the detail state a duration, not a date: zh reads `2小时后`
// and en reads `in 2 hours`, and neither renders a clock time for it. The
// fixture is two hours out, where a few milliseconds of clock drift cannot
// change the rendered unit.
// and en reads `in 2 hours`, and neither renders a clock time for it.
const soon: ScheduleCatalogEntry = {
...at, title: 'Two hours out', prompt: 'Two hours out',
scheduledAt: new Date(Date.now() + 2 * 3_600_000).toISOString(),