@backstage/frontend-test-utils 0.2.1-next.2 → 0.2.1

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 CHANGED
@@ -1,5 +1,32 @@
1
1
  # @backstage/frontend-test-utils
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 666d5b1: Disable the built-in `SignInPage` in `createExtensionTester` in order to not mess with existing tests
8
+ - e969dc7: Move `@types/react` to a peer dependency.
9
+ - 873e424: Internal refactor of usage of opaque types.
10
+ - 0801db6: Added an `ApiMock`, analogous to `ServiceMock` from the backend test utils.
11
+ - 9cc7dd6: Added a `mockApis` export, which will replace the `MockX` API implementation classes and their related types. This is analogous with the backend's `mockServices`.
12
+
13
+ **DEPRECATED** several old helpers:
14
+
15
+ - Deprecated `MockAnalyticsApi`, please use `mockApis.analytics` instead.
16
+ - Deprecated `MockConfigApi`, please use `mockApis.config` instead.
17
+ - Deprecated `MockPermissionApi`, please use `mockApis.permission` instead.
18
+ - Deprecated `MockStorageApi`, please use `mockApis.storage` instead.
19
+ - Deprecated `MockTranslationApi`, please use `mockApis.translation` instead.
20
+
21
+ - Updated dependencies
22
+ - @backstage/frontend-plugin-api@0.9.0
23
+ - @backstage/frontend-app-api@0.10.0
24
+ - @backstage/version-bridge@1.0.10
25
+ - @backstage/test-utils@1.7.0
26
+ - @backstage/plugin-app@0.1.1
27
+ - @backstage/config@1.2.0
28
+ - @backstage/types@1.1.1
29
+
3
30
  ## 0.2.1-next.2
4
31
 
5
32
  ### Patch Changes
@@ -16,6 +16,9 @@ const NavItem = (props) => {
16
16
  };
