@backstage/frontend-test-utils 0.4.6-next.1 → 0.5.0-next.2
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 +50 -0
- package/dist/apis/AlertApi/MockAlertApi.esm.js +64 -0
- package/dist/apis/AlertApi/MockAlertApi.esm.js.map +1 -0
- package/dist/apis/ConfigApi/MockConfigApi.esm.js +76 -0
- package/dist/apis/ConfigApi/MockConfigApi.esm.js.map +1 -0
- package/dist/apis/ErrorApi/MockErrorApi.esm.js +44 -0
- package/dist/apis/ErrorApi/MockErrorApi.esm.js.map +1 -0
- package/dist/apis/FeatureFlagsApi/MockFeatureFlagsApi.esm.js +55 -0
- package/dist/apis/FeatureFlagsApi/MockFeatureFlagsApi.esm.js.map +1 -0
- package/dist/apis/FetchApi/MockFetchApi.esm.js +56 -0
- package/dist/apis/FetchApi/MockFetchApi.esm.js.map +1 -0
- package/dist/apis/MockWithApiFactory.esm.js +28 -0
- package/dist/apis/MockWithApiFactory.esm.js.map +1 -0
- package/dist/apis/PermissionApi/MockPermissionApi.esm.js +13 -0
- package/dist/apis/PermissionApi/MockPermissionApi.esm.js.map +1 -0
- package/dist/apis/StorageApi/MockStorageApi.esm.js +98 -0
- package/dist/apis/StorageApi/MockStorageApi.esm.js.map +1 -0
- package/dist/apis/TestApiProvider.esm.js +31 -0
- package/dist/apis/TestApiProvider.esm.js.map +1 -0
- package/dist/apis/TranslationApi/MockTranslationApi.esm.js +68 -0
- package/dist/apis/TranslationApi/MockTranslationApi.esm.js.map +1 -0
- package/dist/apis/createApiMock.esm.js +25 -0
- package/dist/apis/createApiMock.esm.js.map +1 -0
- package/dist/apis/mockApis.esm.js +195 -0
- package/dist/apis/mockApis.esm.js.map +1 -0
- package/dist/app/createExtensionTester.esm.js +36 -2
- package/dist/app/createExtensionTester.esm.js.map +1 -1
- package/dist/app/renderInTestApp.esm.js +20 -4
- package/dist/app/renderInTestApp.esm.js.map +1 -1
- package/dist/app/renderTestApp.esm.js +45 -7
- package/dist/app/renderTestApp.esm.js.map +1 -1
- package/dist/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.esm.js +67 -0
- package/dist/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.esm.js.map +1 -0
- package/dist/frontend-plugin-api/src/translation/TranslationRef.esm.js +13 -0
- package/dist/frontend-plugin-api/src/translation/TranslationRef.esm.js.map +1 -0
- package/dist/index.d.ts +690 -51
- package/dist/index.esm.js +5 -3
- package/dist/index.esm.js.map +1 -1
- package/package.json +22 -9
- package/dist/utils/TestApiProvider.esm.js +0 -52
- package/dist/utils/TestApiProvider.esm.js.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { mockApis } from './apis/mockApis.esm.js';
|
|
2
|
+
export { createApiMock } from './apis/createApiMock.esm.js';
|
|
3
|
+
export { attachMockApiFactory } from './apis/MockWithApiFactory.esm.js';
|
|
4
|
+
export { TestApiProvider } from './apis/TestApiProvider.esm.js';
|
|
3
5
|
export { createExtensionTester } from './app/createExtensionTester.esm.js';
|
|
4
6
|
export { renderInTestApp } from './app/renderInTestApp.esm.js';
|
|
5
7
|
export { renderTestApp } from './app/renderTestApp.esm.js';
|
|
6
|
-
export {
|
|
8
|
+
export { registerMswTestHooks, withLogCollector } from '@backstage/test-utils';
|
|
7
9
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/frontend-test-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-next.2",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "web-library"
|
|
6
6
|
},
|
|
@@ -32,31 +32,44 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@backstage/config": "1.3.6",
|
|
35
|
-
"@backstage/
|
|
36
|
-
"@backstage/
|
|
37
|
-
"@backstage/
|
|
35
|
+
"@backstage/core-app-api": "1.19.5-next.1",
|
|
36
|
+
"@backstage/core-plugin-api": "1.12.3-next.1",
|
|
37
|
+
"@backstage/frontend-app-api": "0.15.0-next.2",
|
|
38
|
+
"@backstage/frontend-plugin-api": "0.14.0-next.2",
|
|
39
|
+
"@backstage/plugin-app": "0.4.0-next.2",
|
|
38
40
|
"@backstage/plugin-app-react": "0.1.1-next.0",
|
|
39
|
-
"@backstage/
|
|
41
|
+
"@backstage/plugin-permission-common": "0.9.6-next.0",
|
|
42
|
+
"@backstage/plugin-permission-react": "0.4.40-next.1",
|
|
43
|
+
"@backstage/test-utils": "1.7.15-next.2",
|
|
40
44
|
"@backstage/types": "1.2.2",
|
|
41
|
-
"@backstage/version-bridge": "1.0.
|
|
45
|
+
"@backstage/version-bridge": "1.0.12-next.0",
|
|
46
|
+
"i18next": "^22.4.15",
|
|
47
|
+
"zen-observable": "^0.10.0",
|
|
42
48
|
"zod": "^3.25.76"
|
|
43
49
|
},
|
|
44
50
|
"devDependencies": {
|
|
45
|
-
"@backstage/cli": "0.35.4-next.
|
|
51
|
+
"@backstage/cli": "0.35.4-next.2",
|
|
46
52
|
"@testing-library/jest-dom": "^6.0.0",
|
|
53
|
+
"@types/jest": "*",
|
|
47
54
|
"@types/react": "^18.0.0",
|
|
55
|
+
"@types/zen-observable": "^0.8.0",
|
|
56
|
+
"msw": "^2.0.0",
|
|
48
57
|
"react": "^18.0.2",
|
|
49
58
|
"react-dom": "^18.0.2",
|
|
50
|
-
"react-router-dom": "^6.
|
|
59
|
+
"react-router-dom": "^6.30.2"
|
|
51
60
|
},
|
|
52
61
|
"peerDependencies": {
|
|
53
62
|
"@testing-library/react": "^16.0.0",
|
|
63
|
+
"@types/jest": "*",
|
|
54
64
|
"@types/react": "^17.0.0 || ^18.0.0",
|
|
55
65
|
"react": "^17.0.0 || ^18.0.0",
|
|
56
66
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
57
|
-
"react-router-dom": "^6.
|
|
67
|
+
"react-router-dom": "^6.30.2"
|
|
58
68
|
},
|
|
59
69
|
"peerDependenciesMeta": {
|
|
70
|
+
"@types/jest": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
60
73
|
"@types/react": {
|
|
61
74
|
"optional": true
|
|
62
75
|
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { ApiProvider } from '../core-app-api/src/apis/system/ApiProvider.esm.js';
|
|
3
|
-
|
|
4
|
-
class TestApiRegistry {
|
|
5
|
-
constructor(apis) {
|
|
6
|
-
this.apis = apis;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Creates a new {@link TestApiRegistry} with a list of API implementation pairs.
|
|
10
|
-
*
|
|
11
|
-
* Similar to the {@link TestApiProvider}, there is no need to provide a full
|
|
12
|
-
* implementation of each API, it's enough to implement the methods that are tested.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { identityApiRef } from '@backstage/frontend-plugin-api';
|
|
17
|
-
* import { mockApis } from '@backstage/frontend-test-utils';
|
|
18
|
-
*
|
|
19
|
-
* const apis = TestApiRegistry.from(
|
|
20
|
-
* [identityApiRef, mockApis.identity({ userEntityRef: 'user:default/guest' })],
|
|
21
|
-
* );
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
* @param apis - A list of pairs mapping an ApiRef to its respective implementation.
|
|
26
|
-
*/
|
|
27
|
-
static from(...apis) {
|
|
28
|
-
return new TestApiRegistry(
|
|
29
|
-
new Map(apis.map(([api, impl]) => [api.id, impl]))
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Returns an implementation of the API.
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
get(api) {
|
|
38
|
-
return this.apis.get(api.id);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const TestApiProvider = (props) => {
|
|
42
|
-
return /* @__PURE__ */ jsx(
|
|
43
|
-
ApiProvider,
|
|
44
|
-
{
|
|
45
|
-
apis: TestApiRegistry.from(...props.apis),
|
|
46
|
-
children: props.children
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export { TestApiProvider, TestApiRegistry };
|
|
52
|
-
//# sourceMappingURL=TestApiProvider.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TestApiProvider.esm.js","sources":["../../src/utils/TestApiProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { ReactNode } from 'react';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { ApiProvider } from '../../../core-app-api/src/apis/system';\nimport { ApiHolder, ApiRef } from '@backstage/frontend-plugin-api';\n\n/**\n * Helper type for representing an API reference paired with a partial implementation.\n * @public\n */\nexport type TestApiProviderPropsApiPair<TApi> = TApi extends infer TImpl\n ? readonly [ApiRef<TApi>, Partial<TImpl>]\n : never;\n\n/**\n * Helper type for representing an array of API reference pairs.\n * @public\n */\nexport type TestApiProviderPropsApiPairs<TApiPairs> = {\n [TIndex in keyof TApiPairs]: TestApiProviderPropsApiPair<TApiPairs[TIndex]>;\n};\n\n/**\n * Shorter alias for TestApiProviderPropsApiPairs for use in function signatures.\n * @public\n */\nexport type TestApiPairs<TApiPairs> = TestApiProviderPropsApiPairs<TApiPairs>;\n\n/**\n * Properties for the {@link TestApiProvider} component.\n *\n * @public\n */\nexport type TestApiProviderProps<TApiPairs extends any[]> = {\n apis: readonly [...TestApiProviderPropsApiPairs<TApiPairs>];\n children: ReactNode;\n};\n\n/**\n * The `TestApiRegistry` is an {@link @backstage/frontend-plugin-api#ApiHolder} implementation\n * that is particularly well suited for development and test environments such as\n * unit tests, storybooks, and isolated plugin development setups.\n *\n * @remarks\n *\n * For most test scenarios, prefer using the `apis` option in `renderInTestApp` or\n * `createExtensionTester` instead of creating a registry directly.\n *\n * @public\n */\nexport class TestApiRegistry implements ApiHolder {\n /**\n * Creates a new {@link TestApiRegistry} with a list of API implementation pairs.\n *\n * Similar to the {@link TestApiProvider}, there is no need to provide a full\n * implementation of each API, it's enough to implement the methods that are tested.\n *\n * @example\n * ```ts\n * import { identityApiRef } from '@backstage/frontend-plugin-api';\n * import { mockApis } from '@backstage/frontend-test-utils';\n *\n * const apis = TestApiRegistry.from(\n * [identityApiRef, mockApis.identity({ userEntityRef: 'user:default/guest' })],\n * );\n * ```\n *\n * @public\n * @param apis - A list of pairs mapping an ApiRef to its respective implementation.\n */\n static from<TApiPairs extends any[]>(\n ...apis: readonly [...TestApiProviderPropsApiPairs<TApiPairs>]\n ) {\n return new TestApiRegistry(\n new Map(apis.map(([api, impl]) => [api.id, impl])),\n );\n }\n\n private constructor(private readonly apis: Map<string, unknown>) {}\n\n /**\n * Returns an implementation of the API.\n *\n * @public\n */\n get<T>(api: ApiRef<T>): T | undefined {\n return this.apis.get(api.id) as T | undefined;\n }\n}\n\n/**\n * The `TestApiProvider` is a Utility API context provider for standalone rendering\n * scenarios where you're not using `renderInTestApp` or other test utilities.\n *\n * It lets you provide any number of API implementations, without necessarily\n * having to fully implement each of the APIs.\n *\n * @remarks\n *\n * For most test scenarios, prefer using the `apis` option in `renderInTestApp` or\n * `createExtensionTester` instead of wrapping components with `TestApiProvider`.\n *\n * @example\n * ```tsx\n * import { render } from '\\@testing-library/react';\n * import { identityApiRef } from '\\@backstage/frontend-plugin-api';\n * import { TestApiProvider, mockApis } from '\\@backstage/frontend-test-utils';\n *\n * render(\n * <TestApiProvider\n * apis={[[identityApiRef, mockApis.identity({ userEntityRef: 'user:default/guest' })]]}\n * >\n * <MyComponent />\n * </TestApiProvider>\n * );\n * ```\n *\n * @public\n */\nexport const TestApiProvider = <T extends any[]>(\n props: TestApiProviderProps<T>,\n) => {\n return (\n <ApiProvider\n apis={TestApiRegistry.from(...props.apis)}\n children={props.children}\n />\n );\n};\n"],"names":[],"mappings":";;;AAiEO,MAAM,eAAA,CAAqC;AAAA,EA4BxC,YAA6B,IAAA,EAA4B;AAA5B,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EARlE,OAAO,QACF,IAAA,EACH;AACA,IAAA,OAAO,IAAI,eAAA;AAAA,MACT,IAAI,GAAA,CAAI,IAAA,CAAK,GAAA,CAAI,CAAC,CAAC,GAAA,EAAK,IAAI,CAAA,KAAM,CAAC,GAAA,CAAI,EAAA,EAAI,IAAI,CAAC,CAAC;AAAA,KACnD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAO,GAAA,EAA+B;AACpC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAI,GAAA,CAAI,EAAE,CAAA;AAAA,EAC7B;AACF;AA+BO,MAAM,eAAA,GAAkB,CAC7B,KAAA,KACG;AACH,EAAA,uBACE,GAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAM,eAAA,CAAgB,IAAA,CAAK,GAAG,MAAM,IAAI,CAAA;AAAA,MACxC,UAAU,KAAA,CAAM;AAAA;AAAA,GAClB;AAEJ;;;;"}
|