Commit Graph

183 Commits

Author SHA1 Message Date
Fredrik Adelöw b404647c64 Merge pull request #32080 from backstage/freben/search-first 2025-12-15 19:44:09 +01:00
Johan Persson cd0b8a11a3 chore: make jest a peer dependency with v29/v30 support
Move jest from dependencies to peer dependencies, allowing users to
choose between Jest 29 and Jest 30.

The CLI now detects the Jest version at runtime and uses the
appropriate environment:
- Jest 29: Uses standard jest-environment-jsdom
- Jest 30: Uses a custom environment based on @jest/environment-jsdom-abstract
  with fixes for Web API globals (fetch, streams, Error, etc.)

The cross-fetch polyfill is only injected for Jest 29, as with Jest 30+
our patched Jest environment is used. The network request blocker is made
MSW-compatible by checking if fetch was wrapped before blocking.

Jest 30 (with jsdom v27) fixes `Could not parse CSS stylesheet`
warnings/errors when testing components from @backstage/ui or other
packages using CSS `@layer` declarations.

New peer dependencies (install based on your Jest version):
- jest (required, ^29 or ^30)
- Jest 29 requires: jest-environment-jsdom
- Jest 30 requires: @jest/environment-jsdom-abstract, jsdom

Production code changes for jsdom 27 testability:
- AppIdentityProxy: extract navigateToUrl method for spying
- LiveReloadAddon: export utils.reloadPage for spying
- collect.ts: export internal.resolvePackagePath for mocking

MockFetchApi: evaluate global.fetch at call time instead of construction
time, allowing MSW to patch fetch after MockFetchApi is constructed.

Test adaptations for jsdom 27:
- Use RGB values instead of named colors in CSS assertions
- Update error format expectations (hyphenated type names, SyntaxError
  instead of FetchError for JSON parse errors)
- Simplify URL error assertions for cross-version compatibility
- Fix accessible name whitespace handling for external links
- Use history.replaceState for location mocking (non-configurable)
- Use fireEvent.blur for contentEditable elements
- Move async assertions inside waitFor for race conditions
- Remove Blob.prototype.text polyfill (now native)
- Remove test case using credentials in plugin:// URLs

Test adaptations for Jest 30:
- Replace `expect.objectContaining([...])` with direct array equality
- Replace `expect.objectContaining({ length: N })` with
  `expect.any(Array)` + separate `toHaveLength()` assertions
- Use child process for native Node.js module resolution in
  collect.test.ts to work around Jest 30's resolver behavior
- Update snapshot headers for new Jest format

Also removes the jest-haste-map patch which is no longer needed.