17
17
  const appPluginOverride = appPlugin.withOverrides({
18
18
  extensions: [
19
+ appPlugin.getExtension("sign-in-page:app").override({
20
+ disabled: true
21
+ }),
19
22
  appPlugin.getExtension("app/nav").override({
20
23
  output: [coreExtensionData.reactElement],
21
24
  factory(_originalFactory, { inputs }) {
@@ -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 React from 'react';\nimport { Link, MemoryRouter } from 'react-router-dom';\nimport {\n createSpecializedApp,\n FrontendFeature,\n} 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 RouterBlueprint,\n NavItemBlueprint,\n createFrontendPlugin,\n} from '@backstage/frontend-plugin-api';\nimport appPlugin from '@backstage/plugin-app';\n\n/**\n * Options to customize the behavior of the test app.\n * @public\n */\nexport type TestAppOptions = {\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 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\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('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(\n element: JSX.Element,\n options?: TestAppOptions,\n): RenderResult {\n const extensions: Array<ExtensionDefinition> = [\n createExtension({\n attachTo: { id: 'app/routes', input: 'routes' },\n output: [coreExtensionData.reactElement, coreExtensionData.routePath],\n factory: () => {\n return [\n coreExtensionData.reactElement(element),\n coreExtensionData.routePath('/'),\n ];\n },\n }),\n RouterBlueprint.make({\n params: {\n Component: ({ children }) => <MemoryRouter>{children}</MemoryRouter>,\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(<React.Fragment />),\n coreExtensionData.routePath(path),\n coreExtensionData.routeRef(routeRef),\n ],\n }),\n );\n }\n }\n\n if (options?.extensions) {\n extensions.push(...options.extensions);\n }\n\n const features: FrontendFeature[] = [\n createFrontendPlugin({\n id: '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 { context: 'render-config', data: options?.config ?? {} },\n ]),\n });\n\n return render(app.createRoot());\n}\n"],"names":[],"mappings":";;;;;;;;AA6EA,MAAM,OAAA,GAAU,CAAC,KAIX,KAAA;AACJ,EAAA,MAAM,EAAE,QAAA,EAAU,KAAO,EAAA,IAAA,EAAM,MAAS,GAAA,KAAA,CAAA;AACxC,EAAM,MAAA,IAAA,GAAO,YAAY,QAAQ,CAAA,CAAA;AACjC,EAAA,IAAI,CAAC,IAAM,EAAA;AACT,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACA,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,EAAI,EAAA,IAAA,EACR,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,IAAA,CAAA,EAAE,GAAE,EAAA,KACZ,CACF,CAAA,CAAA;AAEJ,CAAA,CAAA;AAEA,MAAM,iBAAA,GAAoB,UAAU,aAAc,CAAA;AAAA,EAChD,UAAY,EAAA;AAAA,IACV,SAAU,CAAA,YAAA,CAAa,SAAS,CAAA,CAAE,QAAS,CAAA;AAAA,MACzC,MAAA,EAAQ,CAAC,iBAAA,CAAkB,YAAY,CAAA;AAAA,MACvC,OAAQ,CAAA,gBAAA,EAAkB,EAAE,MAAA,EAAU,EAAA;AACpC,QAAO,OAAA;AAAA,UACL,iBAAkB,CAAA,YAAA;AAAA,4BAChB,KAAA,CAAA,aAAA,CAAC,6BACE,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EACE,OAAO,KAAM,CAAA,GAAA,CAAI,CAAC,IAAA,EAAM,KAAU,KAAA;AACjC,cAAA,MAAM,EAAE,IAAA,EAAM,KAAO,EAAA,QAAA,KAAa,IAAK,CAAA,GAAA;AAAA,gBACrC,iBAAiB,QAAS,CAAA,MAAA;AAAA,eAC5B,CA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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 React from 'react';\nimport { Link, MemoryRouter } from 'react-router-dom';\nimport {\n createSpecializedApp,\n FrontendFeature,\n} 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 RouterBlueprint,\n NavItemBlueprint,\n createFrontendPlugin,\n} from '@backstage/frontend-plugin-api';\nimport appPlugin from '@backstage/plugin-app';\n\n/**\n * Options to customize the behavior of the test app.\n * @public\n */\nexport type TestAppOptions = {\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 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\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/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(\n element: JSX.Element,\n options?: TestAppOptions,\n): RenderResult {\n const extensions: Array<ExtensionDefinition> = [\n createExtension({\n attachTo: { id: 'app/routes', input: 'routes' },\n output: [coreExtensionData.reactElement, coreExtensionData.routePath],\n factory: () => {\n return [\n coreExtensionData.reactElement(element),\n coreExtensionData.routePath('/'),\n ];\n },\n }),\n RouterBlueprint.make({\n params: {\n Component: ({ children }) => <MemoryRouter>{children}</MemoryRouter>,\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(<React.Fragment />),\n coreExtensionData.routePath(path),\n coreExtensionData.routeRef(routeRef),\n ],\n }),\n );\n }\n }\n\n if (options?.extensions) {\n extensions.push(...options.extensions);\n }\n\n const features: FrontendFeature[] = [\n createFrontendPlugin({\n id: '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 { context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// <reference types="jest" />
2
1
  /// <reference types="react" />
3
- export { ErrorWithContext, MockConfigApi, MockErrorApi, MockErrorApiOptions, MockFetchApi, MockFetchApiOptions, MockPermissionApi, MockStorageApi, MockStorageBucket, TestApiProvider, TestApiProviderProps, TestApiRegistry, registerMswTestHooks, withLogCollector } from '@backstage/test-utils';
2
+ export { ApiMock, ErrorWithContext, MockConfigApi, MockErrorApi, MockErrorApiOptions, MockFetchApi, MockFetchApiOptions, MockPermissionApi, MockStorageApi, MockStorageBucket, TestApiProvider, TestApiProviderProps, TestApiRegistry, mockApis, registerMswTestHooks, withLogCollector } from '@backstage/test-utils';
4
3
  import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
5
- import { ApiFactory, AnalyticsApi, AnalyticsEvent, AnyExtensionDataRef, AppNode, ExtensionDataRef, ExtensionDefinitionParameters, ExtensionDefinition, RouteRef } from '@backstage/frontend-plugin-api';
4
+ import { AnalyticsApi, AnalyticsEvent, AnyExtensionDataRef, AppNode, ExtensionDataRef, ExtensionDefinitionParameters, ExtensionDefinition, RouteRef } from '@backstage/frontend-plugin-api';
6
5
  import { FrontendFeature } from '@backstage/frontend-app-api';
7
6
  import { RenderResult } from '@testing-library/react';
8
7
  import { JsonObject } from '@backstage/types';
@@ -17,19 +16,6 @@ declare function setupRequestMockHandlers(worker: {
17
16
  resetHandlers: () => void;
18
17
  }): void;
19
18
 
20
- /**
21
- * Represents a mocked version of an API, where you automatically have access to
22
- * the mocked versions of all of its methods along with a factory that returns
23
- * that same mock.
24
- *
25
- * @public
26
- */
27
- type ApiMock<TApi> = {
28
- factory: ApiFactory<TApi, TApi, {}>;
29
- } & {
30
- [Key in keyof TApi]: TApi[Key] extends (...args: infer Args) => infer Return ? TApi[Key] & jest.MockInstance<Return, Args> : TApi[Key];
31
- };
32
-
33
19
  /**
34
20
  * Mock implementation of {@link frontend-plugin-api#AnalyticsApi} with helpers to ensure that events are sent correctly.
35
21
  * Use getEvents in tests to verify captured events.
@@ -108,4 +94,4 @@ type TestAppOptions = {
108
94
  */
109
95
  declare function renderInTestApp(element: JSX.Element, options?: TestAppOptions): RenderResult;
110
96
 
111
- export { type ApiMock, ExtensionQuery, ExtensionTester, MockAnalyticsApi, type TestAppOptions, createExtensionTester, renderInTestApp, setupRequestMockHandlers };
97
+ export { ExtensionQuery, ExtensionTester, MockAnalyticsApi, type TestAppOptions, createExtensionTester, renderInTestApp, setupRequestMockHandlers };
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { setupRequestMockHandlers } from './deprecated.esm.js';
2
- export { MockConfigApi, MockErrorApi, MockFetchApi, MockPermissionApi, MockStorageApi, TestApiProvider, TestApiRegistry, registerMswTestHooks, withLogCollector } from '@backstage/test-utils';
2
+ export { MockConfigApi, MockErrorApi, MockFetchApi, MockPermissionApi, MockStorageApi, TestApiProvider, TestApiRegistry, mockApis, registerMswTestHooks, withLogCollector } from '@backstage/test-utils';
3
3
  export { MockAnalyticsApi } from './apis/AnalyticsApi/MockAnalyticsApi.esm.js';
4
4
  export { createExtensionTester } from './app/createExtensionTester.esm.js';
5
5
  export { renderInTestApp } from './app/renderInTestApp.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/frontend-test-utils",
3
- "version": "0.2.1-next.2",
3
+ "version": "0.2.1",
4
4
  "backstage": {
5
5
  "role": "web-library"
6
6
  },
@@ -31,17 +31,17 @@
31
31
  "test": "backstage-cli package test"
32
32
  },
33
33
  "dependencies": {
34
- "@backstage/config": "1.2.0",
35
- "@backstage/frontend-app-api": "0.10.0-next.2",
36
- "@backstage/frontend-plugin-api": "0.9.0-next.2",
37
- "@backstage/plugin-app": "0.1.1-next.2",
38
- "@backstage/test-utils": "1.6.1-next.2",
39
- "@backstage/types": "1.1.1",
40
- "@backstage/version-bridge": "1.0.10-next.0",
34
+ "@backstage/config": "^1.2.0",
35
+ "@backstage/frontend-app-api": "^0.10.0",
36
+ "@backstage/frontend-plugin-api": "^0.9.0",
37
+ "@backstage/plugin-app": "^0.1.1",
38
+ "@backstage/test-utils": "^1.7.0",
39
+ "@backstage/types": "^1.1.1",
40
+ "@backstage/version-bridge": "^1.0.10",
41
41
  "zod": "^3.22.4"
42
42
  },
43
43
  "devDependencies": {
44
- "@backstage/cli": "0.28.0-next.2",
44
+ "@backstage/cli": "^0.28.0",
45
45
  "@testing-library/jest-dom": "^6.0.0",
46
46
  "@types/react": "^18.0.0",
47
47
  "react": "^18.0.2",
@@ -50,7 +50,6 @@
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@testing-library/react": "^16.0.0",
53
- "@types/jest": "*",
54
53
  "@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
55
54
  "react": "^16.13.1 || ^17.0.0 || ^18.0.0",
56
55
  "react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",