Commit Graph

121 Commits

Author SHA1 Message Date
Patrik Oldsberg ec794b9e8b frontend-app-api: fix changed-package lint regressions
Declare the new frontend test dependencies, avoid the finalize options shadowing lint error, and add explicit assertions in frontend-test-utils so the changed-package lint jobs pass again.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
2026-03-17 13:05:00 +01:00
Patrik Oldsberg e66bbfc85c frontend-test-utils: prepare apps before finalizing
Move the test app helpers over to prepareSpecializedApp().finalize() so they stop depending on the deprecated createSpecializedApp entrypoint.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
2026-03-17 13:03:57 +01:00
Patrik Oldsberg 3b0c46e272 deprecate MockFetchApi class, keep MockFetchApiOptions
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
2026-03-05 13:56:51 +01:00
Patrik Oldsberg b56f573815 frontend-test-utils: deprecate standalone mock API exports
Deprecate all standalone mock API exports in favor of the `mockApis`
namespace. This includes the mock classes, their option types, and
the `ErrorWithContext` type. Inline option types into the `mockApis`
function signatures to avoid dependence on the deprecated types.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
2026-03-05 13:14:55 +01:00
Patrik Oldsberg fba2809b20 frontend-test-utils: add type tests for TestApiProvider
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-27 23:45:54 +01:00
Patrik Oldsberg 479282f38e frontend-test-utils: fix TestApiPair type inference for tuple syntax
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-27 21:23:18 +01:00
Patrik Oldsberg 909c742c18 Stabilize translation API in the new frontend system
Remove @alpha tags from translation-related types and switch all
translation API imports in new frontend system packages to use stable
paths from @backstage/frontend-plugin-api instead of
@backstage/core-plugin-api/alpha.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-23 21:23:05 +01:00
Patrik Oldsberg d56d9eae3c Explicitly disable v7 future flags to suppress warnings
Rather than removing the future prop, set v7_relativeSplatPath and
v7_startTransition to false so react-router stops logging deprecation
warnings.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-13 15:09:23 +01:00
Patrik Oldsberg 47d064a51b Revert react-router v7 future flags from #31818
Roll back the v7_relativeSplatPath and v7_startTransition future flags
and the Outlet-based route structure, keeping the version bump to
react-router-dom@^6.30.2.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-12 10:03:13 +01:00
Patrik Oldsberg 8fa6ef3452 frontend-test-utils: review fixes
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-10 10:42:32 +01:00
Patrik Oldsberg a7d4a3109c frontend-test-utils: consistent internal types for test api pairs
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-09 20:37:36 +01:00
Patrik Oldsberg 7ee7f122a8 frontend-test-utils: adjust fetch mock + add createApiMock
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-09 19:22:58 +01:00
Patrik Oldsberg 3f19d5ec32 frontend-test-utils: review fixes for readonly fields and config constructor
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 14:20:57 +01:00
Patrik Oldsberg b9d90a7140 frontend-test-utils: review and type fixes + cleanup
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-07 11:37:37 +01:00
Patrik Oldsberg f4bb4d1983 frontend-test-utils: remove redundant .factory util
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-07 00:34:36 +01:00
Patrik Oldsberg b9110a5724 frontend-test-utils: api cleanup, remove TestApiRegistry
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-06 22:48:22 +01:00
Patrik Oldsberg a18c64a285 frontend-test-utils: mock type exports comment
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-05 23:53:12 +01:00
Patrik Oldsberg 6362ca4b17 catalog-react: factory mock shortcut for catalogApiMock
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-05 23:50:30 +01:00
Patrik Oldsberg 0d7e331265 frontend-test-utils: shorthand mocks everywhere
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-05 23:50:29 +01:00
Patrik Oldsberg 14611301e5 frontend-test-utils: copy over all mock APIs
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-05 23:50:29 +01:00
Patrik Oldsberg a20cbb2514 frontend-test-utils: new utility for passing mock APIs directly
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-05 23:50:29 +01:00
Patrik Oldsberg d2ac2ec49d Add MockAlertApi and MockFeatureFlagsApi to frontend-test-utils
Introduces comprehensive mock implementations for AlertApi and FeatureFlagsApi in @backstage/frontend-test-utils, following the 3-pattern approach (function, factory, mock) for consistency with existing test utilities.

The new mocks include useful testing methods:
- MockAlertApi: clearAlerts(), waitForAlert(), getAlerts()
- MockFeatureFlagsApi: getState(), setState(), clearState()

