Repository navigation
perf(test): make role+name queries O(match) in the date-component suites - #3816
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
sangwook-dev
marked this pull request as ready for review
July 11, 2026 12:02
sangwook-dev
requested review from
cixzhang,
ejhammond,
imdreamrunner,
josephfarina,
marie-lucas,
nynexman4464 and
thedjpetersen
as code owners
July 11, 2026 12:02
sangwook-dev
marked this pull request as draft
July 11, 2026 12:18
sangwook-dev
force-pushed
the
perf/daterange-test-speed
branch
from
July 11, 2026 12:27
0d6ef23 to
25bbcb6
Compare
sangwook-dev
marked this pull request as ready for review
July 11, 2026 12:31
sangwook-dev
force-pushed
the
perf/daterange-test-speed
branch
from
July 11, 2026 21:10
af294c9 to
3d5e2c2
Compare
Contributor
PR Analysis ReportNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | View full report |
cixzhang
approved these changes
Jul 11, 2026
cixzhang
left a comment
Contributor
There was a problem hiding this comment.
Thanks for speeding up this test!
cixzhang
enabled auto-merge (squash)
July 11, 2026 22:41
… O(all buttons)
DateRangeInput.test.tsx was the slowest file in the suite: 34.3s for 34
tests (~1s each), 10x slower per test than DateInput's. Profiling showed
the tests' render is cheap (~20ms) — the cost was every
getByRole('button', {name}) query: the closed popover keeps a two-month
Calendar (~85 role=button nodes) permanently mounted, RTL computes the
accessible name of every candidate before filtering, and each
computation consults jsdom's slow getComputedStyle (~5ms/node). One
trigger lookup: ~450ms. A name-less getAllByRole with hidden:true runs
in 29ms.
Replace the 23 button role+name queries with file-local getButton()/
queryButton() helpers that use the same name algorithm RTL uses
internally (dom-accessibility-api, promoted from transitive to explicit
devDependency) but inject a constant "visible" style stub — with
{hidden: true} semantics, visibility must not exclude candidates anyway,
so the stub only removes the getComputedStyle cost, not correctness.
Trade-off, documented in the helper: first-match-wins, no uniqueness
check across the tree.
File time: 34.3s -> 5.7s wall (tests 34.3s -> 1.7s). All 34 tests pass
unchanged in what they assert; core typecheck and the neighboring
DateInput/DateTimeInput/Calendar suites (218 tests) stay green.
Candidates for a follow-up using the same pattern via a shared
test-utils helper: Calendar.test.tsx (12s), DateInput (7.5s),
DateTimeInput (5.9s).
…dency" The undeclared import type-checks only by luck of which copy wins the shamefully-hoist: without the declaration, RTL's transitive 0.5.16 lands at the root, and its package.json exports map has no types condition (import -> dist/index.mjs with no index.d.mts), so tsc fails with TS7016 'implicitly has an any type' — exactly what broke the PR's typecheck job. Declaring ^0.6.3 pins the copy whose exports carry types. Runtime never noticed; the type graph is why the declaration is needed today, not later.
…DateTimeInput
Promote DateRangeInput's file-local getButton/queryButton helpers to a
shared packages/core/src/__tests__/fastRoleQueries.ts (same convention
as TestIcon.tsx) and apply them to the other three date-component
suites, which pay the same tax: every getByRole('button', {name}) query
computes accessible names for the whole mounted month grid through
jsdom's slow getComputedStyle.
Measured locally (same machine, sequential runs):
Calendar.test.tsx 7.2s -> 1.9s (45 tests)
DateInput.test.tsx 5.1s -> 2.2s (68 tests)
DateTimeInput.test.tsx 4.1s -> 1.8s (64 tests)
DateRangeInput.test.tsx stays at ~1.3s with the shared helper
Full suite: 5893 tests green, wall 105.9s -> 92.8s, worker-summed
'tests' phase 297.7s -> 235.1s. Core typecheck green. Queries that were
already cheap (combobox/tooltip/grid — few candidates or no name
filter) are left as stock RTL.
Lint flagged the `{...} as CSSStyleDeclaration` object-literal cast
(@typescript-eslint/consistent-type-assertions wants `const x: T = {...}`).
A plain `: CSSStyleDeclaration` annotation can't work — the interface has
hundreds of required members and the stub only implements getPropertyValue.
Type the stub honestly as Pick<CSSStyleDeclaration, 'getPropertyValue'>
(no literal cast, typechecks) and move the widening to the call site as an
identifier assertion, which the rule's objectLiteralTypeAssertions option
does not govern. Lint clean, core typecheck green, all four date suites
(252 tests) pass.
auto-merge was automatically disabled
July 12, 2026 01:23
Head branch was pushed to by a user without write access
sangwook-dev
force-pushed
the
perf/daterange-test-speed
branch
from
July 12, 2026 01:23
3d5e2c2 to
8f456a5
Compare
Contributor
Author
|
@cixzhang I resolved the conflicts and pushed the changes. Please review it again. |
sangwook-dev
added a commit
to sangwook-dev/fe-lab
that referenced
this pull request
Jul 31, 2026
로컬에 설치된 인용 버전(jsdom 27.4.0, dom-accessibility-api 0.6.3, @testing-library/dom 10.4.1)과 근거 PR(meta/astryx#3816)을 직접 돌려 대조했다. 4장 호출 횟수 표(0/256/176/261), 5장의 후보당 3회 분해, 6장 jsdom 소스 인용 줄범위, 9장 수치는 전부 실물과 일치했고 아래 세 곳만 어긋나 고친다. - 7장: 코드 증감이 링크된 diff와 반대였다. 실제 PR은 +134/-96으로 테스트 파일은 32줄 줄었지만 헬퍼 66줄이 새로 생겨 전체로는 늘었다 - 5장 각주: isHidden의 조기 종료 설명이 뒤집혀 있었다. 속성으로 숨긴 노드에서만 스타일 조회를 건너뛰므로 본문의 256회와 충돌했다 - 3장: 후보 85개를 떨어뜨리는 것은 hidden 필터가 아니라 name 필터다. 4장이 같은 사실을 이미 반대로 서술하고 있었다 5장 스니펫은 멀티라인 HTML 탓에 textContent가 인쇄된 출력과 달랐다. 한 줄로 고쳐 출력과 맞추고 불필요한 global.window 줄을 지웠다. 읽는 부담을 줄이려고 출처 4곳과 재현 환경 고지 2곳을 details로 접었다. 논증을 지탱하는 문장(261회를 닫는 5회 내역, 256회의 근거)은 본문으로 올리고 링크만 접었으며, 접혀도 보여야 하는 "재현 환경"이라는 사실은 summary에 남겼다. 그 밖에 남아 있던 수사물 어휘(증거, 짚다)와 설명 없이 한 번만 등장하던 비유(해결은 사다리로)를 걷어내고, 번호로만 가리키던 상호참조 2곳을 풀었다.
sangwook-dev
added a commit
to sangwook-dev/fe-lab
that referenced
this pull request
Jul 31, 2026
* feat: 글 수정 * chore(claude): 글쓰기 에이전트에서 서사 템플릿을 걷어낸다 Hero's Journey 8단계와 "드라마틱한 시작(위기 상황)" 지시가 소재와 무관하게 수사물·영웅서사 톤을 만들어내고 있었다. 개발 글에 장르 색이 섞이는 원인이라 다음으로 대체한다. - Hero's Journey 8단계 → "구조는 소재에서 나온다" 원칙 + 금지 어휘 표 (범인→원인/병목, 무죄→~가 아니었다, 파헤치다/잡았다→확인한다/좁힌다) - "드라마틱한 시작" → "글의 시작점". 극적으로 보이려고 없던 위기를 지어내지 않는다 - 의성어/의태어 적극 활용 지침 제거. 기술 글 톤과 충돌한다 빈자리에 새 구조 템플릿을 넣지 않았다. 대신 사용자가 자기 기준을 안 정했으면 대신 정해주지 말고 물어보도록 했다. * docs(blog): getByRole 글의 수사물 어휘를 사실 어휘로 바꾼다 개발 글인데 장르 색 표현이 섞여 이질적이라 9군데를 교체했다. 섹션 구조(4막 + 1~10장)는 그대로 두었고, 설명에 기여하는 은유(jsdom의 "비용 청구서")도 유지했다. - 범인 → 원인/병목, 무죄였습니다 → 아니었습니다, 파헤치고 → 다루고, 범인은 잡았습니다 → 여기까지가 측정으로 좁힌 결과입니다 - 4장 호출 횟수 표에 시간 수치를 뺀 이유를 밝힘 — 실행마다 1.4~2.4초로 흔들려 호출이 많은 쪽이 더 빠르게 찍히기도 했다. 호출 횟수는 재현 가능했다 - 표 구분선·링크 줄바꿈 포맷 정리 * docs(blog): getByRole 글의 계산 오류와 어색한 표현을 고친다 전체를 다시 읽고 나온 16군데를 반영했다. - 5장의 getComputedStyle 호출 수가 틀렸다. 1 + 85×3 = 256인데 261로 적혀 있었다. 261은 거기에 hidden 필터 5회를 더한 값이라 그 경로를 문장에 명시했다 - 2장 제목이 같은 섹션 결론과 같은 말이라 "렌더 20ms, 쿼리 450ms"로 바꿨다 - 참조 대상이 없는 언급을 걷어냈다. 본문에 인용한 적 없는 "커밋 제목의 O(match)", CI 시리즈가 전부 draft라 링크할 수 없는 "다음 글의 주제" - 8장 중간의 구분선을 뺐다. 이제 모든 구분선이 섹션 경계다 - 성과 절의 순서를 바꿨다. 테스트 통과 강조로 닫고 남은 시간 이야기를 뒤에 둔다 - 표현 정리: 그제서야→그제야(2군데), 첫 문단 CI 중복, 꼬인 문장 몇 개 * style(claude): 글쓰기 에이전트 문서에 prettier 포맷을 적용한다 bd80fd0을 --no-verify로 커밋하면서 lefthook의 prettier 자동 포맷이 건너뛰어졌다. 금지 어휘 표의 열 정렬만 바뀌고 내용 변경은 없다. * Update apps/blog/posts/testing/매일 쓰던 getByRole 때문에 테스트가 26배 느렸습니다.md Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> * feat(blog): 본문 details 블록에 스타일과 펼침 애니메이션을 넣는다 마크다운 본문의 raw HTML <details>는 rehypeRaw로 렌더되고 있었지만 전용 스타일이 0줄이라 브라우저 기본 모양으로 나왔다. 출처·측정 방법론처럼 논증에서 비켜둘 보조 설명을 접어두려면 접기 어포던스가 필요해 스타일을 추가한다. - summary: 기본 마커를 지우고 90도 회전하는 삼각형으로 대체 - ::details-content의 block-size를 0에서 auto로 전환해 펼침을 애니메이션 - auto 보간의 전제인 interpolate-size: allow-keywords를 :root에 선언 - prefers-reduced-motion에서는 전환을 끈다 ::details-content 미지원 브라우저는 애니메이션 없이 즉시 펼쳐지므로 기능 손실은 없다. Chrome에서 높이가 51px에서 186px까지 26프레임에 걸쳐 이징되는 것과, TOC·검색 인덱스에 접힌 내용이 새지 않는 것을 확인했다. * docs(blog): getByRole 글의 사실 오류를 고치고 오늘 날짜로 발행한다 로컬에 설치된 인용 버전(jsdom 27.4.0, dom-accessibility-api 0.6.3, @testing-library/dom 10.4.1)과 근거 PR(meta/astryx#3816)을 직접 돌려 대조했다. 4장 호출 횟수 표(0/256/176/261), 5장의 후보당 3회 분해, 6장 jsdom 소스 인용 줄범위, 9장 수치는 전부 실물과 일치했고 아래 세 곳만 어긋나 고친다. - 7장: 코드 증감이 링크된 diff와 반대였다. 실제 PR은 +134/-96으로 테스트 파일은 32줄 줄었지만 헬퍼 66줄이 새로 생겨 전체로는 늘었다 - 5장 각주: isHidden의 조기 종료 설명이 뒤집혀 있었다. 속성으로 숨긴 노드에서만 스타일 조회를 건너뛰므로 본문의 256회와 충돌했다 - 3장: 후보 85개를 떨어뜨리는 것은 hidden 필터가 아니라 name 필터다. 4장이 같은 사실을 이미 반대로 서술하고 있었다 5장 스니펫은 멀티라인 HTML 탓에 textContent가 인쇄된 출력과 달랐다. 한 줄로 고쳐 출력과 맞추고 불필요한 global.window 줄을 지웠다. 읽는 부담을 줄이려고 출처 4곳과 재현 환경 고지 2곳을 details로 접었다. 논증을 지탱하는 문장(261회를 닫는 5회 내역, 256회의 근거)은 본문으로 올리고 링크만 접었으며, 접혀도 보여야 하는 "재현 환경"이라는 사실은 summary에 남겼다. 그 밖에 남아 있던 수사물 어휘(증거, 짚다)와 설명 없이 한 번만 등장하던 비유(해결은 사다리로)를 걷어내고, 번호로만 가리키던 상호참조 2곳을 풀었다. * chore: nodejs를 24.18.1로 올린다 .tool-versions는 ci / deploy-blog / claude-lighthouse / claude-deps-audit 네 워크플로가 node-version-file로 참조하는 단일 소스라, 이 한 줄이 CI가 쓰는 노드 버전을 함께 옮긴다. 루트 engines는 ">=24"라 그대로 만족한다. * style(blog): MobileTOC의 paddingBottom을 pb 축약으로 바꾼다 같은 스타일 객체의 다른 속성들이 이미 축약형(display, flexDir, shadow)을 쓰고 있어 표기를 맞춘다. 렌더 결과는 동일하다. --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
This branch was successfully deployed
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.
Summary
The four date-component suites were the slowest files in packages/core, and profiling showed why: their month grid keeps ~35–85
role=buttonnodes mounted (visible in Calendar's case, inside the closed popover for the*Inputcomponents), and RTL'sgetByRole('button', {name})computes the accessible name of every candidate before filtering — each computation consulting jsdom's slowgetComputedStyle(~5ms/node). One trigger lookup: ~450ms. A name-lessgetAllByRole('button', {hidden: true}): 29ms.Changes
packages/core/src/__tests__/fastRoleQueries.ts(same convention asTestIcon.tsx):getButton()/queryButton()keep RTL's exact name algorithm (dom-accessibility-api, the library RTL uses internally) but collect candidates with{hidden: true}and inject a constant "visible" style stub into the name computation — under{hidden: true}semantics visibility must not exclude candidates, so the stub removes only thegetComputedStylecost. Documented trade-off: first-match-wins, no tree-wide uniqueness check.dom-accessibility-apideclared as a root devDependency: it already ships in node_modules as a transitive dep, but without the declaration the hoisted copy is RTL's 0.5.16, whoseexportsmap has no types condition —tscfails with TS7016 (implicitly has an 'any' type), which is exactly what broke this PR's typecheck when the declaration was briefly dropped.^0.6.3pins the copy whose exports carry types.Measurements (local, sequential runs on the same machine)
Full suite: 5,893 tests green, wall 105.9s → 92.8s, worker-summed
testsphase 297.7s → 235.1s. Core typecheck green. All tests assert the same things they did before.