镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

test: fix month-boundary and Sonner mount races in StatusEditor and RelayStaff tests - #2064

Merged
kalvinnchau merged 2 commits into
mainfrom
fix/status-editor-month-boundary-test
Oct 31, 2026
Merged

kalvinnchau merged 2 commits into
mainfrom
fix/status-editor-month-boundary-test

Conversation

@kalvinnchau

@kalvinnchau kalvinnchau commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes two timing-dependent Vitest failures, one on main and one seen on this PR's CI. Both changes are test-only; product code is unchanged.

Test Failure Class
StatusEditor.test.tsx › prefills and preserves an existing deadline… Unable to find role="button" and name /^Today,/ (main run) Real-clock dependency (month boundary)
RelayStaff.test.tsx › enforcement error finished while closed reaches reopened detail expect(element).toBeVisible() on .buzz-toast-title (PR run) Synchronous assertion racing a mount effect

1. StatusEditor: month-boundary clock dependency

Root cause. The test seeds an existing status with expiresAt = Date.now() + 86400. The custom date picker opens on the month of the prefilled deadline, and the test then clicks the Today, … day button. On the last day of a month (in the runner's time zone), tomorrow is in the next month. The calendar then renders that month, today's button isn't present, and findByRole times out. CI ran at 2026-10-31T00:28Z.

Opening on the month of the selected date is intended product behavior.

Fix.

  • vi.useFakeTimers({ toFake: ["Date"], now: new Date(2026, 5, 15, 12) }) pins Date to a mid-month local noon, so now + 1 day stays in the same month in any time zone.
  • Only Date is faked. Timers, microtasks and user-event scheduling stay real, so the existing waitFor/findBy* behavior doesn't change.
  • afterEach calls vi.useRealTimers() so other tests in the file go back to the real clock.

2. RelayStaff: toast visibility before Sonner mount

Root cause. Sonner renders a new toast with data-mounted="false". Its injected stylesheet keeps a toast at opacity: 0 until a post-render effect sets data-mounted="true" ([data-sonner-toast][data-mounted='true']). The test asserted toBeVisible() right after findByRole(...) for the detail view. Depending on scheduling, the toast node existed but hadn't flipped to mounted yet, so jsdom reported it as hidden.

Fix. Wrap that assertion in waitFor(() => expect(getByText(...)).toBeVisible()), waiting on the observable mounted state instead of assuming it already happened. The assertion is just as strict as before: the toast must actually become visible. The synchronous toBeVisible() for the inline Native enforcement detail (non-toast) stays as it was.

Validation

Command Result
bin/pnpm vitest run src/features/user-status/StatusEditor.test.tsx (local TZ) 20/20 pass
TZ=UTC bin/pnpm vitest run src/features/user-status/StatusEditor.test.tsx 20/20 pass
bin/pnpm vitest run src/bundled/relay-staff/RelayStaff.test.tsx ×3 136/136 pass each run

Deferred / gaps

  • Neither original failure was reproduced locally. The month-boundary case wasn't run on a month-end date, and the Sonner race isn't deterministic under local scheduling. The fixes address the mechanisms identified from the CI logs and the Sonner CSS.
  • The full JavaScript and browser splits are left to hosted CI.

…month end

Signed-off-by: Kalvin Chau <kalvin@block.xyz>
…ility

Signed-off-by: Kalvin Chau <kalvin@block.xyz>
@kalvinnchau kalvinnchau changed the title test(user-status): pin clock so StatusEditor deadline test passes at month end test: fix month-boundary and Sonner mount races in StatusEditor and RelayStaff tests Oct 31, 2026
@kalvinnchau
kalvinnchau merged commit 802bf5a into main Oct 31, 2026
75 of 77 checks passed
@kalvinnchau
kalvinnchau deleted the fix/status-editor-month-boundary-test branch October 31, 2026 01:26
shellz-n-stuff added a commit that referenced this pull request Oct 31, 2026
Picks up the month-boundary StatusEditor test fix (#2064).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* origin/main: (56 commits)
  perf(sidebar): subscribe to selected live and list facts (#1966)
  feat(desktop): align the sign-in callback page with web branding (#2038)
  Show linked PRs in Solo headers and move idle huddles to Chat actions (#1968)
  feat(messages): mark edited messages with "(edited)" (#2020)
  feat(desktop): bundle the buzz CLI in every package (#2027)
  feat(plugins): open a plugin page from buzz://plugin links (#2053)
  feat(plugins): managed plugin sources (#2052)
  test(browser): prevent sampled clock pause races (#1955)
  test: fix month-boundary and Sonner mount races in StatusEditor and RelayStaff tests (#2064)
  test: stop tests leaving temp dirs and a flake-check fixture behind (#1977)
  fix(messages): release Virtua's held range when scrolling stops (#2032)
  test(mcp): allow protection checks in bundled help fixture (#2061)
  fix(emoji): recover transient image failures without reopening chats (#2000)
  test: wait for dialog focus, reach a reading position, re-sign pair() (#1975)
  feat(plugins): sign builderlab in through the native fi session in fi builds (#1461)
  feat(agents): offer bundled Buzz help (#2033)
  fix(github): show pull request status for anchors and subpages (#2055)
  fix(dialogs): focus safe controls and task inputs (#2021)
  fix(composer): truncate workspace names at narrow widths (#2043)
  AIDA-2287: Refresh public channel search incrementally (#2023)
  ...

Signed-off-by: Alex Rosenzweig <arosenzweig@squareup.com>
morgmart added a commit that referenced this pull request Oct 31, 2026
…isibility

* origin/main: (23 commits)
  feat(profiles): show NIP-FI verified names (BUZZ-433) (#2005)
  feat(identity): sign in to the organization when Buzz opens (#2086)
  perf(identity-names): stop rerunning name policy for live member churn (#2092)
  fix(sidebar): keep the channel drag preview under the pointer (#2019)
  fix(identity): use xyz.block.buzz.desktop federated-session keychain service (#2094)
  perf(relay): read each channel's remote access once per accepted batch (#2091)
  fix(styles): keep page status :has() on each rule's subject (#2081)
  fix(navigation): show a notice for invalid deep links (#2054)
  fix(messages): preserve held readers through equal-height resizes (#1963)
  perf(sidebar): subscribe to selected live and list facts (#1966)
  feat(desktop): align the sign-in callback page with web branding (#2038)
  Show linked PRs in Solo headers and move idle huddles to Chat actions (#1968)
  feat(messages): mark edited messages with "(edited)" (#2020)
  feat(desktop): bundle the buzz CLI in every package (#2027)
  feat(plugins): open a plugin page from buzz://plugin links (#2053)
  feat(plugins): managed plugin sources (#2052)
  test(browser): prevent sampled clock pause races (#1955)
  test: fix month-boundary and Sonner mount races in StatusEditor and RelayStaff tests (#2064)
  test: stop tests leaving temp dirs and a flake-check fixture behind (#1977)
  fix(messages): release Virtua's held range when scrolling stops (#2032)
  ...

# Conflicts:
#	src/bundled/channels/ChannelMemberAvatars.tsx
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