Also adds a mockApis namespace that provides these new mocks and re-exports existing mockApis from @backstage/test-utils for backwards compatibility.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-05 23:50:28 +01:00
Patrik Oldsberg 15ed3f9ccb Add extension snapshot testing support to frontend-test-utils
Adds the snapshot() method to ExtensionTester, enabling snapshot
testing of extension tree structures. The snapshots use a tree-shaped
format that mirrors the extension hierarchy, with empty fields and
default values omitted for clarity.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-04 10:37:33 +01:00
Patrik Oldsberg 013ec22eab frontend-test-utils: add mountedRoutes option for renderTestApp + document
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-03 23:05:57 +01:00
Paul Schultz a7e0d506a2 feat: enable react router feature flags for v7
Signed-off-by: Paul Schultz <pschultz@pobox.com>
2026-02-03 09:37:11 -06:00
Patrik Oldsberg 1911ebac7f frontend-test-utils: also add apis option to renderTestApp
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-03 10:41:11 +01:00
Patrik Oldsberg 062e9dcf09 frontend-test-utils: update docs for TestApiProvider and friends
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-03 00:11:48 +01:00
Patrik Oldsberg 68d2c57d94 docs: update to prefer new apis option and use mockApis
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-03 00:11:48 +01:00
Patrik Oldsberg 09032d7bd4 frontend-app-api: add internal app options
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-03 00:11:48 +01:00
Patrik Oldsberg 22864b75a9 feat(frontend-test-utils): add API override support to test utilities
Added support for API overrides in `createExtensionTester` and
`renderInTestApp` to allow tests to override specific APIs without
requiring wrapper components. This provides app-level API overrides
that are available throughout the entire extension tree.

The `apis` option follows the same typing pattern as `TestApiProvider`
from `@backstage/test-utils` for consistency and type safety.

Example usage:

```typescript
const tester = createExtensionTester(MyExtension, {
  apis: [
    [errorApiRef, mockErrorApi],
    [analyticsApiRef, mockAnalyticsApi],
  ],
});

renderInTestApp(<MyComponent />, {
  apis: [
    [errorApiRef, mockErrorApi],
    [analyticsApiRef, mockAnalyticsApi],
  ],
});
```

This enables cleaner tests with app-level API overrides, eliminating
the need to wrap components with TestApiProvider in many cases.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-02-03 00:11:48 +01:00
Patrik Oldsberg d7dd5bdc80 frontend-test-utils: fix Router deprecation warning
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2026-01-21 10:34:44 +01:00
Vincenzo Scamporlino a8e223fa89 frontend-test-utils: marking as breaking
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
2025-10-13 15:14:02 +02:00
Vincenzo Scamporlino 116e05e294 frontend-test-utils: add initialRouteEntries option
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
2025-10-07 23:04:44 +02:00
Vincenzo Scamporlino 980bce1ff8 core-compat-api: use renderTestApp
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
2025-10-07 23:04:24 +02:00
Vincenzo Scamporlino 6c23efd539 frontend-test-utils: api-reports
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
2025-10-07 21:45:03 +02:00
Vincenzo Scamporlino 4a494abf78 frontend-test-utils: introduce renderTestApp and mark features option as deprecated
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
2025-10-07 21:45:03 +02:00
Vincenzo Scamporlino 1013eb72cb Revert "frontend-test-utils: render the element as Page"
This reverts commit 23c72e7e65.

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
2025-10-07 21:44:57 +02:00
Vincenzo Scamporlino 34680e981c frontend-test-utils: tweak test
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
2025-10-07 14:09:16 +02:00
Vincenzo Scamporlino 23c72e7e65 frontend-test-utils: render the element as Page
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
2025-10-07 12:40:12 +02:00
Vincenzo Scamporlino a26508eea4 fix renderInTestApp routing
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
2025-10-07 11:43:03 +02:00
Patrik Oldsberg 4907da392a frontend-test-utils: updated to use and report errors via error collector
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-09-08 12:38:36 +02:00
Patrik Oldsberg 3c3c8825b2 frontend-plugin-api: get rid of AnyExtensionDataRef
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-08-04 16:50:03 +02:00
Patrik Oldsberg eb62f764d1 Merge pull request #30709 from backstage/rugvip/no-feature
frontend-app-api: removed deprecated FrontendFeature type
2025-08-04 13:20:12 +02:00
Patrik Oldsberg df7bd3ba0d frontend-app-api: removed deprecated FrontendFeature type
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-08-04 13:06:11 +02:00
benjdlambert b465fbb09b chore: fixing types
Signed-off-by: benjdlambert <ben@blam.sh>
2025-07-31 16:38:53 +02:00
James Brooks cb3ad5a52d Move fix to AppRoutes
Signed-off-by: James Brooks <jamesbrooks@spotify.com>
2025-07-09 15:13:56 +01:00
James Brooks 09f5e36955 Fix duplicate slash in renderInTestApp routing
Signed-off-by: James Brooks <jamesbrooks@spotify.com>
2025-07-08 15:45:12 +01:00
Patrik Oldsberg fb58f20613 frontend-plugin-api: rename plugin ID option to pluginId
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-04-27 12:53:08 +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
Patrik Oldsberg f861bfcfb7 frontend-test-utils: add initial routes option and default config for renderInTestApp
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2025-03-11 10:32:45 +01:00