fix(test): load app CSS in Cypress component tests / 修复 Cypress 组件测试未加载应用 CSS#614
Merged
Conversation
中文:在 Cypress 组件测试中统一加载应用 CSS,并增加 Tailwind 可见性与尺寸回归测试。
中文:将 Header 移动端导航断言限定在汉堡菜单容器内(新增 mobile-menu testid),并验证桌面导航在小屏幕下隐藏。
中文:提高 selector 分类 Tooltip 的局部层级,避免其被 MultiSelect 选项遮挡。
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Claude finished @edwingao28's task in 1m 42s —— View job Review: PR #614 — load app CSS in Cypress component tests🟢 LGTM — no blocking issues found. I reviewed all 6 changed files, checked CI status, and verified the app renders at runtime. What I checked:
Test coverage and analytics requirements are satisfied — the new harness ships a regression test, and no new interactive elements were added (only a |
adibarra
approved these changes
Jul 22, 2026
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
src/app/globals.cssfrom the shared Cypress component support filemobile-menutest seamCloses #612.
Root cause
Cypress component tests mount React components without the application root layout, so
globals.csswas never loaded. As a result, Tailwind utilities such ashidden, responsive visibility classes, and sizing utilities were not applied, allowing visibility assertions to pass against an unstyled DOM.Importing the stylesheet alone is insufficient because Next.js's development style loader also requires the
#__next_css__DO_NOT_USE__insertion anchor.Once the component harness loaded the real application CSS, it exposed two previously hidden failures:
z-50, below the open MultiSelect panel atz-[120].Why these changes are in one PR
The Header and tooltip failures are direct consequences of correcting the Cypress CSS environment. Landing only the harness change would leave the component suite red, while keeping the old assertions would preserve false-positive coverage.
The work remains separated into three reviewable commits:
Verification
inline-blockand50.0938 × 21.5pxdisplay: noneand44 × 44pxretries=0retries=0pnpm fmtpnpm lintpnpm typecheckglobals.cssis imported only once by the shared Cypress support file中文说明
概述
src/app/globals.cssmobile-menu测试入口限定 Header 移动端导航断言根因
Cypress 组件测试只挂载 React 组件,不会挂载应用根布局,因此此前从未加载
globals.css。这导致hidden、响应式可见性和尺寸等 Tailwind 工具类没有生效,使部分可见性断言在未应用样式的 DOM 上错误通过。仅导入样式表仍然不够,因为 Next.js development style loader 还需要
#__next_css__DO_NOT_USE__CSS 插入锚点。启用真实应用 CSS 后,测试暴露了两个此前被隐藏的问题:
z-50,低于使用z-[120]的 MultiSelect 面板。为什么放在同一个 PR
Header 和 Tooltip 失败都是修正 Cypress CSS 环境后直接暴露出来的结果。如果只合入测试环境修复,组件测试套件会保持失败;如果保留原有断言,则会继续产生 false positive。
本 PR 仍通过三个独立 commit 保持清晰的 review 和 bisect 边界:
验证
inline-block、50.0938 × 21.5pxdisplay: none、44 × 44pxretries=0retries=0pnpm fmtpnpm lintpnpm typecheckglobals.cssNote
Low Risk
Test harness and assertion fixes plus a small z-index tweak on tooltips; no auth, data, or core business-logic changes.
Overview
Cypress component tests now mount with real app styles, fixing false-positive visibility checks that passed on an unstyled DOM.
The shared component support imports
globals.cssand the componentindex.htmladds Next.js’s#__next_css__DO_NOT_USE__anchor so Tailwind utilities apply in the harness. A new component CSS probe assertshiddenandsize-11resolve todisplay: noneand 44×44px.With CSS enabled, Header mobile-nav tests are tightened: desktop dashboard links are expected hidden on small viewports, the hamburger asserts
aria-expanded, and links are scoped insidedata-testid="mobile-menu". The mobile dropdown gains that test id inheader.tsx.Selector category tooltips get
z-[130]onTooltipContentso they stack above the openMultiSelectpanel (z-[120]).Reviewed by Cursor Bugbot for commit 6fbd468. Bugbot is set up for automated code reviews on this repo. Configure here.