Commit cf64198
Add an integration test suite (#412)
* test: add vitest test suite with ported react-select tests
Adds vitest + jsdom + @testing-library/{react,user-event,jest-dom} as
devDependencies and configures a Chakra-provider-wrapped render helper.
Ports the upstream react-select tests (Select, Async, Creatable,
AsyncCreatable, StateManaged + the constants fixture) from
react-select@5.10.2 with the adaptations the wrapper needs: imports
from the package source, userEvent v14 async migration, and a small
jest-in-case shim that honors per-case skip/only flags.
Adds dedicated coverage for the props this package layers on top of
react-select (size, variant, invalid, disabled, readOnly, chakraStyles,
tagColorPalette, tagVariant, selectedOptionStyle,
selectedOptionColorPalette, focusRingColor, useChakraSelectProps),
using a probe pattern that captures chakraStyles slot state to bypass
jsdom CSS-engine flakiness.
Also fixes a small accessibility gap surfaced while writing tests:
passing \`invalid\` directly to Select now propagates to aria-invalid on
the rendered input, matching how Field.Root invalid inheritance already
worked.
A CI workflow runs the suite on push to main/v5 and on PR. Final tally:
271 passing, 4 skipped (upstream's own QUESTION-marked tests and
intentional Chakra divergences). The .oxlintrc.json ignores src/tests/
since upstream's style differs from our strict project rules.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* ci: limit test workflow push trigger to main
Each branch's workflow only knows about its code, so listing both
[main, v5] in a single workflow file is a footgun — only the branch
whose name matches will actually run, and pushing to the other
branch silently fires nothing useful from this file. Matches the
existing convention used by lint.yml, pkg-pr.yml, and zizmor.yml.
A parallel copy in the v5 branch should reference [v5] only.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: extract lint-staged config and filter ignored paths
Moves the lint-staged config from package.json into .lintstagedrc.cjs
so we can use a function to filter file lists before invoking oxlint.
oxlint exits non-zero with "No files found to lint" when every staged
path matches its ignorePatterns (e.g. a commit touching only files
under src/tests/), which broke the pre-commit hook for test-only
changes. The filter drops src/tests/ paths before invoking oxlint;
oxfmt still formats them via the catch-all glob.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test: pin react-select source version in ported test files
Each ported test file now carries a header comment with a permalink to
the exact upstream source at react-select@5.10.2 plus a brief re-port
checklist for future dep bumps. constants.ts gets a verbatim note
since its data fixtures should stay bit-identical with upstream.
No behavior change — comments only.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* ci: run tests across Node 20 and 24
Adds a Node version matrix to the test workflow so we catch regressions
that depend on the runtime — particularly relevant given the test suite
relies on jsdom whose CSS serialization differs across versions (we
already hit a jsdom 22 -> 25 change in caret-color handling). 20 is the
current LTS, 24 is the latest stable. fail-fast: false so a failure on
one runner doesn't cancel the other and obscure which is broken.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs: document the test suite in CONTRIBUTING
Adds a `pnpm test` bullet to the pre-PR checklist and a new Tests
section explaining the suite layout, the file naming convention, and
the manual re-port checklist for `react-select` dep bumps. The intent
is to make the porting boundary explicit so future contributors don't
fold chakra-specific assertions back into the ported files or skip
the upstream-source comments.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: switch lint-staged config to ESM
`.cjs` was unnecessary in a `type: commonjs` project — a plain `.js`
file already would have been CommonJS — and ESM is the better default
for new config files. Behavior unchanged from the previous .cjs
version. Uses `import.meta.dirname` (Node 20.11+); our CI matrix
requires Node 20+.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: lint-clean .lintstagedrc.mjs
Two layers:
* In source: name the default export (satisfies
import/no-anonymous-default-export) and add braces to the bare
if/return (satisfies eslint/curly). Both fixes are easy improvements
that match project style.
* In config: add a *.mjs override that disables rules which
fundamentally don't apply to root tooling configs —
import/no-nodejs-modules (Node tooling legitimately imports
node:built-ins) and the three typescript/no-unsafe-* rules (a .mjs
file has no TS declarations, so type-aware oxlint sees everything as
`any`).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test: enable oxlint on the test suite
Removes `src/tests/` from `.oxlintrc.json` `ignorePatterns` so the
tests now get linted alongside source. A scoped override exempts the
small set of rules that legitimately don't apply to spy/mock-style
test code: TS unsafe checks, the `cases()` non-null assertions,
react-perf inline-prop rules, jsx-a11y rules for synthetic fixtures,
and a handful of unicorn opinions that don't fit our jsdom env.
Also adds the `vitest` plugin and enables most of its rules
project-wide; the disables for vitest stylistic preferences
(`prefer-to-be*`, `prefer-lowercase-title`, etc.) live at the top
level since those rules are no-ops outside test files anyway.
Source side: a sweep that converts the upstream-ported style to
project conventions — `let` → `const` where appropriate, type-only
import splits, `toHaveLength`/`toStrictEqual` matcher upgrades,
function declarations to expressions, a few prefer-destructuring
rewrites, regex `u` flags, etc. Two intentional patterns get
per-line `oxlint-disable-next-line` comments (definite-assignment
`let event!:`, the 4th-element index in state-managed-select).
`init-declarations` ends up off project-wide. It conflicts with
`unicorn/no-useless-undefined` (one wants `= undefined`, the other
forbids it); we pick the no-useless-undefined style so
`let captured: T | undefined;` stays uninitialised. The change goes
at the top level rather than in the test override because the
preference is consistent for source code too.
Test counts: 271 passing, 4 skipped, 0 lint errors. Remaining lint
output is 4 `no-warning-comments` warnings (2 pre-existing project
TODOs in src/chakra-components, 2 upstream-ported `TODO: Cover more
scenarios` in select.test.tsx) — kept as warnings intentionally to
keep TODOs visible.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 49a968b commit cf64198
18 files changed
Lines changed: 6161 additions & 16 deletions
File tree
- .github/workflows
- src
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
62 | 71 | | |
63 | 72 | | |
64 | 73 | | |
| |||
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
| 106 | + | |
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
| |||
122 | 132 | | |
123 | 133 | | |
124 | 134 | | |
125 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
126 | 156 | | |
127 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
128 | 191 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
75 | 80 | | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
| 84 | + | |
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
82 | 89 | | |
83 | 90 | | |
84 | 91 | | |
| 92 | + | |
85 | 93 | | |
86 | | - | |
| 94 | + | |
| 95 | + | |
87 | 96 | | |
88 | 97 | | |
89 | 98 | | |
90 | 99 | | |
91 | 100 | | |
92 | 101 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | 102 | | |
99 | 103 | | |
0 commit comments