Signed-off-by: Johan Persson <johanopersson@gmail.com>
2025-12-11 18:06:55 +01:00
Fredrik Adelöw 8947a4eb82 skip the very first search on opening the app
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
2025-12-09 11:32:10 +01:00
Ben Lambert 3bdeb378e2 Merge pull request #31277 from Andy2003/feature/provide-icon-for-search-result-icon
Add support for customizable icons in SearchResultListItemBlueprint
2025-11-04 11:21:14 +01:00
Paul Schultz 05f60e1e0a refactor: convert constructor parameter properties for erasableSyntaxOnly compatibility
Signed-off-by: Paul Schultz <pschultz@pobox.com>
2025-10-14 08:29:21 -05:00
Andreas Berger 0a4e495019 Merge remote-tracking branch 'origin/master' into feature/provide-icon-for-search-result-icon 2025-10-09 08:50:15 +02:00
Andreas Berger a521911fbc Add support for customizable icons in SearchResultListItemBlueprint and related components
Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
2025-09-25 12:40:31 +02:00
Sydney Achinger 67a3e1a7a4 Implement AbortController request cancellation for search.
Signed-off-by: Sydney Achinger <sydneynicoleachinger@spotify.com>
2025-09-23 15:46:27 -04:00
Patrik Oldsberg e4ddf22854 frontend-plugin-api,catalog-react: remove default* prefix from blueprint params
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-08-04 16:46:55 +02:00
mario ma 869fa46bd2 feat: SearchBar clear button support i18n
Signed-off-by: mario ma <mario.ma.node@gmail.com>
2025-06-04 16:09:44 +08:00
Alex Lorenzi 7e0a10caae Merge pull request #29401 from mario-mui/feat/search-plugin-i18n
search plugin support i18n
2025-05-07 12:42:34 -04:00
mario ma d827c84fba fix unit test
Signed-off-by: mario ma <mario.ma.node@gmail.com>
2025-05-06 14:54:41 +08:00
mario ma c20b2285d6 fix report error
Signed-off-by: mario ma <mario.ma.node@gmail.com>
2025-05-06 14:54:41 +08:00
mario ma fa485943e4 search plugin support i18n
Signed-off-by: mario ma <mario.ma.node@gmail.com>
2025-05-06 14:54:39 +08:00
Moro 60100aeb0c prettier fix
Signed-off-by: Moro <sleeping.moro@gmail.com>
2025-05-02 23:13:13 +02:00
Moro 2c7661423c Add useMemo to searchFilter.Autocomplete filterValue
Signed-off-by: Moro <sleeping.moro@gmail.com>
Signed-off-by: Moro <46880495+sleepingmoro@users.noreply.github.com>
2025-05-02 20:53:35 +00:00
Gustaf Räntilä 611c941d8e Add support for providing values and labels to the search filters
Signed-off-by: Gustaf Räntilä <g.rantila@gmail.com>
2025-04-09 16:14:35 +02:00
Paul Schultz 2e26579e06 chore: update react imports
Signed-off-by: Paul Schultz <pschultz@pobox.com>
2025-04-08 07:35:24 -05:00
Agata Drapala cb070f7bd8 code clean-up
Signed-off-by: Agata Drapala <agata.drapala@gmail.com>
2025-02-17 13:17:51 +01:00
Agata Drapala 7507056511 testing two non-empty terms
Signed-off-by: Agata Drapala <agata.drapala@gmail.com>
2025-02-17 11:42:48 +01:00
Agata Drapala c37e4803f0 fix: capturing the correct number of search results in the search analytics event
Signed-off-by: Agata Drapala <agata.drapala@gmail.com>
2025-02-07 17:15:22 +01:00
Mark Dunphy 0027a010e7 add serch filter blueprint extension
Signed-off-by: Mark Dunphy <markd@spotify.com>
2025-01-07 20:48:03 -05:00
Mark Dunphy d90f71068a add blueprint extension for result type filter in search plugin
Signed-off-by: Mark Dunphy <markd@spotify.com>
2025-01-07 17:17:13 -05:00
Jonathan Roebuck c275960e73 add value to all option to fix a11y issue
Signed-off-by: Jonathan Roebuck <jroebuck@spotify.com>
2024-11-20 14:19:22 +00:00
Jonathan Roebuck d311c848ff Use core Select instead of Checkbox for filters
Signed-off-by: Jonathan Roebuck <jroebuck@spotify.com>
2024-11-20 14:19:22 +00:00
Fredrik Adelöw 811ff0cddc implement analytics too
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
2024-10-11 09:48:52 +02:00
Fredrik Adelöw 9cc7dd6cfd implement the beginnings of mockApis
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
2024-10-08 17:58:34 +02:00
blam 4a5ba19344 chore: removals
Signed-off-by: blam <ben@blam.sh>
2024-09-18 18:53:39 +02:00
Andre Wanlin 9adc552602 Refactoring based on feedback
Signed-off-by: Andre Wanlin <awanlin@spotify.com>
2024-09-10 15:05:42 -05:00
Andre Wanlin 32fce06e89 Added missing items to overridableComponents
Signed-off-by: Andre Wanlin <awanlin@spotify.com>
2024-09-10 15:05:42 -05:00
Fredrik Adelöw d76cc2974f Merge pull request #26396 from backstage/renovate/react-monorepo
chore(deps): update dependency @types/react to v18.3.5
2024-09-06 14:57:54 +02:00
Fredrik Adelöw dbbd93ec7f fixup
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
2024-09-06 10:49:28 +02:00
blam 1ac573b4f3 chore: smol refactor
Signed-off-by: blam <ben@blam.sh>
2024-09-03 07:59:02 +02:00
Patrik Oldsberg 00b9e8c010 update test snapshots for new structure of ExtensionDefinition
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-08-27 10:39:45 +02:00
Patrik Oldsberg e6e488cf20 frontend-test-utils: remove render method
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-08-27 09:39:08 +02:00
Fredrik Adelöw f26ff99a2f fixup
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
2024-08-23 14:42:50 +02:00
Fredrik Adelöw dae74b0d05 Merge pull request #25611 from RikClaessens/use-search-icon
Update the SearchBar to make use of the useApp hook to retrieve the search icon specified in the createApp call
2024-08-21 10:47:05 +02:00
Patrik Oldsberg d0501bb8c2 search-react: removed deprecated extension creators
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-08-20 12:15:09 +02:00
blam 4c39af8902 feat: small refactor for the search package
Co-authored-by: Fredrik Adelöw <freben@users.noreply.github.com>
Signed-off-by: blam <ben@blam.sh>
2024-08-15 09:59:55 +02:00
blam 8f8519d94e feat: implement search
Signed-off-by: blam <ben@blam.sh>
2024-08-15 09:59:55 +02:00
Rik Claessens d6ef48f201 Merge branch 'master' into use-search-icon 2024-08-07 14:59:34 +02:00
Patrik Oldsberg 31bfc4417f frontend-plugin-api: update extension data ref declaration to allow embedding of ID in type
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2024-07-22 10:20:38 +02:00
Rik Claessens f9011ac3d4 Wrap storybook components for SearchBar and SearchBarAutocomplete in wrapInTestApp
Signed-off-by: Rik Claessens <rhmclaessens@gmail.com>
2024-07-13 14:07:54 +02:00
Rik Claessens e460cbb027 Replace renderWithEffects with renderInTestApp to fix all existing tests
Signed-off-by: Rik Claessens <rhmclaessens@gmail.com>
2024-07-13 11:42:38 +02:00
Rik Claessens 85095afd82 Add test for checking if the SearchBar renders the provided custom search icon
Signed-off-by: Rik Claessens <rhmclaessens@gmail.com>
2024-07-13 11:40:40 +02:00
Rik Claessens 960b292c68 Replace renderWithEffects with renderInTestApp to fix all existing tests
Signed-off-by: Rik Claessens <rhmclaessens@gmail.com>
2024-07-13 11:31:09 +02:00
Rik Claessens 9d66d8cd90 Make use of the useApp hook to retrieve search icon
Signed-off-by: Rik Claessens <rhmclaessens@gmail.com>
2024-07-12 23:28:36 +02:00
Juan Pablo Garcia Ripa 8d50bd34fe add miu import rules to Search-react
Signed-off-by: Juan Pablo Garcia Ripa <sarabadu@gmail.com>
2024-04-13 22:04:44 +02:00
Tomasz Szuba e8f026a300 Use esm exports from react-use library
Signed-off-by: Tomasz Szuba <tszuba@box.com>
2024-03-19 19:53:04 +00:00
Emma Indal 6f280fa01a fix search issue analytics tracking
Signed-off-by: Emma Indal <emma.indahl@gmail.com>
2023-12-18 16:24:45 +01:00