Commit 923d855
authored
chore: migrate tests to Vitest with Storybook interaction tests (#224)
* feat: migrate tests to Vitest with Storybook interaction tests
- Replace web-test-runner with Vitest 4.x + @storybook/addon-vitest
- Convert stories from JS to TypeScript with play functions
- Add autocomplete-keybindings.ts for keyboard handling
- Add shadow-dom-testing-library for shadow DOM queries
- Add global keybindings decorator in .storybook/preview.js
- Remove @open-wc/testing and @types/mocha dependencies
- Keep existing Playwright E2E visual tests
BREAKING CHANGE: Test infrastructure changed from web-test-runner to Vitest
* chore: include e2e tests in npm test script
* feat: add interaction tests to story play functions
- Add userEvent interactions to test keyboard navigation and selection
- Create InteractionTest stories for comprehensive E2E-style tests
- Keep Basic stories with read-only assertions for visual regression tests
- Add eslint override to disable max-lines for stories folder
- Test coverage: chip removal, item selection, no-results message, exclude toggle
* chore: enable autodocs for all stories
* chore: reorder stories - Autocomplete before Excluding
* fix: enable autodocs via tags for Storybook 10
* refactor: remove keybindings infrastructure (to be added later)
* test: migrate removed tests to Vitest unit tests and Storybook interaction tests
- Add unit tests for pure functions (search, mark) in test/utils.test.ts (11 tests)
- Extract pure functions to src/autocomplete/pure.ts for jsdom testability
- Add Storybook test stories for listbox (7 tests) and autocomplete (11 tests)
- Configure vitest with 'unit' project for jsdom-based tests
- Add jsdom dependency for unit testing pure functions
- Update eslint config for test files
* test: add missing coverage for external search, valueProperty, onSelect, keyboard edge cases
Add 10 new test stories to close coverage gaps from the @web/test-runner migration:
Autocomplete (4 stories):
- ExternalSearchMode: verifies client-side filtering is bypassed
- ValueProperty: verifies deduplication by valueProperty (id)
- OnSelectCallback: verifies onSelect receives (item, meta)
- Limit1DisablesBackspace: verifies use-keys disables when limit=1
Listbox (6 stories):
- KeyboardDownCycling: ArrowDown wraps from last to first item
- KeyboardUpNavigation: ArrowDown then ArrowUp returns to original
- HighlightAndEnter: mouseenter sets highlight, Enter selects it
- EnterDefaultIndex0: Enter with implicit defaultIndex=0
- CtrlAltIgnoresKeys: Ctrl+Alt modifier combo is ignored
- LegacyKeyNames: legacy 'Down'/'Up' key names are handled
* ci: remove separate playwright workflow, run e2e via npm test
* refactor: merge pure.ts back into util.ts, move useNotify into use-autocomplete1 parent 2829483 commit 923d855
File tree
26 files changed
+2616
-1555
lines changed- .github/workflows
- .storybook
- src/autocomplete
- stories
- tests
- test
- __snapshots__
26 files changed
+2616
-1555
lines changedThis file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | | - | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| 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 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
14 | 27 | | |
0 commit comments