@backstage/frontend-test-utils 0.5.0-next.2 → 0.5.1-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +110 -0
- package/dist/apis/TranslationApi/MockTranslationApi.esm.js.map +1 -1
- package/dist/apis/mockApis.esm.js.map +1 -1
- package/dist/app/renderInTestApp.esm.js +2 -2
- package/dist/app/renderInTestApp.esm.js.map +1 -1
- package/dist/app/renderTestApp.esm.js +2 -2
- package/dist/app/renderTestApp.esm.js.map +1 -1
- package/dist/frontend-internal/src/wiring/InternalFrontendPlugin.esm.js.map +1 -1
- package/dist/index.d.ts +7 -8
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,115 @@
|
|
|
1
1
|
# @backstage/frontend-test-utils
|
|
2
2
|
|
|
3
|
+
## 0.5.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 909c742: Switched `MockTranslationApi` and related test utility imports from `@backstage/core-plugin-api/alpha` to the stable `@backstage/frontend-plugin-api` export. The `TranslationApi` type in the API report is now sourced from a single package. This has no effect on runtime behavior.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/frontend-plugin-api@0.14.2-next.0
|
|
10
|
+
- @backstage/plugin-app@0.4.1-next.0
|
|
11
|
+
- @backstage/config@1.3.6
|
|
12
|
+
- @backstage/core-app-api@1.19.6-next.0
|
|
13
|
+
- @backstage/core-plugin-api@1.12.4-next.0
|
|
14
|
+
- @backstage/frontend-app-api@0.15.1-next.0
|
|
15
|
+
- @backstage/test-utils@1.7.16-next.0
|
|
16
|
+
- @backstage/types@1.2.2
|
|
17
|
+
- @backstage/version-bridge@1.0.12
|
|
18
|
+
- @backstage/plugin-app-react@0.2.1-next.0
|
|
19
|
+
- @backstage/plugin-permission-common@0.9.6
|
|
20
|
+
- @backstage/plugin-permission-react@0.4.41-next.0
|
|
21
|
+
|
|
22
|
+
## 0.5.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- 09a6aad: **BREAKING**: Removed the `TestApiRegistry` class, use `TestApiProvider` directly instead, storing reused APIs in a variable, e.g. `const apis = [...] as const`.
|
|
27
|
+
- d2ac2ec: Added `MockAlertApi` and `MockFeatureFlagsApi` implementations to the `mockApis` namespace. The mock implementations include useful testing methods like `clearAlerts()`, `waitForAlert()`, `getState()`, `setState()`, and `clearState()` for better test ergonomics.
|
|
28
|
+
- 09a6aad: **BREAKING**: The `mockApis` namespace is no longer a re-export from `@backstage/test-utils`. It's now a standalone namespace with mock implementations of most core APIs. Mock API instances can be passed directly to `TestApiProvider`, `renderInTestApp`, and `renderTestApp` without needing `[apiRef, impl]` tuples. As part of this change, the `.factory()` method on some mocks has been removed, since it's now redundant.
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
// Before
|
|
32
|
+
import { mockApis } from '@backstage/frontend-test-utils';
|
|
33
|
+
|
|
34
|
+
renderInTestApp(<MyComponent />, {
|
|
35
|
+
apis: [[identityApiRef, mockApis.identity()]],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// After - mock APIs can be passed directly
|
|
39
|
+
renderInTestApp(<MyComponent />, {
|
|
40
|
+
apis: [mockApis.identity()],
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This change also adds `createApiMock`, a public utility for creating mock API factories, intended for plugin authors to create their own `.mock()` variants.
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- 22864b7: Added an `apis` option to `createExtensionTester`, `renderInTestApp`, and `renderTestApp` to override APIs when testing extensions. Use the `mockApis` helpers to create mock implementations:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { identityApiRef } from '@backstage/frontend-plugin-api';
|
|
52
|
+
import { mockApis } from '@backstage/frontend-test-utils';
|
|
53
|
+
|
|
54
|
+
// Override APIs in createExtensionTester
|
|
55
|
+
const tester = createExtensionTester(myExtension, {
|
|
56
|
+
apis: [
|
|
57
|
+
[
|
|
58
|
+
identityApiRef,
|
|
59
|
+
mockApis.identity({ userEntityRef: 'user:default/guest' }),
|
|
60
|
+
],
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Override APIs in renderInTestApp
|
|
65
|
+
renderInTestApp(<MyComponent />, {
|
|
66
|
+
apis: [
|
|
67
|
+
[
|
|
68
|
+
identityApiRef,
|
|
69
|
+
mockApis.identity({ userEntityRef: 'user:default/guest' }),
|
|
70
|
+
],
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Override APIs in renderTestApp
|
|
75
|
+
renderTestApp({
|
|
76
|
+
extensions: [myExtension],
|
|
77
|
+
apis: [
|
|
78
|
+
[
|
|
79
|
+
identityApiRef,
|
|
80
|
+
mockApis.identity({ userEntityRef: 'user:default/guest' }),
|
|
81
|
+
],
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- 15ed3f9: Added `snapshot()` method to `ExtensionTester`, which returns a tree-shaped representation of the resolved extension hierarchy. Convenient to use with `toMatchInlineSnapshot()`.
|
|
87
|
+
- 013ec22: Added `mountedRoutes` option to `renderTestApp` for binding route refs to paths, matching the existing option in `renderInTestApp`:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
renderTestApp({
|
|
91
|
+
extensions: [...],
|
|
92
|
+
mountedRoutes: {
|
|
93
|
+
'/my-path': myRouteRef,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- d7dd5bd: Fixed Router deprecation warning and switched to using new `RouterBlueprint` from `@backstage/plugin-app-api`.
|
|
99
|
+
- a7e0d50: Updated `react-router-dom` peer dependency to `^6.30.2` and explicitly disabled v7 future flags to suppress deprecation warnings.
|
|
100
|
+
- 69d880e: Bump to latest zod to ensure it has the latest features
|
|
101
|
+
- Updated dependencies
|
|
102
|
+
- @backstage/frontend-app-api@0.15.0
|
|
103
|
+
- @backstage/core-app-api@1.19.5
|
|
104
|
+
- @backstage/frontend-plugin-api@0.14.0
|
|
105
|
+
- @backstage/plugin-app-react@0.2.0
|
|
106
|
+
- @backstage/plugin-app@0.4.0
|
|
107
|
+
- @backstage/core-plugin-api@1.12.3
|
|
108
|
+
- @backstage/plugin-permission-react@0.4.40
|
|
109
|
+
- @backstage/version-bridge@1.0.12
|
|
110
|
+
- @backstage/test-utils@1.7.15
|
|
111
|
+
- @backstage/plugin-permission-common@0.9.6
|
|
112
|
+
|
|
3
113
|
## 0.5.0-next.2
|
|
4
114
|
|
|
5
115
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MockTranslationApi.esm.js","sources":["../../../src/apis/TranslationApi/MockTranslationApi.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n TranslationApi,\n TranslationRef,\n TranslationSnapshot,\n} from '@backstage/
|
|
1
|
+
{"version":3,"file":"MockTranslationApi.esm.js","sources":["../../../src/apis/TranslationApi/MockTranslationApi.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n TranslationApi,\n TranslationRef,\n TranslationSnapshot,\n} from '@backstage/frontend-plugin-api';\nimport { createInstance as createI18n, type i18n as I18n } from 'i18next';\nimport ObservableImpl from 'zen-observable';\n\nimport { Observable } from '@backstage/types';\n// Internal import to avoid code duplication, this will lead to duplication in build output\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalTranslationRef } from '../../../../frontend-plugin-api/src/translation/TranslationRef';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { JsxInterpolator } from '../../../../core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi';\n\nconst DEFAULT_LANGUAGE = 'en';\n\n/**\n * Mock implementation of {@link @backstage/frontend-plugin-api#TranslationApi}.\n *\n * @public\n */\nexport class MockTranslationApi implements TranslationApi {\n static create() {\n const i18n = createI18n({\n fallbackLng: DEFAULT_LANGUAGE,\n supportedLngs: [DEFAULT_LANGUAGE],\n interpolation: {\n escapeValue: false,\n // Used for the JsxInterpolator format hook\n alwaysFormat: true,\n },\n ns: [],\n defaultNS: false,\n fallbackNS: false,\n\n // Disable resource loading on init, meaning i18n will be ready to use immediately\n initImmediate: false,\n });\n\n i18n.init();\n if (!i18n.isInitialized) {\n throw new Error('i18next was unexpectedly not initialized');\n }\n\n const interpolator = JsxInterpolator.fromI18n(i18n);\n\n return new MockTranslationApi(i18n, interpolator);\n }\n\n readonly #i18n: I18n;\n readonly #interpolator: JsxInterpolator;\n readonly #registeredRefs = new Set<string>();\n\n private constructor(i18n: I18n, interpolator: JsxInterpolator) {\n this.#i18n = i18n;\n this.#interpolator = interpolator;\n }\n\n getTranslation<TMessages extends { [key in string]: string }>(\n translationRef: TranslationRef<string, TMessages>,\n ): TranslationSnapshot<TMessages> {\n const internalRef = toInternalTranslationRef(translationRef);\n\n if (!this.#registeredRefs.has(internalRef.id)) {\n this.#registeredRefs.add(internalRef.id);\n this.#i18n.addResourceBundle(\n DEFAULT_LANGUAGE,\n internalRef.id,\n internalRef.getDefaultMessages(),\n false, // do not merge\n true, // overwrite existing\n );\n }\n\n const t = this.#interpolator.wrapT<TMessages>(\n this.#i18n.getFixedT(null, internalRef.id),\n );\n\n return {\n ready: true,\n t,\n };\n }\n\n translation$<TMessages extends { [key in string]: string }>(): Observable<\n TranslationSnapshot<TMessages>\n > {\n // No need to implement, getTranslation will always return a ready snapshot\n return new ObservableImpl<TranslationSnapshot<TMessages>>(_subscriber => {\n return () => {};\n });\n }\n}\n"],"names":["createI18n"],"mappings":";;;;;AA+BA,MAAM,gBAAA,GAAmB,IAAA;AAOlB,MAAM,kBAAA,CAA6C;AAAA,EACxD,OAAO,MAAA,GAAS;AACd,IAAA,MAAM,OAAOA,cAAA,CAAW;AAAA,MACtB,WAAA,EAAa,gBAAA;AAAA,MACb,aAAA,EAAe,CAAC,gBAAgB,CAAA;AAAA,MAChC,aAAA,EAAe;AAAA,QACb,WAAA,EAAa,KAAA;AAAA;AAAA,QAEb,YAAA,EAAc;AAAA,OAChB;AAAA,MACA,IAAI,EAAC;AAAA,MACL,SAAA,EAAW,KAAA;AAAA,MACX,UAAA,EAAY,KAAA;AAAA;AAAA,MAGZ,aAAA,EAAe;AAAA,KAChB,CAAA;AAED,IAAA,IAAA,CAAK,IAAA,EAAK;AACV,IAAA,IAAI,CAAC,KAAK,aAAA,EAAe;AACvB,MAAA,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAAA,IAC5D;AAEA,IAAA,MAAM,YAAA,GAAe,eAAA,CAAgB,QAAA,CAAS,IAAI,CAAA;AAElD,IAAA,OAAO,IAAI,kBAAA,CAAmB,IAAA,EAAM,YAAY,CAAA;AAAA,EAClD;AAAA,EAES,KAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA,uBAAsB,GAAA,EAAY;AAAA,EAEnC,WAAA,CAAY,MAAY,YAAA,EAA+B;AAC7D,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAA;AACb,IAAA,IAAA,CAAK,aAAA,GAAgB,YAAA;AAAA,EACvB;AAAA,EAEA,eACE,cAAA,EACgC;AAChC,IAAA,MAAM,WAAA,GAAc,yBAAyB,cAAc,CAAA;AAE3D,IAAA,IAAI,CAAC,IAAA,CAAK,eAAA,CAAgB,GAAA,CAAI,WAAA,CAAY,EAAE,CAAA,EAAG;AAC7C,MAAA,IAAA,CAAK,eAAA,CAAgB,GAAA,CAAI,WAAA,CAAY,EAAE,CAAA;AACvC,MAAA,IAAA,CAAK,KAAA,CAAM,iBAAA;AAAA,QACT,gBAAA;AAAA,QACA,WAAA,CAAY,EAAA;AAAA,QACZ,YAAY,kBAAA,EAAmB;AAAA,QAC/B,KAAA;AAAA;AAAA,QACA;AAAA;AAAA,OACF;AAAA,IACF;AAEA,IAAA,MAAM,CAAA,GAAI,KAAK,aAAA,CAAc,KAAA;AAAA,MAC3B,IAAA,CAAK,KAAA,CAAM,SAAA,CAAU,IAAA,EAAM,YAAY,EAAE;AAAA,KAC3C;AAEA,IAAA,OAAO;AAAA,MACL,KAAA,EAAO,IAAA;AAAA,MACP;AAAA,KACF;AAAA,EACF;AAAA,EAEA,YAAA,GAEE;AAEA,IAAA,OAAO,IAAI,eAA+C,CAAA,WAAA,KAAe;AACvE,MAAA,OAAO,MAAM;AAAA,MAAC,CAAA;AAAA,IAChB,CAAC,CAAA;AAAA,EACH;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockApis.esm.js","sources":["../../src/apis/mockApis.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n alertApiRef,\n analyticsApiRef,\n configApiRef,\n discoveryApiRef,\n errorApiRef,\n fetchApiRef,\n featureFlagsApiRef,\n identityApiRef,\n storageApiRef,\n translationApiRef,\n type AnalyticsApi,\n type ConfigApi,\n type DiscoveryApi,\n type ErrorApi,\n type FetchApi,\n type IdentityApi,\n type StorageApi,\n type TranslationApi,\n} from '@backstage/frontend-plugin-api';\nimport {\n permissionApiRef,\n type PermissionApi,\n} from '@backstage/plugin-permission-react';\nimport { JsonObject } from '@backstage/types';\nimport {\n AuthorizeResult,\n EvaluatePermissionRequest,\n} from '@backstage/plugin-permission-common';\nimport { MockAlertApi } from './AlertApi';\nimport {\n MockFeatureFlagsApi,\n MockFeatureFlagsApiOptions,\n} from './FeatureFlagsApi';\nimport { MockAnalyticsApi } from './AnalyticsApi';\nimport { MockConfigApi } from './ConfigApi';\nimport { MockErrorApi, MockErrorApiOptions } from './ErrorApi';\nimport { MockFetchApi, MockFetchApiOptions } from './FetchApi';\nimport { MockStorageApi } from './StorageApi';\nimport { MockPermissionApi } from './PermissionApi';\nimport { MockTranslationApi } from './TranslationApi';\nimport {\n mockWithApiFactory,\n type MockWithApiFactory,\n} from './MockWithApiFactory';\nimport { createApiMock } from './createApiMock';\n\n/**\n * Mock implementations of the core utility APIs, to be used in tests.\n *\n * @public\n * @remarks\n *\n * There are some variations among the APIs depending on what needs tests\n * might have, but overall there are two main usage patterns:\n *\n * 1: Creating an actual fake API instance, often with a simplified version\n * of functionality, by calling the mock API itself as a function.\n *\n * ```ts\n * // The function often accepts parameters that control its behavior\n * const foo = mockApis.foo();\n * ```\n *\n * 2: Creating a mock API, where all methods are replaced with jest mocks, by\n * calling the API's `mock` function.\n *\n * ```ts\n * // You can optionally supply a subset of its methods to implement\n * const foo = mockApis.foo.mock({\n * someMethod: () => 'mocked result',\n * });\n * // After exercising your test, you can make assertions on the mock:\n * expect(foo.someMethod).toHaveBeenCalledTimes(2);\n * expect(foo.otherMethod).toHaveBeenCalledWith(testData);\n * ```\n */\nexport namespace mockApis {\n /**\n * Fake implementation of {@link @backstage/frontend-plugin-api#AlertApi}.\n *\n * @public\n * @example\n *\n * ```tsx\n * const alertApi = mockApis.alert();\n * alertApi.post({ message: 'Test alert' });\n * expect(alertApi.getAlerts()).toHaveLength(1);\n * ```\n */\n export function alert(): MockWithApiFactory<MockAlertApi> {\n const instance = new MockAlertApi();\n return mockWithApiFactory(\n alertApiRef,\n instance,\n ) as MockWithApiFactory<MockAlertApi>;\n }\n /**\n * Mock helpers for {@link @backstage/frontend-plugin-api#AlertApi}.\n *\n * @see {@link @backstage/frontend-plugin-api#mockApis.alert}\n * @public\n */\n export namespace alert {\n /**\n * Creates a mock implementation of\n * {@link @backstage/frontend-plugin-api#AlertApi}. All methods are\n * replaced with jest mock functions, and you can optionally pass in a\n * subset of methods with an explicit implementation.\n *\n * @public\n */\n export const mock = createApiMock(alertApiRef, () => ({\n post: jest.fn(),\n alert$: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/frontend-plugin-api#FeatureFlagsApi}.\n *\n * @public\n * @example\n *\n * ```tsx\n * const featureFlagsApi = mockApis.featureFlags({\n * initialStates: { 'my-feature': FeatureFlagState.Active },\n * });\n * expect(featureFlagsApi.isActive('my-feature')).toBe(true);\n * ```\n */\n export function featureFlags(\n options?: MockFeatureFlagsApiOptions,\n ): MockWithApiFactory<MockFeatureFlagsApi> {\n const instance = new MockFeatureFlagsApi(options);\n return mockWithApiFactory(\n featureFlagsApiRef,\n instance,\n ) as MockWithApiFactory<MockFeatureFlagsApi>;\n }\n /**\n * Mock helpers for {@link @backstage/frontend-plugin-api#FeatureFlagsApi}.\n *\n * @see {@link @backstage/frontend-plugin-api#mockApis.featureFlags}\n * @public\n */\n export namespace featureFlags {\n /**\n * Creates a mock implementation of\n * {@link @backstage/frontend-plugin-api#FeatureFlagsApi}. All methods are\n * replaced with jest mock functions, and you can optionally pass in a\n * subset of methods with an explicit implementation.\n *\n * @public\n */\n export const mock = createApiMock(featureFlagsApiRef, () => ({\n registerFlag: jest.fn(),\n getRegisteredFlags: jest.fn(),\n isActive: jest.fn(),\n save: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#AnalyticsApi}.\n *\n * @public\n */\n export function analytics(): MockAnalyticsApi &\n MockWithApiFactory<AnalyticsApi> {\n const instance = new MockAnalyticsApi();\n return mockWithApiFactory(analyticsApiRef, instance) as MockAnalyticsApi &\n MockWithApiFactory<AnalyticsApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#AnalyticsApi}.\n *\n * @public\n */\n export namespace analytics {\n export const mock = createApiMock(analyticsApiRef, () => ({\n captureEvent: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api/alpha#TranslationApi}.\n * By default returns the default translation.\n *\n * @public\n */\n export function translation(): MockTranslationApi &\n MockWithApiFactory<TranslationApi> {\n const instance = MockTranslationApi.create();\n return mockWithApiFactory(\n translationApiRef,\n instance,\n ) as MockTranslationApi & MockWithApiFactory<TranslationApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api/alpha#TranslationApi}.\n *\n * @see {@link @backstage/frontend-plugin-api#mockApis.translation}\n * @public\n */\n export namespace translation {\n /**\n * Creates a mock of {@link @backstage/core-plugin-api/alpha#TranslationApi}.\n *\n * @public\n */\n export const mock = createApiMock(translationApiRef, () => ({\n getTranslation: jest.fn(),\n translation$: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#ConfigApi}.\n *\n * @public\n */\n export function config(options?: {\n data?: JsonObject;\n }): MockConfigApi & MockWithApiFactory<ConfigApi> {\n const instance = new MockConfigApi({ data: options?.data ?? {} });\n return mockWithApiFactory(configApiRef, instance) as MockConfigApi &\n MockWithApiFactory<ConfigApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#ConfigApi}.\n *\n * @public\n */\n export namespace config {\n export const mock = createApiMock(configApiRef, () => ({\n has: jest.fn(),\n keys: jest.fn(),\n get: jest.fn(),\n getOptional: jest.fn(),\n getConfig: jest.fn(),\n getOptionalConfig: jest.fn(),\n getConfigArray: jest.fn(),\n getOptionalConfigArray: jest.fn(),\n getNumber: jest.fn(),\n getOptionalNumber: jest.fn(),\n getBoolean: jest.fn(),\n getOptionalBoolean: jest.fn(),\n getString: jest.fn(),\n getOptionalString: jest.fn(),\n getStringArray: jest.fn(),\n getOptionalStringArray: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#DiscoveryApi}.\n *\n * @public\n */\n export function discovery(options?: {\n baseUrl?: string;\n }): DiscoveryApi & MockWithApiFactory<DiscoveryApi> {\n const baseUrl = options?.baseUrl ?? 'http://example.com';\n const instance: DiscoveryApi = {\n async getBaseUrl(pluginId: string) {\n return `${baseUrl}/api/${pluginId}`;\n },\n };\n return mockWithApiFactory(discoveryApiRef, instance) as DiscoveryApi &\n MockWithApiFactory<DiscoveryApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#DiscoveryApi}.\n *\n * @public\n */\n export namespace discovery {\n export const mock = createApiMock(discoveryApiRef, () => ({\n getBaseUrl: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#IdentityApi}.\n *\n * @public\n */\n export function identity(options?: {\n userEntityRef?: string;\n ownershipEntityRefs?: string[];\n token?: string;\n email?: string;\n displayName?: string;\n picture?: string;\n }): MockWithApiFactory<IdentityApi> {\n const {\n userEntityRef = 'user:default/test',\n ownershipEntityRefs = ['user:default/test'],\n token,\n email,\n displayName,\n picture,\n } = options ?? {};\n const instance: IdentityApi = {\n async getBackstageIdentity() {\n return { type: 'user', ownershipEntityRefs, userEntityRef };\n },\n async getCredentials() {\n return { token };\n },\n async getProfileInfo() {\n return { email, displayName, picture };\n },\n async signOut() {},\n };\n return mockWithApiFactory(identityApiRef, instance) as IdentityApi &\n MockWithApiFactory<IdentityApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#IdentityApi}.\n *\n * @public\n */\n export namespace identity {\n export const mock = createApiMock(identityApiRef, () => ({\n getBackstageIdentity: jest.fn(),\n getCredentials: jest.fn(),\n getProfileInfo: jest.fn(),\n signOut: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/plugin-permission-react#PermissionApi}.\n *\n * @public\n */\n export function permission(options?: {\n authorize?:\n | AuthorizeResult.ALLOW\n | AuthorizeResult.DENY\n | ((\n request: EvaluatePermissionRequest,\n ) => AuthorizeResult.ALLOW | AuthorizeResult.DENY);\n }): MockPermissionApi & MockWithApiFactory<PermissionApi> {\n const authorizeInput = options?.authorize;\n const handler =\n typeof authorizeInput === 'function'\n ? authorizeInput\n : () => authorizeInput ?? AuthorizeResult.ALLOW;\n const instance = new MockPermissionApi(handler);\n return mockWithApiFactory(permissionApiRef, instance) as MockPermissionApi &\n MockWithApiFactory<PermissionApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/plugin-permission-react#PermissionApi}.\n *\n * @public\n */\n export namespace permission {\n export const mock = createApiMock(permissionApiRef, () => ({\n authorize: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#StorageApi}.\n *\n * @public\n */\n export function storage(options?: {\n data?: JsonObject;\n }): MockStorageApi & MockWithApiFactory<StorageApi> {\n const instance = MockStorageApi.create(options?.data);\n return mockWithApiFactory(storageApiRef, instance) as MockStorageApi &\n MockWithApiFactory<StorageApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#StorageApi}.\n *\n * @public\n */\n export namespace storage {\n export const mock = createApiMock(storageApiRef, () => ({\n forBucket: jest.fn(),\n snapshot: jest.fn(),\n set: jest.fn(),\n remove: jest.fn(),\n observe$: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#ErrorApi}.\n *\n * @public\n */\n export function error(\n options?: MockErrorApiOptions,\n ): MockErrorApi & MockWithApiFactory<ErrorApi> {\n const instance = new MockErrorApi(options);\n return mockWithApiFactory(errorApiRef, instance) as MockErrorApi &\n MockWithApiFactory<ErrorApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#ErrorApi}.\n *\n * @public\n */\n export namespace error {\n export const mock = createApiMock(errorApiRef, () => ({\n post: jest.fn(),\n error$: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#FetchApi}.\n *\n * @public\n */\n export function fetch(\n options?: MockFetchApiOptions,\n ): MockFetchApi & MockWithApiFactory<FetchApi> {\n const instance = new MockFetchApi(options);\n return mockWithApiFactory(fetchApiRef, instance) as MockFetchApi &\n MockWithApiFactory<FetchApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#FetchApi}.\n *\n * @public\n */\n export namespace fetch {\n export const mock = createApiMock(fetchApiRef, () => ({\n fetch: jest.fn(),\n }));\n }\n}\n"],"names":["mockApis","alert","featureFlags","analytics","translation","config","discovery","identity","permission","storage","error","fetch"],"mappings":";;;;;;;;;;;;;;;AA6FO,IAAU;AAAA,CAAV,CAAUA,SAAAA,KAAV;AAaE,EAAA,SAAS,KAAA,GAA0C;AACxD,IAAA,MAAM,QAAA,GAAW,IAAI,YAAA,EAAa;AAClC,IAAA,OAAO,kBAAA;AAAA,MACL,WAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AANO,EAAAA,SAAAA,CAAS,KAAA,GAAA,KAAA;AAaT,EAAA,CAAA,CAAUC,MAAAA,KAAV;AASE,IAAMA,MAAAA,CAAA,IAAA,GAAO,aAAA,CAAc,WAAA,EAAa,OAAO;AAAA,MACpD,IAAA,EAAM,KAAK,EAAA,EAAG;AAAA,MACd,MAAA,EAAQ,KAAK,EAAA;AAAG,KAClB,CAAE,CAAA;AAAA,EAAA,CAAA,EAZa,KAAA,GAAAD,SAAAA,CAAA,KAAA,KAAAA,SAAAA,CAAA,KAAA,GAAA,EAAA,CAAA,CAAA;AA4BV,EAAA,SAAS,aACd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Aa,OAAO;AAAA,MACpD,IAAA,EAAM,KAAK,EAAA,EAAG;AAAA,MACd,MAAA,EAAQ,KAAK,EAAA;AAAG,KAClB,CAAE,CAAA;AAAA,EAAA,CAAA,EAJa,KAAA,GAAAV,SAAAA,CAAA,KAAA,KAAAA,SAAAA,CAAA,KAAA,GAAA,EAAA,CAAA,CAAA;AAYV,EAAA,SAAS,MACd,OAAA,EAC6C;AAC7C,IAAA,MAAM,QAAA,GAAW,IAAI,YAAA,CAAa,OAAO,CAAA;AACzC,IAAA,OAAO,kBAAA,CAAmB,aAAa,QAAQ,CAAA;AAAA,EAEjD;AANO,EAAAA,SAAAA,CAAS,KAAA,GAAA,KAAA;AAaT,EAAA,CAAA,CAAUW,MAAAA,KAAV;AACE,IAAMA,MAAAA,CAAA,IAAA,GAAO,aAAA,CAAc,WAAA,EAAa,OAAO;AAAA,MACpD,KAAA,EAAO,KAAK,EAAA;AAAG,KACjB,CAAE,CAAA;AAAA,EAAA,CAAA,EAHa,KAAA,GAAAX,SAAAA,CAAA,KAAA,KAAAA,SAAAA,CAAA,KAAA,GAAA,EAAA,CAAA,CAAA;AAAA,CAAA,EA9WF,QAAA,KAAA,QAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"mockApis.esm.js","sources":["../../src/apis/mockApis.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n alertApiRef,\n analyticsApiRef,\n configApiRef,\n discoveryApiRef,\n errorApiRef,\n fetchApiRef,\n featureFlagsApiRef,\n identityApiRef,\n storageApiRef,\n translationApiRef,\n type AnalyticsApi,\n type ConfigApi,\n type DiscoveryApi,\n type ErrorApi,\n type FetchApi,\n type IdentityApi,\n type StorageApi,\n type TranslationApi,\n} from '@backstage/frontend-plugin-api';\nimport {\n permissionApiRef,\n type PermissionApi,\n} from '@backstage/plugin-permission-react';\nimport { JsonObject } from '@backstage/types';\nimport {\n AuthorizeResult,\n EvaluatePermissionRequest,\n} from '@backstage/plugin-permission-common';\nimport { MockAlertApi } from './AlertApi';\nimport {\n MockFeatureFlagsApi,\n MockFeatureFlagsApiOptions,\n} from './FeatureFlagsApi';\nimport { MockAnalyticsApi } from './AnalyticsApi';\nimport { MockConfigApi } from './ConfigApi';\nimport { MockErrorApi, MockErrorApiOptions } from './ErrorApi';\nimport { MockFetchApi, MockFetchApiOptions } from './FetchApi';\nimport { MockStorageApi } from './StorageApi';\nimport { MockPermissionApi } from './PermissionApi';\nimport { MockTranslationApi } from './TranslationApi';\nimport {\n mockWithApiFactory,\n type MockWithApiFactory,\n} from './MockWithApiFactory';\nimport { createApiMock } from './createApiMock';\n\n/**\n * Mock implementations of the core utility APIs, to be used in tests.\n *\n * @public\n * @remarks\n *\n * There are some variations among the APIs depending on what needs tests\n * might have, but overall there are two main usage patterns:\n *\n * 1: Creating an actual fake API instance, often with a simplified version\n * of functionality, by calling the mock API itself as a function.\n *\n * ```ts\n * // The function often accepts parameters that control its behavior\n * const foo = mockApis.foo();\n * ```\n *\n * 2: Creating a mock API, where all methods are replaced with jest mocks, by\n * calling the API's `mock` function.\n *\n * ```ts\n * // You can optionally supply a subset of its methods to implement\n * const foo = mockApis.foo.mock({\n * someMethod: () => 'mocked result',\n * });\n * // After exercising your test, you can make assertions on the mock:\n * expect(foo.someMethod).toHaveBeenCalledTimes(2);\n * expect(foo.otherMethod).toHaveBeenCalledWith(testData);\n * ```\n */\nexport namespace mockApis {\n /**\n * Fake implementation of {@link @backstage/frontend-plugin-api#AlertApi}.\n *\n * @public\n * @example\n *\n * ```tsx\n * const alertApi = mockApis.alert();\n * alertApi.post({ message: 'Test alert' });\n * expect(alertApi.getAlerts()).toHaveLength(1);\n * ```\n */\n export function alert(): MockWithApiFactory<MockAlertApi> {\n const instance = new MockAlertApi();\n return mockWithApiFactory(\n alertApiRef,\n instance,\n ) as MockWithApiFactory<MockAlertApi>;\n }\n /**\n * Mock helpers for {@link @backstage/frontend-plugin-api#AlertApi}.\n *\n * @see {@link @backstage/frontend-plugin-api#mockApis.alert}\n * @public\n */\n export namespace alert {\n /**\n * Creates a mock implementation of\n * {@link @backstage/frontend-plugin-api#AlertApi}. All methods are\n * replaced with jest mock functions, and you can optionally pass in a\n * subset of methods with an explicit implementation.\n *\n * @public\n */\n export const mock = createApiMock(alertApiRef, () => ({\n post: jest.fn(),\n alert$: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/frontend-plugin-api#FeatureFlagsApi}.\n *\n * @public\n * @example\n *\n * ```tsx\n * const featureFlagsApi = mockApis.featureFlags({\n * initialStates: { 'my-feature': FeatureFlagState.Active },\n * });\n * expect(featureFlagsApi.isActive('my-feature')).toBe(true);\n * ```\n */\n export function featureFlags(\n options?: MockFeatureFlagsApiOptions,\n ): MockWithApiFactory<MockFeatureFlagsApi> {\n const instance = new MockFeatureFlagsApi(options);\n return mockWithApiFactory(\n featureFlagsApiRef,\n instance,\n ) as MockWithApiFactory<MockFeatureFlagsApi>;\n }\n /**\n * Mock helpers for {@link @backstage/frontend-plugin-api#FeatureFlagsApi}.\n *\n * @see {@link @backstage/frontend-plugin-api#mockApis.featureFlags}\n * @public\n */\n export namespace featureFlags {\n /**\n * Creates a mock implementation of\n * {@link @backstage/frontend-plugin-api#FeatureFlagsApi}. All methods are\n * replaced with jest mock functions, and you can optionally pass in a\n * subset of methods with an explicit implementation.\n *\n * @public\n */\n export const mock = createApiMock(featureFlagsApiRef, () => ({\n registerFlag: jest.fn(),\n getRegisteredFlags: jest.fn(),\n isActive: jest.fn(),\n save: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#AnalyticsApi}.\n *\n * @public\n */\n export function analytics(): MockAnalyticsApi &\n MockWithApiFactory<AnalyticsApi> {\n const instance = new MockAnalyticsApi();\n return mockWithApiFactory(analyticsApiRef, instance) as MockAnalyticsApi &\n MockWithApiFactory<AnalyticsApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#AnalyticsApi}.\n *\n * @public\n */\n export namespace analytics {\n export const mock = createApiMock(analyticsApiRef, () => ({\n captureEvent: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/frontend-plugin-api#TranslationApi}.\n * By default returns the default translation.\n *\n * @public\n */\n export function translation(): MockTranslationApi &\n MockWithApiFactory<TranslationApi> {\n const instance = MockTranslationApi.create();\n return mockWithApiFactory(\n translationApiRef,\n instance,\n ) as MockTranslationApi & MockWithApiFactory<TranslationApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/frontend-plugin-api#TranslationApi}.\n *\n * @see {@link @backstage/frontend-plugin-api#mockApis.translation}\n * @public\n */\n export namespace translation {\n /**\n * Creates a mock of {@link @backstage/frontend-plugin-api#TranslationApi}.\n *\n * @public\n */\n export const mock = createApiMock(translationApiRef, () => ({\n getTranslation: jest.fn(),\n translation$: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#ConfigApi}.\n *\n * @public\n */\n export function config(options?: {\n data?: JsonObject;\n }): MockConfigApi & MockWithApiFactory<ConfigApi> {\n const instance = new MockConfigApi({ data: options?.data ?? {} });\n return mockWithApiFactory(configApiRef, instance) as MockConfigApi &\n MockWithApiFactory<ConfigApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#ConfigApi}.\n *\n * @public\n */\n export namespace config {\n export const mock = createApiMock(configApiRef, () => ({\n has: jest.fn(),\n keys: jest.fn(),\n get: jest.fn(),\n getOptional: jest.fn(),\n getConfig: jest.fn(),\n getOptionalConfig: jest.fn(),\n getConfigArray: jest.fn(),\n getOptionalConfigArray: jest.fn(),\n getNumber: jest.fn(),\n getOptionalNumber: jest.fn(),\n getBoolean: jest.fn(),\n getOptionalBoolean: jest.fn(),\n getString: jest.fn(),\n getOptionalString: jest.fn(),\n getStringArray: jest.fn(),\n getOptionalStringArray: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#DiscoveryApi}.\n *\n * @public\n */\n export function discovery(options?: {\n baseUrl?: string;\n }): DiscoveryApi & MockWithApiFactory<DiscoveryApi> {\n const baseUrl = options?.baseUrl ?? 'http://example.com';\n const instance: DiscoveryApi = {\n async getBaseUrl(pluginId: string) {\n return `${baseUrl}/api/${pluginId}`;\n },\n };\n return mockWithApiFactory(discoveryApiRef, instance) as DiscoveryApi &\n MockWithApiFactory<DiscoveryApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#DiscoveryApi}.\n *\n * @public\n */\n export namespace discovery {\n export const mock = createApiMock(discoveryApiRef, () => ({\n getBaseUrl: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#IdentityApi}.\n *\n * @public\n */\n export function identity(options?: {\n userEntityRef?: string;\n ownershipEntityRefs?: string[];\n token?: string;\n email?: string;\n displayName?: string;\n picture?: string;\n }): MockWithApiFactory<IdentityApi> {\n const {\n userEntityRef = 'user:default/test',\n ownershipEntityRefs = ['user:default/test'],\n token,\n email,\n displayName,\n picture,\n } = options ?? {};\n const instance: IdentityApi = {\n async getBackstageIdentity() {\n return { type: 'user', ownershipEntityRefs, userEntityRef };\n },\n async getCredentials() {\n return { token };\n },\n async getProfileInfo() {\n return { email, displayName, picture };\n },\n async signOut() {},\n };\n return mockWithApiFactory(identityApiRef, instance) as IdentityApi &\n MockWithApiFactory<IdentityApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#IdentityApi}.\n *\n * @public\n */\n export namespace identity {\n export const mock = createApiMock(identityApiRef, () => ({\n getBackstageIdentity: jest.fn(),\n getCredentials: jest.fn(),\n getProfileInfo: jest.fn(),\n signOut: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/plugin-permission-react#PermissionApi}.\n *\n * @public\n */\n export function permission(options?: {\n authorize?:\n | AuthorizeResult.ALLOW\n | AuthorizeResult.DENY\n | ((\n request: EvaluatePermissionRequest,\n ) => AuthorizeResult.ALLOW | AuthorizeResult.DENY);\n }): MockPermissionApi & MockWithApiFactory<PermissionApi> {\n const authorizeInput = options?.authorize;\n const handler =\n typeof authorizeInput === 'function'\n ? authorizeInput\n : () => authorizeInput ?? AuthorizeResult.ALLOW;\n const instance = new MockPermissionApi(handler);\n return mockWithApiFactory(permissionApiRef, instance) as MockPermissionApi &\n MockWithApiFactory<PermissionApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/plugin-permission-react#PermissionApi}.\n *\n * @public\n */\n export namespace permission {\n export const mock = createApiMock(permissionApiRef, () => ({\n authorize: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#StorageApi}.\n *\n * @public\n */\n export function storage(options?: {\n data?: JsonObject;\n }): MockStorageApi & MockWithApiFactory<StorageApi> {\n const instance = MockStorageApi.create(options?.data);\n return mockWithApiFactory(storageApiRef, instance) as MockStorageApi &\n MockWithApiFactory<StorageApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#StorageApi}.\n *\n * @public\n */\n export namespace storage {\n export const mock = createApiMock(storageApiRef, () => ({\n forBucket: jest.fn(),\n snapshot: jest.fn(),\n set: jest.fn(),\n remove: jest.fn(),\n observe$: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#ErrorApi}.\n *\n * @public\n */\n export function error(\n options?: MockErrorApiOptions,\n ): MockErrorApi & MockWithApiFactory<ErrorApi> {\n const instance = new MockErrorApi(options);\n return mockWithApiFactory(errorApiRef, instance) as MockErrorApi &\n MockWithApiFactory<ErrorApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#ErrorApi}.\n *\n * @public\n */\n export namespace error {\n export const mock = createApiMock(errorApiRef, () => ({\n post: jest.fn(),\n error$: jest.fn(),\n }));\n }\n\n /**\n * Fake implementation of {@link @backstage/core-plugin-api#FetchApi}.\n *\n * @public\n */\n export function fetch(\n options?: MockFetchApiOptions,\n ): MockFetchApi & MockWithApiFactory<FetchApi> {\n const instance = new MockFetchApi(options);\n return mockWithApiFactory(fetchApiRef, instance) as MockFetchApi &\n MockWithApiFactory<FetchApi>;\n }\n\n /**\n * Mock helpers for {@link @backstage/core-plugin-api#FetchApi}.\n *\n * @public\n */\n export namespace fetch {\n export const mock = createApiMock(fetchApiRef, () => ({\n fetch: jest.fn(),\n }));\n }\n}\n"],"names":["mockApis","alert","featureFlags","analytics","translation","config","discovery","identity","permission","storage","error","fetch"],"mappings":";;;;;;;;;;;;;;;AA6FO,IAAU;AAAA,CAAV,CAAUA,SAAAA,KAAV;AAaE,EAAA,SAAS,KAAA,GAA0C;AACxD,IAAA,MAAM,QAAA,GAAW,IAAI,YAAA,EAAa;AAClC,IAAA,OAAO,kBAAA;AAAA,MACL,WAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AANO,EAAAA,SAAAA,CAAS,KAAA,GAAA,KAAA;AAaT,EAAA,CAAA,CAAUC,MAAAA,KAAV;AASE,IAAMA,MAAAA,CAAA,IAAA,GAAO,aAAA,CAAc,WAAA,EAAa,OAAO;AAAA,MACpD,IAAA,EAAM,KAAK,EAAA,EAAG;AAAA,MACd,MAAA,EAAQ,KAAK,EAAA;AAAG,KAClB,CAAE,CAAA;AAAA,EAAA,CAAA,EAZa,KAAA,GAAAD,SAAAA,CAAA,KAAA,KAAAA,SAAAA,CAAA,KAAA,GAAA,EAAA,CAAA,CAAA;AA4BV,EAAA,SAAS,aACd,OAAA,EACyC;AACzC,IAAA,MAAM,QAAA,GAAW,IAAI,mBAAA,CAAoB,OAAO,CAAA;AAChD,IAAA,OAAO,kBAAA;AAAA,MACL,kB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AA,EAAA,CAAA,EAJa,KAAA,GAAAV,SAAAA,CAAA,KAAA,KAAAA,SAAAA,CAAA,KAAA,GAAA,EAAA,CAAA,CAAA;AAYV,EAAA,SAAS,MACd,OAAA,EAC6C;AAC7C,IAAA,MAAM,QAAA,GAAW,IAAI,YAAA,CAAa,OAAO,CAAA;AACzC,IAAA,OAAO,kBAAA,CAAmB,aAAa,QAAQ,CAAA;AAAA,EAEjD;AANO,EAAAA,SAAAA,CAAS,KAAA,GAAA,KAAA;AAaT,EAAA,CAAA,CAAUW,MAAAA,KAAV;AACE,IAAMA,MAAAA,CAAA,IAAA,GAAO,aAAA,CAAc,WAAA,EAAa,OAAO;AAAA,MACpD,KAAA,EAAO,KAAK,EAAA;AAAG,KACjB,CAAE,CAAA;AAAA,EAAA,CAAA,EAHa,KAAA,GAAAX,SAAAA,CAAA,KAAA,KAAAA,SAAAA,CAAA,KAAA,GAAA,EAAA,CAAA,CAAA;AAAA,CAAA,EA9WF,QAAA,KAAA,QAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -103,8 +103,8 @@ function renderInTestApp(element, options) {
|
|
|
103
103
|
{
|
|
104
104
|
initialEntries: options?.initialRouteEntries,
|
|
105
105
|
future: {
|
|
106
|
-
v7_relativeSplatPath:
|
|
107
|
-
v7_startTransition:
|
|
106
|
+
v7_relativeSplatPath: false,
|
|
107
|
+
v7_startTransition: false
|
|
108
108
|
},
|
|
109
109
|
children
|
|
110
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderInTestApp.esm.js","sources":["../../src/app/renderInTestApp.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment } from 'react';\nimport { Link, MemoryRouter } from 'react-router-dom';\nimport { createSpecializedApp } from '@backstage/frontend-app-api';\nimport { RenderResult, render } from '@testing-library/react';\nimport { ConfigReader } from '@backstage/config';\nimport { JsonObject } from '@backstage/types';\nimport {\n createExtension,\n ExtensionDefinition,\n coreExtensionData,\n RouteRef,\n useRouteRef,\n IconComponent,\n NavItemBlueprint,\n createFrontendPlugin,\n FrontendFeature,\n createFrontendModule,\n createApiFactory,\n type ApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { RouterBlueprint } from '@backstage/plugin-app-react';\nimport appPlugin from '@backstage/plugin-app';\nimport { getMockApiFactory } from '../apis/MockWithApiFactory';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type { CreateSpecializedAppInternalOptions } from '../../../frontend-app-api/src/wiring/createSpecializedApp';\nimport { TestApiPairs } from '../apis/TestApiProvider';\n\nconst DEFAULT_MOCK_CONFIG = {\n app: { baseUrl: 'http://localhost:3000' },\n backend: { baseUrl: 'http://localhost:7007' },\n};\n\n/**\n * Options to customize the behavior of the test app.\n * @public\n */\nexport type TestAppOptions<TApiPairs extends any[] = any[]> = {\n /**\n * An object of paths to mount route ref on, with the key being the path and the value\n * being the RouteRef that the path will be bound to. This allows the route refs to be\n * used by `useRouteRef` in the rendered elements.\n *\n * @example\n * ```ts\n * renderInTestApp(<MyComponent />, {\n * mountedRoutes: {\n * '/my-path': myRouteRef,\n * }\n * })\n * // ...\n * const link = useRouteRef(myRouteRef)\n * ```\n */\n mountedRoutes?: { [path: string]: RouteRef };\n\n /**\n * Additional configuration passed to the app when rendering elements inside it.\n */\n config?: JsonObject;\n\n /**\n * Additional features to add to the test app.\n */\n features?: FrontendFeature[];\n\n /**\n * Initial route entries to use for the router.\n */\n initialRouteEntries?: string[];\n\n /**\n * API overrides to provide to the test app. Use `mockApis` helpers\n * from `@backstage/frontend-test-utils` to create mock implementations.\n *\n * @example\n * ```ts\n * import { mockApis } from '@backstage/frontend-test-utils';\n *\n * renderInTestApp(<MyComponent />, {\n * apis: [mockApis.identity({ userEntityRef: 'user:default/guest' })],\n * })\n * ```\n */\n apis?: readonly [...TestApiPairs<TApiPairs>];\n};\n\nconst NavItem = (props: {\n routeRef: RouteRef<undefined>;\n title: string;\n icon: IconComponent;\n}) => {\n const { routeRef, title, icon: Icon } = props;\n const link = useRouteRef(routeRef);\n if (!link) {\n return null;\n }\n return (\n <li>\n <Link to={link()}>\n <Icon /> {title}\n </Link>\n </li>\n );\n};\n\nconst appPluginOverride = appPlugin.withOverrides({\n extensions: [\n appPlugin.getExtension('sign-in-page:app').override({\n disabled: true,\n }),\n appPlugin.getExtension('app/layout').override({\n disabled: true,\n }),\n appPlugin.getExtension('app/routes').override({\n disabled: true,\n }),\n appPlugin.getExtension('app/nav').override({\n output: [coreExtensionData.reactElement],\n factory(_originalFactory, { inputs }) {\n return [\n coreExtensionData.reactElement(\n <nav>\n <ul>\n {inputs.items.map((item, index) => {\n const { icon, title, routeRef } = item.get(\n NavItemBlueprint.dataRefs.target,\n );\n\n return (\n <NavItem\n key={index}\n icon={icon}\n title={title}\n routeRef={routeRef}\n />\n );\n })}\n </ul>\n </nav>,\n ),\n ];\n },\n }),\n ],\n});\n\n/**\n * @public\n * Renders the given element in a test app, for use in unit tests.\n */\nexport function renderInTestApp<const TApiPairs extends any[] = any[]>(\n element: JSX.Element,\n options?: TestAppOptions<TApiPairs>,\n): RenderResult {\n const extensions: Array<ExtensionDefinition> = [\n createExtension({\n attachTo: { id: 'app/root', input: 'children' },\n output: [coreExtensionData.reactElement],\n factory: () => {\n return [coreExtensionData.reactElement(element)];\n },\n }),\n ];\n\n if (options?.mountedRoutes) {\n for (const [path, routeRef] of Object.entries(options.mountedRoutes)) {\n // TODO(Rugvip): add support for external route refs\n extensions.push(\n createExtension({\n kind: 'test-route',\n name: path,\n attachTo: { id: 'app/root', input: 'elements' },\n output: [\n coreExtensionData.reactElement,\n coreExtensionData.routePath,\n coreExtensionData.routeRef,\n ],\n factory: () => [\n coreExtensionData.reactElement(<Fragment />),\n coreExtensionData.routePath(path),\n coreExtensionData.routeRef(routeRef),\n ],\n }),\n );\n }\n }\n\n const features: FrontendFeature[] = [\n createFrontendModule({\n pluginId: 'app',\n extensions: [\n RouterBlueprint.make({\n params: {\n component: ({ children }) => (\n <MemoryRouter\n initialEntries={options?.initialRouteEntries}\n future={{\n v7_relativeSplatPath: true,\n v7_startTransition: true,\n }}\n >\n {children}\n </MemoryRouter>\n ),\n },\n }),\n ],\n }),\n createFrontendPlugin({\n pluginId: 'test',\n extensions,\n }),\n appPluginOverride,\n ];\n\n if (options?.features) {\n features.push(...options.features);\n }\n\n const app = createSpecializedApp({\n features,\n config: ConfigReader.fromConfigs([\n {\n context: 'render-config',\n data: options?.config ?? DEFAULT_MOCK_CONFIG,\n },\n ]),\n __internal: options?.apis && {\n apiFactoryOverrides: options.apis.map(entry => {\n const mockFactory = getMockApiFactory(entry);\n if (mockFactory) {\n return mockFactory;\n }\n const [apiRef, implementation] = entry as readonly [ApiRef<any>, any];\n return createApiFactory(apiRef, implementation);\n }),\n },\n } as CreateSpecializedAppInternalOptions);\n\n return render(\n app.tree.root.instance!.getData(coreExtensionData.reactElement),\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA2CA,MAAM,mBAAA,GAAsB;AAAA,EAC1B,GAAA,EAAK,EAAE,OAAA,EAAS,uBAAA,EAAwB;AAAA,EACxC,OAAA,EAAS,EAAE,OAAA,EAAS,uBAAA;AACtB,CAAA;AAwDA,MAAM,OAAA,GAAU,CAAC,KAAA,KAIX;AACJ,EAAA,MAAM,EAAE,QAAA,EAAU,KAAA,EAAO,IAAA,EAAM,MAAK,GAAI,KAAA;AACxC,EAAA,MAAM,IAAA,GAAO,YAAY,QAAQ,CAAA;AACjC,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,IAAA;AA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CAAA;AAExC,EAAA,OAAO,MAAA;AAAA,IACL,IAAI,IAAA,CAAK,IAAA,CAAK,QAAA,CAAU,OAAA,CAAQ,kBAAkB,YAAY;AAAA,GAChE;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"renderInTestApp.esm.js","sources":["../../src/app/renderInTestApp.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment } from 'react';\nimport { Link, MemoryRouter } from 'react-router-dom';\nimport { createSpecializedApp } from '@backstage/frontend-app-api';\nimport { RenderResult, render } from '@testing-library/react';\nimport { ConfigReader } from '@backstage/config';\nimport { JsonObject } from '@backstage/types';\nimport {\n createExtension,\n ExtensionDefinition,\n coreExtensionData,\n RouteRef,\n useRouteRef,\n IconComponent,\n NavItemBlueprint,\n createFrontendPlugin,\n FrontendFeature,\n createFrontendModule,\n createApiFactory,\n type ApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { RouterBlueprint } from '@backstage/plugin-app-react';\nimport appPlugin from '@backstage/plugin-app';\nimport { getMockApiFactory } from '../apis/MockWithApiFactory';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type { CreateSpecializedAppInternalOptions } from '../../../frontend-app-api/src/wiring/createSpecializedApp';\nimport { TestApiPairs } from '../apis/TestApiProvider';\n\nconst DEFAULT_MOCK_CONFIG = {\n app: { baseUrl: 'http://localhost:3000' },\n backend: { baseUrl: 'http://localhost:7007' },\n};\n\n/**\n * Options to customize the behavior of the test app.\n * @public\n */\nexport type TestAppOptions<TApiPairs extends any[] = any[]> = {\n /**\n * An object of paths to mount route ref on, with the key being the path and the value\n * being the RouteRef that the path will be bound to. This allows the route refs to be\n * used by `useRouteRef` in the rendered elements.\n *\n * @example\n * ```ts\n * renderInTestApp(<MyComponent />, {\n * mountedRoutes: {\n * '/my-path': myRouteRef,\n * }\n * })\n * // ...\n * const link = useRouteRef(myRouteRef)\n * ```\n */\n mountedRoutes?: { [path: string]: RouteRef };\n\n /**\n * Additional configuration passed to the app when rendering elements inside it.\n */\n config?: JsonObject;\n\n /**\n * Additional features to add to the test app.\n */\n features?: FrontendFeature[];\n\n /**\n * Initial route entries to use for the router.\n */\n initialRouteEntries?: string[];\n\n /**\n * API overrides to provide to the test app. Use `mockApis` helpers\n * from `@backstage/frontend-test-utils` to create mock implementations.\n *\n * @example\n * ```ts\n * import { mockApis } from '@backstage/frontend-test-utils';\n *\n * renderInTestApp(<MyComponent />, {\n * apis: [mockApis.identity({ userEntityRef: 'user:default/guest' })],\n * })\n * ```\n */\n apis?: readonly [...TestApiPairs<TApiPairs>];\n};\n\nconst NavItem = (props: {\n routeRef: RouteRef<undefined>;\n title: string;\n icon: IconComponent;\n}) => {\n const { routeRef, title, icon: Icon } = props;\n const link = useRouteRef(routeRef);\n if (!link) {\n return null;\n }\n return (\n <li>\n <Link to={link()}>\n <Icon /> {title}\n </Link>\n </li>\n );\n};\n\nconst appPluginOverride = appPlugin.withOverrides({\n extensions: [\n appPlugin.getExtension('sign-in-page:app').override({\n disabled: true,\n }),\n appPlugin.getExtension('app/layout').override({\n disabled: true,\n }),\n appPlugin.getExtension('app/routes').override({\n disabled: true,\n }),\n appPlugin.getExtension('app/nav').override({\n output: [coreExtensionData.reactElement],\n factory(_originalFactory, { inputs }) {\n return [\n coreExtensionData.reactElement(\n <nav>\n <ul>\n {inputs.items.map((item, index) => {\n const { icon, title, routeRef } = item.get(\n NavItemBlueprint.dataRefs.target,\n );\n\n return (\n <NavItem\n key={index}\n icon={icon}\n title={title}\n routeRef={routeRef}\n />\n );\n })}\n </ul>\n </nav>,\n ),\n ];\n },\n }),\n ],\n});\n\n/**\n * @public\n * Renders the given element in a test app, for use in unit tests.\n */\nexport function renderInTestApp<const TApiPairs extends any[] = any[]>(\n element: JSX.Element,\n options?: TestAppOptions<TApiPairs>,\n): RenderResult {\n const extensions: Array<ExtensionDefinition> = [\n createExtension({\n attachTo: { id: 'app/root', input: 'children' },\n output: [coreExtensionData.reactElement],\n factory: () => {\n return [coreExtensionData.reactElement(element)];\n },\n }),\n ];\n\n if (options?.mountedRoutes) {\n for (const [path, routeRef] of Object.entries(options.mountedRoutes)) {\n // TODO(Rugvip): add support for external route refs\n extensions.push(\n createExtension({\n kind: 'test-route',\n name: path,\n attachTo: { id: 'app/root', input: 'elements' },\n output: [\n coreExtensionData.reactElement,\n coreExtensionData.routePath,\n coreExtensionData.routeRef,\n ],\n factory: () => [\n coreExtensionData.reactElement(<Fragment />),\n coreExtensionData.routePath(path),\n coreExtensionData.routeRef(routeRef),\n ],\n }),\n );\n }\n }\n\n const features: FrontendFeature[] = [\n createFrontendModule({\n pluginId: 'app',\n extensions: [\n RouterBlueprint.make({\n params: {\n component: ({ children }) => (\n <MemoryRouter\n initialEntries={options?.initialRouteEntries}\n future={{\n v7_relativeSplatPath: false,\n v7_startTransition: false,\n }}\n >\n {children}\n </MemoryRouter>\n ),\n },\n }),\n ],\n }),\n createFrontendPlugin({\n pluginId: 'test',\n extensions,\n }),\n appPluginOverride,\n ];\n\n if (options?.features) {\n features.push(...options.features);\n }\n\n const app = createSpecializedApp({\n features,\n config: ConfigReader.fromConfigs([\n {\n context: 'render-config',\n data: options?.config ?? DEFAULT_MOCK_CONFIG,\n },\n ]),\n __internal: options?.apis && {\n apiFactoryOverrides: options.apis.map(entry => {\n const mockFactory = getMockApiFactory(entry);\n if (mockFactory) {\n return mockFactory;\n }\n const [apiRef, implementation] = entry as readonly [ApiRef<any>, any];\n return createApiFactory(apiRef, implementation);\n }),\n },\n } as CreateSpecializedAppInternalOptions);\n\n return render(\n app.tree.root.instance!.get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AM,SAAS,MAAA,IAAU;AAAA;AAC3B,KACD,CAAA;AAAA,IACD,UAAA,EAAY,SAAS,IAAA,IAAQ;AAAA,MAC3B,mBAAA,EAAqB,OAAA,CAAQ,IAAA,CAAK,GAAA,CAAI,CAAA,KAAA,KAAS;AAC7C,QAAA,MAAM,WAAA,GAAc,kBAAkB,KAAK,CAAA;AAC3C,QAAA,IAAI,WAAA,EAAa;AACf,UAAA,OAAO,WAAA;AAAA,QACT;AACA,QAAA,MAAM,CAAC,MAAA,EAAQ,cAAc,CAAA,GAAI,KAAA;AACjC,QAAA,OAAO,gBAAA,CAAiB,QAAQ,cAAc,CAAA;AAAA,MAChD,CAAC;AAAA;AACH,GACsC,CAAA;AAExC,EAAA,OAAO,MAAA;AAAA,IACL,IAAI,IAAA,CAAK,IAAA,CAAK,QAAA,CAAU,OAAA,CAAQ,kBAAkB,YAAY;AAAA,GAChE;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderTestApp.esm.js","sources":["../../src/app/renderTestApp.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment } from 'react';\nimport { createSpecializedApp } from '@backstage/frontend-app-api';\nimport {\n coreExtensionData,\n createApiFactory,\n createExtension,\n createFrontendModule,\n createFrontendPlugin,\n ExtensionDefinition,\n FrontendFeature,\n RouteRef,\n type ApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { render, type RenderResult } from '@testing-library/react';\nimport appPlugin from '@backstage/plugin-app';\nimport { JsonObject } from '@backstage/types';\nimport { ConfigReader } from '@backstage/config';\nimport { MemoryRouter } from 'react-router-dom';\nimport { RouterBlueprint } from '@backstage/plugin-app-react';\nimport { getMockApiFactory } from '../apis/MockWithApiFactory';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type { CreateSpecializedAppInternalOptions } from '../../../frontend-app-api/src/wiring/createSpecializedApp';\nimport { TestApiPairs } from '../apis/TestApiProvider';\n\nconst DEFAULT_MOCK_CONFIG = {\n app: { baseUrl: 'http://localhost:3000' },\n backend: { baseUrl: 'http://localhost:7007' },\n};\n\n/**\n * Options for `renderTestApp`.\n *\n * @public\n */\nexport type RenderTestAppOptions<TApiPairs extends any[] = any[]> = {\n /**\n * Additional configuration passed to the app when rendering elements inside it.\n */\n config?: JsonObject;\n /**\n * Additional extensions to add to the test app.\n */\n extensions?: ExtensionDefinition<any>[];\n\n /**\n * Additional features to add to the test app.\n */\n features?: FrontendFeature[];\n\n /**\n * Initial route entries to use for the router.\n */\n initialRouteEntries?: string[];\n\n /**\n * An object of paths to mount route refs on, with the key being the path and\n * the value being the RouteRef that the path will be bound to. This allows\n * the route refs to be used by `useRouteRef` in the rendered elements.\n *\n * @example\n * ```ts\n * renderTestApp({\n * mountedRoutes: {\n * '/my-path': myRouteRef,\n * },\n * extensions: [...],\n * })\n * ```\n */\n mountedRoutes?: { [path: string]: RouteRef };\n\n /**\n * API overrides to provide to the test app. Use `mockApis` helpers\n * from `@backstage/frontend-test-utils` to create mock implementations.\n *\n * @example\n * ```ts\n * import { mockApis } from '@backstage/frontend-test-utils';\n *\n * renderTestApp({\n * apis: [mockApis.identity({ userEntityRef: 'user:default/guest' })],\n * extensions: [...],\n * })\n * ```\n */\n apis?: readonly [...TestApiPairs<TApiPairs>];\n};\n\nconst appPluginOverride = appPlugin.withOverrides({\n extensions: [\n appPlugin.getExtension('sign-in-page:app').override({\n disabled: true,\n }),\n ],\n});\n\n/**\n * Renders the provided extensions inside a Backstage app, returning the same\n * utilities as `@testing-library/react` `render` function.\n *\n * @public\n */\nexport function renderTestApp<const TApiPairs extends any[] = any[]>(\n options?: RenderTestAppOptions<TApiPairs>,\n): RenderResult {\n const extensions = [...(options?.extensions ?? [])];\n\n if (options?.mountedRoutes) {\n for (const [path, routeRef] of Object.entries(options.mountedRoutes)) {\n extensions.push(\n createExtension({\n kind: 'test-route',\n name: path,\n attachTo: { id: 'app/routes', input: 'routes' },\n output: [\n coreExtensionData.reactElement,\n coreExtensionData.routePath,\n coreExtensionData.routeRef,\n ],\n factory: () => [\n coreExtensionData.reactElement(<Fragment />),\n coreExtensionData.routePath(path),\n coreExtensionData.routeRef(routeRef),\n ],\n }),\n );\n }\n }\n\n const features: FrontendFeature[] = [\n createFrontendModule({\n pluginId: 'app',\n extensions: [\n RouterBlueprint.make({\n params: {\n component: ({ children }) => (\n <MemoryRouter\n initialEntries={options?.initialRouteEntries}\n future={{\n v7_relativeSplatPath:
|
|
1
|
+
{"version":3,"file":"renderTestApp.esm.js","sources":["../../src/app/renderTestApp.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment } from 'react';\nimport { createSpecializedApp } from '@backstage/frontend-app-api';\nimport {\n coreExtensionData,\n createApiFactory,\n createExtension,\n createFrontendModule,\n createFrontendPlugin,\n ExtensionDefinition,\n FrontendFeature,\n RouteRef,\n type ApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { render, type RenderResult } from '@testing-library/react';\nimport appPlugin from '@backstage/plugin-app';\nimport { JsonObject } from '@backstage/types';\nimport { ConfigReader } from '@backstage/config';\nimport { MemoryRouter } from 'react-router-dom';\nimport { RouterBlueprint } from '@backstage/plugin-app-react';\nimport { getMockApiFactory } from '../apis/MockWithApiFactory';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport type { CreateSpecializedAppInternalOptions } from '../../../frontend-app-api/src/wiring/createSpecializedApp';\nimport { TestApiPairs } from '../apis/TestApiProvider';\n\nconst DEFAULT_MOCK_CONFIG = {\n app: { baseUrl: 'http://localhost:3000' },\n backend: { baseUrl: 'http://localhost:7007' },\n};\n\n/**\n * Options for `renderTestApp`.\n *\n * @public\n */\nexport type RenderTestAppOptions<TApiPairs extends any[] = any[]> = {\n /**\n * Additional configuration passed to the app when rendering elements inside it.\n */\n config?: JsonObject;\n /**\n * Additional extensions to add to the test app.\n */\n extensions?: ExtensionDefinition<any>[];\n\n /**\n * Additional features to add to the test app.\n */\n features?: FrontendFeature[];\n\n /**\n * Initial route entries to use for the router.\n */\n initialRouteEntries?: string[];\n\n /**\n * An object of paths to mount route refs on, with the key being the path and\n * the value being the RouteRef that the path will be bound to. This allows\n * the route refs to be used by `useRouteRef` in the rendered elements.\n *\n * @example\n * ```ts\n * renderTestApp({\n * mountedRoutes: {\n * '/my-path': myRouteRef,\n * },\n * extensions: [...],\n * })\n * ```\n */\n mountedRoutes?: { [path: string]: RouteRef };\n\n /**\n * API overrides to provide to the test app. Use `mockApis` helpers\n * from `@backstage/frontend-test-utils` to create mock implementations.\n *\n * @example\n * ```ts\n * import { mockApis } from '@backstage/frontend-test-utils';\n *\n * renderTestApp({\n * apis: [mockApis.identity({ userEntityRef: 'user:default/guest' })],\n * extensions: [...],\n * })\n * ```\n */\n apis?: readonly [...TestApiPairs<TApiPairs>];\n};\n\nconst appPluginOverride = appPlugin.withOverrides({\n extensions: [\n appPlugin.getExtension('sign-in-page:app').override({\n disabled: true,\n }),\n ],\n});\n\n/**\n * Renders the provided extensions inside a Backstage app, returning the same\n * utilities as `@testing-library/react` `render` function.\n *\n * @public\n */\nexport function renderTestApp<const TApiPairs extends any[] = any[]>(\n options?: RenderTestAppOptions<TApiPairs>,\n): RenderResult {\n const extensions = [...(options?.extensions ?? [])];\n\n if (options?.mountedRoutes) {\n for (const [path, routeRef] of Object.entries(options.mountedRoutes)) {\n extensions.push(\n createExtension({\n kind: 'test-route',\n name: path,\n attachTo: { id: 'app/routes', input: 'routes' },\n output: [\n coreExtensionData.reactElement,\n coreExtensionData.routePath,\n coreExtensionData.routeRef,\n ],\n factory: () => [\n coreExtensionData.reactElement(<Fragment />),\n coreExtensionData.routePath(path),\n coreExtensionData.routeRef(routeRef),\n ],\n }),\n );\n }\n }\n\n const features: FrontendFeature[] = [\n createFrontendModule({\n pluginId: 'app',\n extensions: [\n RouterBlueprint.make({\n params: {\n component: ({ children }) => (\n <MemoryRouter\n initialEntries={options?.initialRouteEntries}\n future={{\n v7_relativeSplatPath: false,\n v7_startTransition: false,\n }}\n >\n {children}\n </MemoryRouter>\n ),\n },\n }),\n ],\n }),\n createFrontendPlugin({\n pluginId: 'test',\n extensions,\n }),\n appPluginOverride,\n ];\n\n if (options?.features) {\n features.push(...options.features);\n }\n\n const app = createSpecializedApp({\n features,\n config: ConfigReader.fromConfigs([\n {\n context: 'render-config',\n data: options?.config ?? DEFAULT_MOCK_CONFIG,\n },\n ]),\n __internal: options?.apis && {\n apiFactoryOverrides: options.apis.map(entry => {\n const mockFactory = getMockApiFactory(entry);\n if (mockFactory) {\n return mockFactory;\n }\n const [apiRef, implementation] = entry as readonly [ApiRef<any>, any];\n return createApiFactory(apiRef, implementation);\n }),\n },\n } as CreateSpecializedAppInternalOptions);\n\n return render(\n app.tree.root.instance!.getData(coreExtensionData.reactElement),\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAwCA,MAAM,mBAAA,GAAsB;AAAA,EAC1B,GAAA,EAAK,EAAE,OAAA,EAAS,uBAAA,EAAwB;AAAA,EACxC,OAAA,EAAS,EAAE,OAAA,EAAS,uBAAA;AACtB,CAAA;AA6DA,MAAM,iBAAA,GAAoB,UAAU,aAAA,CAAc;AA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"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Extension,\n FeatureFlagConfig,\n OverridableFrontendPlugin,\n} from '@backstage/frontend-plugin-api';\nimport { JsonObject } from '@backstage/types';\nimport { OpaqueType } from '@internal/opaque';\n\nexport const OpaqueFrontendPlugin = OpaqueType.create<{\n public: OverridableFrontendPlugin;\n versions: {\n readonly version: 'v1';\n readonly extensions: Extension<unknown>[];\n readonly featureFlags: FeatureFlagConfig[];\n readonly infoOptions?: {\n packageJson?: () => Promise<JsonObject>;\n manifest?: () => Promise<JsonObject>;\n };\n };\n}>({\n type: '@backstage/FrontendPlugin',\n versions: ['v1'],\n});\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"InternalFrontendPlugin.esm.js","sources":["../../../../../frontend-internal/src/wiring/InternalFrontendPlugin.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Extension,\n FeatureFlagConfig,\n IconElement,\n OverridableFrontendPlugin,\n} from '@backstage/frontend-plugin-api';\nimport { JsonObject } from '@backstage/types';\nimport { OpaqueType } from '@internal/opaque';\n\nexport const OpaqueFrontendPlugin = OpaqueType.create<{\n public: OverridableFrontendPlugin;\n versions: {\n readonly version: 'v1';\n readonly title?: string;\n readonly icon?: IconElement;\n readonly extensions: Extension<unknown>[];\n readonly featureFlags: FeatureFlagConfig[];\n readonly infoOptions?: {\n packageJson?: () => Promise<JsonObject>;\n manifest?: () => Promise<JsonObject>;\n };\n };\n}>({\n type: '@backstage/FrontendPlugin',\n versions: ['v1'],\n});\n"],"names":[],"mappings":";;AAyBO,MAAM,oBAAA,GAAuB,WAAW,MAAA,CAa5C;AAAA,EACD,IAAA,EAAM,2BAAA;AAAA,EACN,QAAA,EAAU,CAAC,IAAI;AACjB,CAAC;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as _backstage_config from '@backstage/config';
|
|
2
2
|
import { Config } from '@backstage/config';
|
|
3
3
|
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
4
|
-
import { ApiFactory, ApiRef, AlertApi, AlertMessage, FeatureFlagState, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, AnalyticsApi, AnalyticsEvent, TranslationApi
|
|
4
|
+
import { ApiFactory, ApiRef, AlertApi, AlertMessage, FeatureFlagState, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, AnalyticsApi, AnalyticsEvent, TranslationApi, TranslationRef, TranslationSnapshot, ConfigApi as ConfigApi$1, DiscoveryApi as DiscoveryApi$1, IdentityApi as IdentityApi$1, StorageApi as StorageApi$1, ErrorApi as ErrorApi$1, FetchApi as FetchApi$1, ExtensionDefinitionParameters, ExtensionDefinition, ExtensionDataRef, AppNode, RouteRef, FrontendFeature } from '@backstage/frontend-plugin-api';
|
|
5
5
|
import { PermissionApi } from '@backstage/plugin-permission-react';
|
|
6
6
|
import { Observable, JsonObject, JsonValue } from '@backstage/types';
|
|
7
7
|
import { EvaluatePermissionRequest, AuthorizeResult, EvaluatePermissionResponse } from '@backstage/plugin-permission-common';
|
|
8
8
|
import { ConfigApi, ErrorApi, ErrorApiError, ErrorApiErrorContext, DiscoveryApi, IdentityApi, FetchApi, StorageApi, StorageValueSnapshot } from '@backstage/core-plugin-api';
|
|
9
|
-
import { TranslationApi, TranslationRef, TranslationSnapshot } from '@backstage/core-plugin-api/alpha';
|
|
10
9
|
import { ReactNode } from 'react';
|
|
11
10
|
import { RenderResult } from '@testing-library/react';
|
|
12
11
|
export { registerMswTestHooks, withLogCollector } from '@backstage/test-utils';
|
|
@@ -390,7 +389,7 @@ declare class MockPermissionApi implements PermissionApi {
|
|
|
390
389
|
}
|
|
391
390
|
|
|
392
391
|
/**
|
|
393
|
-
* Mock implementation of {@link @backstage/
|
|
392
|
+
* Mock implementation of {@link @backstage/frontend-plugin-api#TranslationApi}.
|
|
394
393
|
*
|
|
395
394
|
* @public
|
|
396
395
|
*/
|
|
@@ -513,25 +512,25 @@ declare namespace mockApis {
|
|
|
513
512
|
const mock: (partialImpl?: Partial<AnalyticsApi> | undefined) => ApiMock<AnalyticsApi>;
|
|
514
513
|
}
|
|
515
514
|
/**
|
|
516
|
-
* Fake implementation of {@link @backstage/
|
|
515
|
+
* Fake implementation of {@link @backstage/frontend-plugin-api#TranslationApi}.
|
|
517
516
|
* By default returns the default translation.
|
|
518
517
|
*
|
|
519
518
|
* @public
|
|
520
519
|
*/
|
|
521
|
-
function translation(): MockTranslationApi & MockWithApiFactory<TranslationApi
|
|
520
|
+
function translation(): MockTranslationApi & MockWithApiFactory<TranslationApi>;
|
|
522
521
|
/**
|
|
523
|
-
* Mock helpers for {@link @backstage/
|
|
522
|
+
* Mock helpers for {@link @backstage/frontend-plugin-api#TranslationApi}.
|
|
524
523
|
*
|
|
525
524
|
* @see {@link @backstage/frontend-plugin-api#mockApis.translation}
|
|
526
525
|
* @public
|
|
527
526
|
*/
|
|
528
527
|
namespace translation {
|
|
529
528
|
/**
|
|
530
|
-
* Creates a mock of {@link @backstage/
|
|
529
|
+
* Creates a mock of {@link @backstage/frontend-plugin-api#TranslationApi}.
|
|
531
530
|
*
|
|
532
531
|
* @public
|
|
533
532
|
*/
|
|
534
|
-
const mock: (partialImpl?: Partial<TranslationApi
|
|
533
|
+
const mock: (partialImpl?: Partial<TranslationApi> | undefined) => ApiMock<TranslationApi>;
|
|
535
534
|
}
|
|
536
535
|
/**
|
|
537
536
|
* Fake implementation of {@link @backstage/core-plugin-api#ConfigApi}.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/frontend-test-utils",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1-next.0",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "web-library"
|
|
6
6
|
},
|
|
@@ -32,23 +32,23 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@backstage/config": "1.3.6",
|
|
35
|
-
"@backstage/core-app-api": "1.19.
|
|
36
|
-
"@backstage/core-plugin-api": "1.12.
|
|
37
|
-
"@backstage/frontend-app-api": "0.15.
|
|
38
|
-
"@backstage/frontend-plugin-api": "0.14.
|
|
39
|
-
"@backstage/plugin-app": "0.4.
|
|
40
|
-
"@backstage/plugin-app-react": "0.
|
|
41
|
-
"@backstage/plugin-permission-common": "0.9.6
|
|
42
|
-
"@backstage/plugin-permission-react": "0.4.
|
|
43
|
-
"@backstage/test-utils": "1.7.
|
|
35
|
+
"@backstage/core-app-api": "1.19.6-next.0",
|
|
36
|
+
"@backstage/core-plugin-api": "1.12.4-next.0",
|
|
37
|
+
"@backstage/frontend-app-api": "0.15.1-next.0",
|
|
38
|
+
"@backstage/frontend-plugin-api": "0.14.2-next.0",
|
|
39
|
+
"@backstage/plugin-app": "0.4.1-next.0",
|
|
40
|
+
"@backstage/plugin-app-react": "0.2.1-next.0",
|
|
41
|
+
"@backstage/plugin-permission-common": "0.9.6",
|
|
42
|
+
"@backstage/plugin-permission-react": "0.4.41-next.0",
|
|
43
|
+
"@backstage/test-utils": "1.7.16-next.0",
|
|
44
44
|
"@backstage/types": "1.2.2",
|
|
45
|
-
"@backstage/version-bridge": "1.0.12
|
|
45
|
+
"@backstage/version-bridge": "1.0.12",
|
|
46
46
|
"i18next": "^22.4.15",
|
|
47
47
|
"zen-observable": "^0.10.0",
|
|
48
48
|
"zod": "^3.25.76"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@backstage/cli": "0.35.
|
|
51
|
+
"@backstage/cli": "0.35.5-next.0",
|
|
52
52
|
"@testing-library/jest-dom": "^6.0.0",
|
|
53
53
|
"@types/jest": "*",
|
|
54
54
|
"@types/react": "^18.0.0",
|