Skip to content

refactor(ui): decouple CSS dependencies and improve test quality#35242

Merged
lyzno1 merged 7 commits intomainfrom
cursor/ui-decouple-css-and-test-quality
Apr 15, 2026
Merged

refactor(ui): decouple CSS dependencies and improve test quality#35242
lyzno1 merged 7 commits intomainfrom
cursor/ui-decouple-css-and-test-quality

Conversation

@lyzno1
Copy link
Copy Markdown
Member

@lyzno1 lyzno1 commented Apr 15, 2026

Summary

Preliminary decoupling work for web/app/components/base/ui/ components to prepare for future @dify/ui package extraction. This PR focuses exclusively on removing CSS coupling and improving test quality — no package extraction is performed.

CSS Decoupling

  • Button: Inline all 11 @utility definitions from button/index.css into CVA Tailwind classes, remove the CSS file and its globals.css import so the component is fully self-contained.
  • ScrollArea: Replace CSS Module (index.module.css) with a plain CSS file using [data-dify-scrollbar] attribute selectors, eliminating CSS Module loader dependency while preserving style isolation.

Test Quality Improvements

  • Remove export === BaseXxx.Root identity tests from dialog, popover, tooltip, and number-field specs (implementation coupling, not bridging behavior).
  • Remove @/next/link external project dependency from dropdown-menu spec.
  • Remove redundant afterEach(cleanup) from button spec (already handled by vitest.setup.ts).
  • Remove unused beforeEach(vi.clearAllMocks) from number-field spec.
  • Update stale btn-* class name assertions to actual design-token classes in alert-dialog and button specs.
  • Mark intentionally public re-exports (DialogTrigger, DialogClose, PopoverTitle, PopoverDescription) with @public JSDoc for knip.

All 13 test files (165 tests) pass. ESLint, TypeScript type-check, and knip all clean.

From Cursor.

Screenshots

No visual changes — CSS refactoring preserves identical rendered output.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Made with Cursor

- Inline Button @Utility classes into CVA, remove button/index.css and
  its globals.css import so the component is self-contained
- Replace ScrollArea CSS Module with data-attribute selector
  (scroll-area.css) to eliminate CSS Module loader coupling
- Remove base-ui identity tests (export === Base.X) from dialog,
  popover, tooltip, and number-field specs
- Remove @/next/link external dependency from dropdown-menu spec
- Remove redundant afterEach(cleanup) and unused beforeEach from specs
- Update stale btn-* class assertions to actual design-token classes
- Mark intentionally public re-exports with @public JSDoc for knip

Made-with: Cursor
@github-actions github-actions Bot added the web This relates to changes on the web. label Apr 15, 2026
@lyzno1 lyzno1 marked this pull request as ready for review April 15, 2026 06:10
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. javascript Pull requests that update javascript code refactor labels Apr 15, 2026
hyoban
hyoban previously approved these changes Apr 15, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 15, 2026
Both are fully covered by their styled wrappers (DialogCloseButton and
AlertDialogCancelButton) which use the same underlying base-ui primitive.
Mark zero-consumer but intentionally public exports with @public JSDoc.

Made-with: Cursor
@lyzno1 lyzno1 requested review from WTW0313 and zhsama as code owners April 15, 2026 06:31
@lyzno1 lyzno1 enabled auto-merge April 15, 2026 06:58
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.85%. Comparing base (3bccdd6) to head (d620e31).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #35242      +/-   ##
==========================================
- Coverage   84.85%   84.85%   -0.01%     
==========================================
  Files        4360     4360              
  Lines      196685   196683       -2     
  Branches    37281    37280       -1     
==========================================
- Hits       166900   166895       -5     
- Misses      26703    26706       +3     
  Partials     3082     3082              
Flag Coverage Δ
web 85.76% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lyzno1 lyzno1 added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit 50a5551 Apr 15, 2026
33 checks passed
@lyzno1 lyzno1 deleted the cursor/ui-decouple-css-and-test-quality branch April 15, 2026 07:12
HanqingZ pushed a commit to HanqingZ/dify that referenced this pull request Apr 23, 2026
…ggenius#35242)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
asukaminato0721 pushed a commit to asukaminato0721/dify that referenced this pull request Apr 24, 2026
…ggenius#35242)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code lgtm This PR has been approved by a maintainer refactor size:L This PR changes 100-499 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants