test(ui): budget DOM-structure assertions in dashboard tests

Turn on testing-library/no-node-access, no-container and
prefer-screen-queries as warnings and baseline them in eslint-budgets.json
so the counts can only go down.

These three rules catch tests that assert on DOM structure rather than on
what a user can observe: reaching through parentElement chains, querying
the container by CSS selector, and destructuring queries off render
instead of going through screen. Those assertions break on refactors that
change nothing a user sees, and stay green when the behaviour underneath
is broken.

Baselines are the current counts, so nothing fails today.
This commit is contained in:
Yuneng Jiang 2026-09-01 00:13:05 -07:00
parent ec3f8183c3
commit 847d737b8e
No known key found for this signature in database
2 changed files with 7 additions and 1 deletions

View file

@ -4,5 +4,8 @@
"complexity": { "max": 140, "target": 80 },
"max-depth": { "max": 70, "target": 30 },
"local/no-large-inline-object-arg": { "max": 559, "target": 300 },
"local/no-long-condition-chain": { "max": 265, "target": 120 }
"local/no-long-condition-chain": { "max": 265, "target": 120 },
"testing-library/no-container": { "max": 150, "target": 50 },
"testing-library/no-node-access": { "max": 760, "target": 500 },
"testing-library/prefer-screen-queries": { "max": 221, "target": 0 }
}

View file

@ -104,10 +104,13 @@ const eslintConfig = [
plugins: { "testing-library": testingLibrary, "jest-dom": jestDom },
rules: {
"testing-library/await-async-queries": "error",
"testing-library/no-container": "warn",
"testing-library/no-node-access": "warn",
"testing-library/no-wait-for-multiple-assertions": "error",
"testing-library/no-wait-for-side-effects": "error",
"testing-library/prefer-find-by": "error",
"testing-library/prefer-presence-queries": "error",
"testing-library/prefer-screen-queries": "warn",
"jest-dom/prefer-checked": "error",
"jest-dom/prefer-empty": "error",
"jest-dom/prefer-enabled-disabled": "error",