Add an integration test suite#412
Merged
Merged
Conversation
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>
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>
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>
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>
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>
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>
`.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>
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>
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>
|
|
commit: |
📊 Package size report 0.2%↑
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
8 tasks
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
Adds the package's first real integration test suite, built on top of the upstream react-select tests with adaptations for the Chakra wrapper. Before this PR the only tests were in
codemod/; the package itself had zero coverage.What's in here
Ported from react-select@5.10.2 — the core component tests come straight from upstream, adapted only where chakra-react-select diverges. Each ported file carries a header comment with a permalink to its source at the pinned version:
src/tests/select.test.tsx←Select.test.tsxsrc/tests/async-select.test.tsx←Async.test.tsxsrc/tests/creatable-select.test.tsx←Creatable.test.tsxsrc/tests/async-creatable-select.test.tsx←AsyncCreatable.test.tsxsrc/tests/state-managed-select.test.tsx←StateManaged.test.tsxsrc/tests/constants.ts←constants.ts(verbatim — option fixtures)Adaptations applied to every ported file (also documented in CONTRIBUTING.md for future dep bumps):
../indexinstead of../Select/etc.render(seesrc/tests/render.tsx) replaces the bare@testing-library/reactrender.userEvent.setup()+await user.X(...)instead of synchronoususerEvent.X(...)(the upstream tests predate userEvent v14's async API).vi.fn/vi.mockinstead ofjest.fn/jest.mock.src/tests/cases.tsshim provides thejest-in-casecases()function (with per-caseskip/onlyflag support) so the upstream parameterised tests run unchanged.test.skiped withoxlint-disable-next-linecomments: either upstream's own QUESTION-marked tests (e.g. "we currently do not do this, do we want to?") or intentional Chakra divergences (thethemeprop is intentionally ignored in favor of Chakra's design tokens).Chakra-specific tests —
src/tests/chakra-specific.test.tsxcovers the props this package adds on top of react-select:size,variant,invalid,disabled,readOnly,chakraStyles,tagColorPalette,tagVariant,selectedOptionStyle,selectedOptionColorPalette,focusRingColor, plus theuseChakraSelectPropshook. Uses a "probe pattern" — pass achakraStylescallback that capturesstate.selectProps.<prop>— to verify wiring without depending on jsdom's CSS engine (which can't reliably parse Chakra's@layer-based CSS).One incidental fix — in
src/use-chakra-select-props.ts, passinginvaliddirectly to<Select>now propagates toaria-invalidon the input. Previously only<Field.Root invalid>did. Surfaced while writing the chakra-specific tests.Infrastructure
src/tests/setup.tswires up cleanup, amatchMediapolyfill (Chakra'suseMediaQuerycalls it on mount), and a jsdom virtualConsole filter that suppresses the "Could not parse CSS stylesheet" noise Chakra triggers per<style>insert..github/workflows/test.ymlruns the suite on Node 20 and 24, on push tomainand on PR.pnpm test,pnpm test:watchadded;prepublishOnlynow runs the suite too.Linting
After the initial port,
src/tests/was added to oxlint'signorePatternsbecause applying the project's full strict ruleset to upstream-style test code produced ~270 errors. The final commit on this branch reverses that — tests now get linted alongside source, with a scoped override in.oxlintrc.jsonfor the small set of rules that legitimately don't apply to spy/mock-style test code. Thevitestplugin is added project-wide (with stylistic preferences disabled).init-declarationsends up off project-wide because it directly conflicts withunicorn/no-useless-undefinedand we prefer the latter's style (let captured: T | undefined;overlet captured: T | undefined = undefined;).Test plan
pnpm lint— passes (4no-warning-commentswarnings for pre-existing project TODOs + upstream-ported// TODO: Cover more scenariosnotes; intentional)pnpm lint:types— cleanpnpm test— 271 passed / 4 skipped on both Node 20 and Node 24Out of scope
chakraStylescoverage is incomplete🤖 Generated with Claude Code