Commit Graph
10 Commits
Author SHA1 Message Date
Andrew Aquino 7ef8d90c2b fix(site): stop exposing the empty notifications region to screen readers (#32141)
Sonner always renders its toast container as `<section
aria-label="Notifications alt+T" aria-live="polite">`. NVDA reads it as
an empty "Notifications alt+T region" at the bottom of every page, even
when no toast is shown.

This PR upgrades sonner from 2.0.7 to 2.0.8, which adds
`customAriaLabel`, and passes an empty label while there are no toasts.
An unnamed `section` is not a landmark, so screen readers no longer stop
on it. It stays a polite live region, so toasts are still announced, and
it gets its usual name back while toasts are visible.

Closes DEQ-474
Closes DEQ-497

| Ticket | UI surface |
|---|---|
| DEQ-474 | Toast container on every page (reported after the footer on
`/login?redirect=/workspaces`) |
| DEQ-497 | Toast container on every page (reported at the bottom of
`/login`) |

This changes ARIA only and nothing visible, so there are no screenshots.

The sonner 2.0.8 bump also brings upstream fixes: dismissal and
re-creation of toasts with the same ID, bounded toast history,
`aria-hidden` on its default icons (we supply our own), and a
`data-react-aria-top-layer` attribute on the section. The CSS changes in
the release apply only to `[data-styled=true]`, and our Toaster is
`unstyled`.

In 2.0.8, a newly mounted Toaster replays every active toast from
sonner's module-level store. Without cleanup, toasts from one test or
story leaked into the next and duplicated text queries. So
`site/test/setup/msw.ts` (Vitest) and `site/.storybook/preview.tsx` (a
project-level `beforeEach`) now call `toast.dismiss()`.

**Self-review findings left as they are:**

- *FE1/TS5, test asserts presence (`.not.toBeInTheDocument()`) on a role
query.* The behavior under test is the accessible name, which a
screenshot cannot capture. The rest of the file uses the same
assertions.
- *`useSonner()` counts toasts for all toasters and ignores
`toasterId`.* The app has one Toaster and nothing sets `toasterId`, so
filtering would be dead code.
- *The name is cleared about 200 ms before the last toast finishes its
exit animation.* The region uses `aria-relevant="additions text"`, so
removals are not announced anyway.
- *`{...props}` spreads after `customAriaLabel`, so a caller could
override it.* No caller passes props, and moving the spread would change
precedence for every other prop.

<details>
<summary>Grouping and decision log</summary>

- The `reading-order-hidden-content` label has three tickets. DEQ-474
and DEQ-497 report the same element (`#root > section`, the Sonner
container), so they share one root cause and one fix in the shared
`Toaster` wrapper.
- DEQ-299 (hidden Emoji picker content on the template builder's
Customizations step) was already fixed on main. #30181 made the pre-warm
picker `inert` and `aria-hidden`, and #30526 replaced Emoji Mart. The
collapsed popover's content is not mounted. Nothing to change here;
noted on the ticket.
- Options considered for the Sonner region:
1. Mount `<Toaster>` only while toasts exist. Rejected: a live region
inserted together with its content is often not announced.
2. A pnpm patch to drop the label on 2.0.7. Rejected because 2.0.8 ships
`customAriaLabel` upstream.
3. Upgrade and pass `customAriaLabel=""` while empty. Chosen: smallest
change, no patch to maintain.
- Verified in Storybook (`NotificationsInbox/MarkAllAsReadFailure`):
with a toast, the section is named `Notifications alt+T`. After closing
it, `aria-label=""` and `aria-live="polite"` remain, and no region shows
in the accessibility tree. axe reports only the existing
`aria-dialog-name` on the popover.
- The new Vitest test fails on main and passes on this branch.

</details>

🤖 Generated by Coder Agents on behalf of @aqandrew.
2026-11-13 13:06:12 -08:00
Jeremy Ruppel 4ecb4c3a34 fix(site): stub Element.scrollTo in unit tests (#31843)
JSDOM does not implement `Element.scrollTo`. Since #30526, `EmojiPicker`
calls it from a `requestAnimationFrame` callback when a category is
picked, so `IconField.test.tsx` could throw `scrollTo is not a function`
after the test finished and fail `test-js` intermittently.

`domStubs` now stubs `Element.prototype.scrollTo` with `vi.fn()`
alongside the other DOM stubs. The message scroller tests, which need a
`scrollTop`-backed `scrollTo`, install it with
`vi.spyOn(...).mockImplementation(...)` instead of assigning and
deleting it on `Element.prototype`. Stubbing on `Element` (where
browsers define it) keeps their overrides and `WorkingBlockDisclosure`'s
`vi.spyOn(Element.prototype, "scrollTo")` working; an `HTMLElement` stub
would shadow them.

The second commit resets every `domStubs` stub in a global `afterEach`.
`vi.spyOn` reuses a method that is already a `vi.fn()`, so a test's
`mockImplementation` lands on the shared stub and `vi.restoreAllMocks()`
does not undo it; the override and call history leaked into later tests
in the same file (for example, the `scrollIntoView` override in
`ChatsSidebar.test.tsx`). `hasPointerCapture` now passes its return
value to `vi.fn()` so the reset keeps it.

Fixes DASH-135

<details>
<summary>Decision log</summary>

- Rejected: patching `Element.prototype.scrollTo` inside
`IconField.test.tsx`, setting `scrollTop` directly in `EmojiPicker`, and
a `scrollTo?.()` guard in production code. A global test stub keeps the
component unchanged and covers any other component that scrolls.
- Rejected: a Storybook story to assert scroll position. jsdom has no
layout, so the unit test cannot verify where the list scrolls; that
remains uncovered.
- Rejected: plain-function stubs instead of `vi.fn()`. They restore
cleanly with `vi.restoreAllMocks()`, but are inconsistent with the
existing stubs. Kept `vi.fn()` and added the global reset.
- Stubs stay at module level rather than in `beforeEach`, so they exist
during imports, `beforeAll`, and `describe` bodies. Every existing
override of these stubs is in a test or `beforeEach`, so the `afterEach`
reset removes nothing a test relies on.
- Out of scope: during one full local run, `IconField > picks a custom
icon found by search` timed out finding the search box while the lazy
`EmojiPicker` chunk loaded under parallel load. It passed in isolation
and in later full runs. This is a separate timing issue.

</details>

> Generated by Coder Agents on behalf of @jeremyruppel.
2026-11-06 12:01:57 -05:00
McKayla はな e7706406f4 feat: render nerd font icons in the web terminal (#30527) 2026-11-05 10:14:42 -07:00
Ehab Younes f444c6f585 fix(site): flush deferred Radix focus-scope timer before jsdom teardown (#26983)
Radix's FocusScope defers its unmount event dispatch and focus restore
with setTimeout(0). The cleanup() in the shared afterEach schedules that
timer, and for the last test in a file it could still be pending when
vitest tears down the jsdom environment. The callback then constructs a
CustomEvent from Node's built-in constructor instead of jsdom's, and
jsdom rejects the dispatch with "parameter 1 is not of type 'Event'" as
an unhandled error, failing the run.

Await one timer turn in afterAll, while the jsdom environment is still
alive, to deterministically drain the 0ms timers scheduled by cleanup().
Timers with the same delay run in FIFO order, so this is not a race.

Fixes coder/internal#1613
2026-07-06 12:14:44 +03:00
Kayla はな b149433138 chore: complete jest to vitest migration (#24216) 2026-04-10 14:04:24 -06:00
Kayla はな 04f7d19645 chore: additional typescript import modernization (#23722) 2026-03-27 16:41:56 -06:00
Kayla はな aa81238cd0 chore: modernize all typescript imports (#23511) 2026-03-26 16:04:24 -06:00
ケイラ d2d7c0ee40 chore: migrate a bunch of tests to vitest (#21514) 2026-01-15 12:38:29 -07:00
Ehab Younes a581431bc8 fix(site): show apps with disabled health status on workspaces list (#21428)
- Fix to display apps with disabled health status on workspaces list
- Migrate WorkspacesPage jest test into vitest
- Modularize vitest setup into separate files:
  - setup/polyfills.ts: Blob, ResizeObserver polyfills
  - setup/domStubs.ts: Radix UI pointer capture stubs
  - setup/mocks.ts: useProxyLatency mock
  - setup/msw.ts: MSW server lifecycle

Fixed #20319
2026-01-12 13:37:30 +03:00
ケイラ 5691d38db7 chore: migrate tar tests to vitest (#21406) 2026-01-05 13:18:04 -07:00