@backstage/frontend-test-utils 0.1.6 → 0.1.7-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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @backstage/frontend-test-utils
2
2
 
3
+ ## 0.1.7-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/frontend-app-api@0.6.5-next.0
9
+ - @backstage/frontend-plugin-api@0.6.5-next.0
10
+ - @backstage/test-utils@1.5.5-next.0
11
+ - @backstage/types@1.1.1
12
+
3
13
  ## 0.1.6
4
14
 
5
15
  ### Patch Changes
@@ -0,0 +1,27 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, key + "" , value);
5
+ return value;
6
+ };
7
+ class MockAnalyticsApi {
8
+ constructor() {
9
+ __publicField(this, "events", []);
10
+ }
11
+ captureEvent(event) {
12
+ const { action, subject, value, attributes, context } = event;
13
+ this.events.push({
14
+ action,
15
+ subject,
16
+ context,
17
+ ...value !== void 0 ? { value } : {},
18
+ ...attributes !== void 0 ? { attributes } : {}
19
+ });
20
+ }
21
+ getEvents() {
22
+ return this.events;
23
+ }
24
+ }
25
+
26
+ export { MockAnalyticsApi };
27
+ //# sourceMappingURL=MockAnalyticsApi.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockAnalyticsApi.esm.js","sources":["../../../src/apis/AnalyticsApi/MockAnalyticsApi.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 { AnalyticsApi, AnalyticsEvent } from '@backstage/frontend-plugin-api';\n\n/**\n * Mock implementation of {@link frontend-plugin-api#AnalyticsApi} with helpers to ensure that events are sent correctly.\n * Use getEvents in tests to verify captured events.\n *\n * @public\n */\nexport class MockAnalyticsApi implements AnalyticsApi {\n private events: AnalyticsEvent[] = [];\n\n captureEvent(event: AnalyticsEvent) {\n const { action, subject, value, attributes, context } = event;\n\n this.events.push({\n action,\n subject,\n context,\n ...(value !== undefined ? { value } : {}),\n ...(attributes !== undefined ? { attributes } : {}),\n });\n }\n\n getEvents(): AnalyticsEvent[] {\n return this.events;\n }\n}\n"],"names":[],"mappings":";;;;;;AAwBO,MAAM,gBAAyC,CAAA;AAAA,EAA/C,WAAA,GAAA;AACL,IAAA,aAAA,CAAA,IAAA,EAAQ,UAA2B,EAAC,CAAA,CAAA;AAAA,GAAA;AAAA,EAEpC,aAAa,KAAuB,EAAA;AAClC,IAAA,MAAM,EAAE,MAAQ,EAAA,OAAA,EAAS,KAAO,EAAA,UAAA,EAAY,SAAY,GAAA,KAAA,CAAA;AAExD,IAAA,IAAA,CAAK,OAAO,IAAK,CAAA;AAAA,MACf,MAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,GAAI,KAAU,KAAA,KAAA,CAAA,GAAY,EAAE,KAAA,KAAU,EAAC;AAAA,MACvC,GAAI,UAAe,KAAA,KAAA,CAAA,GAAY,EAAE,UAAA,KAAe,EAAC;AAAA,KAClD,CAAA,CAAA;AAAA,GACH;AAAA,EAEA,SAA8B,GAAA;AAC5B,IAAA,OAAO,IAAK,CAAA,MAAA,CAAA;AAAA,GACd;AACF;;;;"}
@@ -0,0 +1,146 @@
1
+ import React from 'react';
2
+ import { Link, MemoryRouter } from 'react-router-dom';
3
+ import { render } from '@testing-library/react';
4
+ import { createSpecializedApp } from '@backstage/frontend-app-api';
5
+ import { createExtension, createExtensionInput, createNavItemExtension, coreExtensionData, useRouteRef, createExtensionOverrides, createRouterExtension } from '@backstage/frontend-plugin-api';
6
+ import { MockConfigApi } from '@backstage/test-utils';
7
+ import { resolveExtensionDefinition } from '../frontend-plugin-api/src/wiring/resolveExtensionDefinition.esm.js';
8
+ import { toInternalExtensionDefinition } from '../frontend-plugin-api/src/wiring/createExtension.esm.js';
9
+
10
+ var __accessCheck = (obj, member, msg) => {
11
+ if (!member.has(obj))
12
+ throw TypeError("Cannot " + msg);
13
+ };
14
+ var __privateGet = (obj, member, getter) => {
15
+ __accessCheck(obj, member, "read from private field");
16
+ return member.get(obj);
17
+ };
18
+ var __privateAdd = (obj, member, value) => {
19
+ if (member.has(obj))
20
+ throw TypeError("Cannot add the same private member more than once");
21
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
22
+ };
23
+ var _extensions;
24
+ const NavItem = (props) => {
25
+ const { routeRef, title, icon: Icon } = props;
26
+ const to = useRouteRef(routeRef)();
27
+ return /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement(Link, { to }, /* @__PURE__ */ React.createElement(Icon, null), " ", title));
28
+ };
29
+ const TestAppNavExtension = createExtension({
30
+ namespace: "app",
31
+ name: "nav",
32
+ attachTo: { id: "app/layout", input: "nav" },
33
+ inputs: {
34
+ items: createExtensionInput({
35
+ target: createNavItemExtension.targetDataRef
36
+ })
37
+ },
38
+ output: {
39
+ element: coreExtensionData.reactElement
40
+ },
41
+ factory({ inputs }) {
42
+ return {
43
+ element: /* @__PURE__ */ React.createElement("nav", null, /* @__PURE__ */ React.createElement("ul", null, inputs.items.map((item, index) => /* @__PURE__ */ React.createElement(
44
+ NavItem,
45
+ {
46
+ key: index,
47
+ icon: item.output.target.icon,
48
+ title: item.output.target.title,
49
+ routeRef: item.output.target.routeRef
50
+ }
51
+ ))))
52
+ };
53
+ }
54
+ });
55
+ const _ExtensionTester = class _ExtensionTester {
56
+ constructor() {
57
+ __privateAdd(this, _extensions, new Array());
58
+ }
59
+ /** @internal */
60
+ static forSubject(subject, options) {
61
+ const tester = new _ExtensionTester();
62
+ const { output, factory, ...rest } = toInternalExtensionDefinition(subject);
63
+ const extension = createExtension({
64
+ ...rest,
65
+ attachTo: { id: "app/routes", input: "routes" },
66
+ output: {
67
+ ...output,
68
+ path: coreExtensionData.routePath
69
+ },
70
+ factory: (params) => ({
71
+ ...factory(params),
72
+ path: "/"
73
+ })
74
+ });
75
+ tester.add(extension, options);
76
+ return tester;
77
+ }
78
+ add(extension, options) {
79
+ const { name, namespace } = extension;
80
+ const definition = {
81
+ ...extension,
82
+ // setting name "test" as fallback
83
+ name: !namespace && !name ? "test" : name
84
+ };
85
+ const { id } = resolveExtensionDefinition(definition);
86
+ __privateGet(this, _extensions).push({
87
+ id,
88
+ definition,
89
+ config: options == null ? void 0 : options.config
90
+ });
91
+ return this;
92
+ }
93
+ render(options) {
94
+ const { config = {} } = options != null ? options : {};
95
+ const [subject, ...rest] = __privateGet(this, _extensions);
96
+ if (!subject) {
97
+ throw new Error(
98
+ "No subject found. At least one extension should be added to the tester."
99
+ );
100
+ }
101
+ const extensionsConfig = [
102
+ ...rest.map((extension) => ({
103
+ [extension.id]: {
104
+ config: extension.config
105
+ }
106
+ })),
107
+ {
108
+ [subject.id]: {
109
+ config: subject.config,
110
+ disabled: false
111
+ }
112
+ }
113
+ ];
114
+ const finalConfig = {
115
+ ...config,
116
+ app: {
117
+ ...typeof config.app === "object" ? config.app : void 0,
118
+ extensions: extensionsConfig
119
+ }
120
+ };
121
+ const app = createSpecializedApp({
122
+ features: [
123
+ createExtensionOverrides({
124
+ extensions: [
125
+ ...__privateGet(this, _extensions).map((extension) => extension.definition),
126
+ TestAppNavExtension,
127
+ createRouterExtension({
128
+ namespace: "test",
129
+ Component: ({ children }) => /* @__PURE__ */ React.createElement(MemoryRouter, null, children)
130
+ })
131
+ ]
132
+ })
133
+ ],
134
+ config: new MockConfigApi(finalConfig)
135
+ });
136
+ return render(app.createRoot());
137
+ }
138
+ };
139
+ _extensions = new WeakMap();
140
+ let ExtensionTester = _ExtensionTester;
141
+ function createExtensionTester(subject, options) {
142
+ return ExtensionTester.forSubject(subject, options);
143
+ }
144
+
145
+ export { ExtensionTester, createExtensionTester };
146
+ //# sourceMappingURL=createExtensionTester.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createExtensionTester.esm.js","sources":["../../src/app/createExtensionTester.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 { MemoryRouter, Link } from 'react-router-dom';\nimport { RenderResult, render } from '@testing-library/react';\nimport { createSpecializedApp } from '@backstage/frontend-app-api';\nimport {\n ExtensionDefinition,\n IconComponent,\n RouteRef,\n coreExtensionData,\n createExtension,\n createExtensionInput,\n createExtensionOverrides,\n createNavItemExtension,\n createRouterExtension,\n useRouteRef,\n} from '@backstage/frontend-plugin-api';\nimport { MockConfigApi } from '@backstage/test-utils';\nimport { JsonArray, JsonObject, JsonValue } from '@backstage/types';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { resolveExtensionDefinition } from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExtensionDefinition } from '../../../frontend-plugin-api/src/wiring/createExtension';\n\nconst NavItem = (props: {\n routeRef: RouteRef<undefined>;\n title: string;\n icon: IconComponent;\n}) => {\n const { routeRef, title, icon: Icon } = props;\n const to = useRouteRef(routeRef)();\n return (\n <li>\n <Link to={to}>\n <Icon /> {title}\n </Link>\n </li>\n );\n};\n\nconst TestAppNavExtension = createExtension({\n namespace: 'app',\n name: 'nav',\n attachTo: { id: 'app/layout', input: 'nav' },\n inputs: {\n items: createExtensionInput({\n target: createNavItemExtension.targetDataRef,\n }),\n },\n output: {\n element: coreExtensionData.reactElement,\n },\n factory({ inputs }) {\n return {\n element: (\n <nav>\n <ul>\n {inputs.items.map((item, index) => (\n <NavItem\n key={index}\n icon={item.output.target.icon}\n title={item.output.target.title}\n routeRef={item.output.target.routeRef}\n />\n ))}\n </ul>\n </nav>\n ),\n };\n },\n});\n\n/** @public */\nexport class ExtensionTester {\n /** @internal */\n static forSubject<TConfig>(\n subject: ExtensionDefinition<TConfig>,\n options?: { config?: TConfig },\n ): ExtensionTester {\n const tester = new ExtensionTester();\n const { output, factory, ...rest } = toInternalExtensionDefinition(subject);\n // attaching to app/routes to render as index route\n const extension = createExtension({\n ...rest,\n attachTo: { id: 'app/routes', input: 'routes' },\n output: {\n ...output,\n path: coreExtensionData.routePath,\n },\n factory: params => ({\n ...factory(params),\n path: '/',\n }),\n });\n tester.add(extension, options);\n return tester;\n }\n\n readonly #extensions = new Array<{\n id: string;\n definition: ExtensionDefinition<any>;\n config?: JsonValue;\n }>();\n\n add<TConfig>(\n extension: ExtensionDefinition<TConfig>,\n options?: { config?: TConfig },\n ): ExtensionTester {\n const { name, namespace } = extension;\n\n const definition = {\n ...extension,\n // setting name \"test\" as fallback\n name: !namespace && !name ? 'test' : name,\n };\n\n const { id } = resolveExtensionDefinition(definition);\n\n this.#extensions.push({\n id,\n definition,\n config: options?.config as JsonValue,\n });\n\n return this;\n }\n\n render(options?: { config?: JsonObject }): RenderResult {\n const { config = {} } = options ?? {};\n\n const [subject, ...rest] = this.#extensions;\n if (!subject) {\n throw new Error(\n 'No subject found. At least one extension should be added to the tester.',\n );\n }\n\n const extensionsConfig: JsonArray = [\n ...rest.map(extension => ({\n [extension.id]: {\n config: extension.config,\n },\n })),\n {\n [subject.id]: {\n config: subject.config,\n disabled: false,\n },\n },\n ];\n\n const finalConfig = {\n ...config,\n app: {\n ...(typeof config.app === 'object' ? config.app : undefined),\n extensions: extensionsConfig,\n },\n };\n\n const app = createSpecializedApp({\n features: [\n createExtensionOverrides({\n extensions: [\n ...this.#extensions.map(extension => extension.definition),\n TestAppNavExtension,\n createRouterExtension({\n namespace: 'test',\n Component: ({ children }) => (\n <MemoryRouter>{children}</MemoryRouter>\n ),\n }),\n ],\n }),\n ],\n config: new MockConfigApi(finalConfig),\n });\n\n return render(app.createRoot());\n }\n}\n\n/** @public */\nexport function createExtensionTester<TConfig>(\n subject: ExtensionDefinition<TConfig>,\n options?: { config?: TConfig },\n): ExtensionTester {\n return ExtensionTester.forSubject(subject, options);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,WAAA,CAAA;AAuCA,MAAM,OAAA,GAAU,CAAC,KAIX,KAAA;AACJ,EAAA,MAAM,EAAE,QAAA,EAAU,KAAO,EAAA,IAAA,EAAM,MAAS,GAAA,KAAA,CAAA;AACxC,EAAM,MAAA,EAAA,GAAK,WAAY,CAAA,QAAQ,CAAE,EAAA,CAAA;AACjC,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,IACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,EAAA,EAAA,sCACH,IAAK,EAAA,IAAA,CAAA,EAAE,GAAE,EAAA,KACZ,CACF,CAAA,CAAA;AAEJ,CAAA,CAAA;AAEA,MAAM,sBAAsB,eAAgB,CAAA;AAAA,EAC1C,SAAW,EAAA,KAAA;AAAA,EACX,IAAM,EAAA,KAAA;AAAA,EACN,QAAU,EAAA,EAAE,EAAI,EAAA,YAAA,EAAc,OAAO,KAAM,EAAA;AAAA,EAC3C,MAAQ,EAAA;AAAA,IACN,OAAO,oBAAqB,CAAA;AAAA,MAC1B,QAAQ,sBAAuB,CAAA,aAAA;AAAA,KAChC,CAAA;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AAN,GAAA,iBAAA;AA6GS,SAAA,qBAAA,CACd,SACA,OACiB,EAAA;AACjB,EAAO,OAAA,eAAA,CAAgB,UAAW,CAAA,OAAA,EAAS,OAAO,CAAA,CAAA;AACpD;;;;"}
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { createExtension, coreExtensionData } from '@backstage/frontend-plugin-api';
3
+ import { createExtensionTester } from './createExtensionTester.esm.js';
4
+
5
+ function renderInTestApp(element, options) {
6
+ const extension = createExtension({
7
+ namespace: "test",
8
+ attachTo: { id: "app", input: "root" },
9
+ output: {
10
+ element: coreExtensionData.reactElement
11
+ },
12
+ factory: () => ({ element })
13
+ });
14
+ const tester = createExtensionTester(extension);
15
+ if (options == null ? void 0 : options.mountedRoutes) {
16
+ for (const [path, routeRef] of Object.entries(options.mountedRoutes)) {
17
+ tester.add(
18
+ createExtension({
19
+ kind: "test-route",
20
+ name: path,
21
+ attachTo: { id: "app/root", input: "elements" },
22
+ output: {
23
+ element: coreExtensionData.reactElement,
24
+ path: coreExtensionData.routePath,
25
+ routeRef: coreExtensionData.routeRef
26
+ },
27
+ factory() {
28
+ return { element: /* @__PURE__ */ React.createElement(React.Fragment, null), path, routeRef };
29
+ }
30
+ })
31
+ );
32
+ }
33
+ }
34
+ return tester.render();
35
+ }
36
+
37
+ export { renderInTestApp };
38
+ //# sourceMappingURL=renderInTestApp.esm.js.map
@@ -0,0 +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 {\n RouteRef,\n coreExtensionData,\n createExtension,\n} from '@backstage/frontend-plugin-api';\nimport { createExtensionTester } from './createExtensionTester';\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/**\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) {\n const extension = createExtension({\n namespace: 'test',\n attachTo: { id: 'app', input: 'root' },\n output: {\n element: coreExtensionData.reactElement,\n },\n factory: () => ({ element }),\n });\n const tester = createExtensionTester(extension);\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 tester.add(\n createExtension({\n kind: 'test-route',\n name: path,\n attachTo: { id: 'app/root', input: 'elements' },\n output: {\n element: coreExtensionData.reactElement,\n path: coreExtensionData.routePath,\n routeRef: coreExtensionData.routeRef,\n },\n factory() {\n return { element: <React.Fragment />, path, routeRef };\n },\n }),\n );\n }\n }\n return tester.render();\n}\n"],"names":[],"mappings":";;;;AAoDgB,SAAA,eAAA,CACd,SACA,OACA,EAAA;AACA,EAAA,MAAM,YAAY,eAAgB,CAAA;AAAA,IAChC,SAAW,EAAA,MAAA;AAAA,IACX,QAAU,EAAA,EAAE,EAAI,EAAA,KAAA,EAAO,OAAO,MAAO,EAAA;AAAA,IACrC,MAAQ,EAAA;AAAA,MACN,SAAS,iBAAkB,CAAA,YAAA;AAAA,KAC7B;AAAA,IACA,OAAA,EAAS,OAAO,EAAE,OAAQ,EAAA,CAAA;AAAA,GAC3B,CAAA,CAAA;AACD,EAAM,MAAA,MAAA,GAAS,sBAAsB,SAAS,CAAA,CAAA;AAE9C,EAAA,IAAI,mCAAS,aAAe,EAAA;AAC1B,IAAW,KAAA,MAAA,CAAC,MAAM,QAAQ,CAAA,IAAK,OAAO,OAAQ,CAAA,OAAA,CAAQ,aAAa,CAAG,EAAA;AAEpE,MAAO,MAAA,CAAA,GAAA;AAAA,QACL,eAAgB,CAAA;AAAA,UACd,IAAM,EAAA,YAAA;AAAA,UACN,IAAM,EAAA,IAAA;AAAA,UACN,QAAU,EAAA,EAAE,EAAI,EAAA,UAAA,EAAY,OAAO,UAAW,EAAA;AAAA,UAC9C,MAAQ,EAAA;AAAA,YACN,SAAS,iBAAkB,CAAA,YAAA;AAAA,YAC3B,MAAM,iBAAkB,CAAA,SAAA;AAAA,YACxB,UAAU,iBAAkB,CAAA,QAAA;AAAA,WAC9B;AAAA,UACA,OAAU,GAAA;AACR,YAAO,OAAA,EAAE,yBAAU,KAAA,CAAA,aAAA,CAAA,KAAA,CAAM,UAAN,IAAe,CAAA,EAAI,MAAM,QAAS,EAAA,CAAA;AAAA,WACvD;AAAA,SACD,CAAA;AAAA,OACH,CAAA;AAAA,KACF;AAAA,GACF;AACA,EAAA,OAAO,OAAO,MAAO,EAAA,CAAA;AACvB;;;;"}
@@ -0,0 +1,17 @@
1
+ function toInternalExtensionDefinition(overrides) {
2
+ const internal = overrides;
3
+ if (internal.$$type !== "@backstage/ExtensionDefinition") {
4
+ throw new Error(
5
+ `Invalid extension definition instance, bad type '${internal.$$type}'`
6
+ );
7
+ }
8
+ if (internal.version !== "v1") {
9
+ throw new Error(
10
+ `Invalid extension definition instance, bad version '${internal.version}'`
11
+ );
12
+ }
13
+ return internal;
14
+ }
15
+
16
+ export { toInternalExtensionDefinition };
17
+ //# sourceMappingURL=createExtension.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createExtension.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/createExtension.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 { AppNode } from '../apis';\nimport { PortableSchema } from '../schema';\nimport { Expand } from '../types';\nimport { ExtensionDataRef } from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\n\n/** @public */\nexport type AnyExtensionDataMap = {\n [name in string]: ExtensionDataRef<unknown, { optional?: true }>;\n};\n\n/** @public */\nexport type AnyExtensionInputMap = {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataMap,\n { optional: boolean; singleton: boolean }\n >;\n};\n\n/**\n * Converts an extension data map into the matching concrete data values type.\n * @public\n */\nexport type ExtensionDataValues<TExtensionData extends AnyExtensionDataMap> = {\n [DataName in keyof TExtensionData as TExtensionData[DataName]['config'] extends {\n optional: true;\n }\n ? never\n : DataName]: TExtensionData[DataName]['T'];\n} & {\n [DataName in keyof TExtensionData as TExtensionData[DataName]['config'] extends {\n optional: true;\n }\n ? DataName\n : never]?: TExtensionData[DataName]['T'];\n};\n\n/**\n * Convert a single extension input into a matching resolved input.\n * @public\n */\nexport type ResolvedExtensionInput<TExtensionData extends AnyExtensionDataMap> =\n {\n node: AppNode;\n output: ExtensionDataValues<TExtensionData>;\n };\n\n/**\n * Converts an extension input map into a matching collection of resolved inputs.\n * @public\n */\nexport type ResolvedExtensionInputs<\n TInputs extends { [name in string]: ExtensionInput<any, any> },\n> = {\n [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton']\n ? Array<Expand<ResolvedExtensionInput<TInputs[InputName]['extensionData']>>>\n : false extends TInputs[InputName]['config']['optional']\n ? Expand<ResolvedExtensionInput<TInputs[InputName]['extensionData']>>\n : Expand<\n ResolvedExtensionInput<TInputs[InputName]['extensionData']> | undefined\n >;\n};\n\n/** @public */\nexport interface CreateExtensionOptions<\n TOutput extends AnyExtensionDataMap,\n TInputs extends AnyExtensionInputMap,\n TConfig,\n> {\n kind?: string;\n namespace?: string;\n name?: string;\n attachTo: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n output: TOutput;\n configSchema?: PortableSchema<TConfig>;\n factory(options: {\n node: AppNode;\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }): Expand<ExtensionDataValues<TOutput>>;\n}\n\n/** @public */\nexport interface ExtensionDefinition<TConfig> {\n $$type: '@backstage/ExtensionDefinition';\n readonly kind?: string;\n readonly namespace?: string;\n readonly name?: string;\n readonly attachTo: { id: string; input: string };\n readonly disabled: boolean;\n readonly configSchema?: PortableSchema<TConfig>;\n}\n\n/** @internal */\nexport interface InternalExtensionDefinition<TConfig>\n extends ExtensionDefinition<TConfig> {\n readonly version: 'v1';\n readonly inputs: AnyExtensionInputMap;\n readonly output: AnyExtensionDataMap;\n factory(options: {\n node: AppNode;\n config: TConfig;\n inputs: ResolvedExtensionInputs<any>;\n }): ExtensionDataValues<any>;\n}\n\n/** @internal */\nexport function toInternalExtensionDefinition<TConfig>(\n overrides: ExtensionDefinition<TConfig>,\n): InternalExtensionDefinition<TConfig> {\n const internal = overrides as InternalExtensionDefinition<TConfig>;\n if (internal.$$type !== '@backstage/ExtensionDefinition') {\n throw new Error(\n `Invalid extension definition instance, bad type '${internal.$$type}'`,\n );\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid extension definition instance, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n\n/** @public */\nexport function createExtension<\n TOutput extends AnyExtensionDataMap,\n TInputs extends AnyExtensionInputMap,\n TConfig = never,\n>(\n options: CreateExtensionOptions<TOutput, TInputs, TConfig>,\n): ExtensionDefinition<TConfig> {\n return {\n $$type: '@backstage/ExtensionDefinition',\n version: 'v1',\n kind: options.kind,\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo,\n disabled: options.disabled ?? false,\n inputs: options.inputs ?? {},\n output: options.output,\n configSchema: options.configSchema,\n factory({ inputs, ...rest }) {\n // TODO: Simplify this, but TS wouldn't infer the input type for some reason\n return options.factory({\n inputs: inputs as Expand<ResolvedExtensionInputs<TInputs>>,\n ...rest,\n });\n },\n toString() {\n const parts: string[] = [];\n if (options.kind) {\n parts.push(`kind=${options.kind}`);\n }\n if (options.namespace) {\n parts.push(`namespace=${options.namespace}`);\n }\n if (options.name) {\n parts.push(`name=${options.name}`);\n }\n parts.push(`attachTo=${options.attachTo.id}@${options.attachTo.input}`);\n return `ExtensionDefinition{${parts.join(',')}}`;\n },\n } as InternalExtensionDefinition<TConfig>;\n}\n"],"names":[],"mappings":"AA6HO,SAAS,8BACd,SACsC,EAAA;AACtC,EAAA,MAAM,QAAW,GAAA,SAAA,CAAA;AACjB,EAAI,IAAA,QAAA,CAAS,WAAW,gCAAkC,EAAA;AACxD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,iDAAA,EAAoD,SAAS,MAAM,CAAA,CAAA,CAAA;AAAA,KACrE,CAAA;AAAA,GACF;AACA,EAAI,IAAA,QAAA,CAAS,YAAY,IAAM,EAAA;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,oDAAA,EAAuD,SAAS,OAAO,CAAA,CAAA,CAAA;AAAA,KACzE,CAAA;AAAA,GACF;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
@@ -0,0 +1,27 @@
1
+ import { toInternalExtensionDefinition } from './createExtension.esm.js';
2
+
3
+ function resolveExtensionDefinition(definition, context) {
4
+ var _a;
5
+ const internalDefinition = toInternalExtensionDefinition(definition);
6
+ const { name, kind, namespace: _, ...rest } = internalDefinition;
7
+ const namespace = (_a = internalDefinition.namespace) != null ? _a : void 0 ;
8
+ const namePart = name && namespace ? `${namespace}/${name}` : namespace || name;
9
+ if (!namePart) {
10
+ throw new Error(
11
+ `Extension must declare an explicit namespace or name as it could not be resolved from context, kind=${kind} namespace=${namespace} name=${name}`
12
+ );
13
+ }
14
+ const id = kind ? `${kind}:${namePart}` : namePart;
15
+ return {
16
+ ...rest,
17
+ $$type: "@backstage/Extension",
18
+ version: "v1",
19
+ id,
20
+ toString() {
21
+ return `Extension{id=${id}}`;
22
+ }
23
+ };
24
+ }
25
+
26
+ export { resolveExtensionDefinition };
27
+ //# sourceMappingURL=resolveExtensionDefinition.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveExtensionDefinition.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition.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 { AppNode } from '../apis';\nimport {\n AnyExtensionDataMap,\n AnyExtensionInputMap,\n ExtensionDataValues,\n ExtensionDefinition,\n ResolvedExtensionInputs,\n toInternalExtensionDefinition,\n} from './createExtension';\nimport { PortableSchema } from '../schema';\n\n/** @public */\nexport interface Extension<TConfig> {\n $$type: '@backstage/Extension';\n readonly id: string;\n readonly attachTo: { id: string; input: string };\n readonly disabled: boolean;\n readonly configSchema?: PortableSchema<TConfig>;\n}\n\n/** @internal */\nexport interface InternalExtension<TConfig> extends Extension<TConfig> {\n readonly version: 'v1';\n readonly inputs: AnyExtensionInputMap;\n readonly output: AnyExtensionDataMap;\n factory(options: {\n node: AppNode;\n config: TConfig;\n inputs: ResolvedExtensionInputs<any>;\n }): ExtensionDataValues<any>;\n}\n\n/** @internal */\nexport function toInternalExtension<TConfig>(\n overrides: Extension<TConfig>,\n): InternalExtension<TConfig> {\n const internal = overrides as InternalExtension<TConfig>;\n if (internal.$$type !== '@backstage/Extension') {\n throw new Error(\n `Invalid extension instance, bad type '${internal.$$type}'`,\n );\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid extension instance, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n\n/** @internal */\nexport function resolveExtensionDefinition<TConfig>(\n definition: ExtensionDefinition<TConfig>,\n context?: { namespace?: string },\n): Extension<TConfig> {\n const internalDefinition = toInternalExtensionDefinition(definition);\n const { name, kind, namespace: _, ...rest } = internalDefinition;\n const namespace = internalDefinition.namespace ?? context?.namespace;\n\n const namePart =\n name && namespace ? `${namespace}/${name}` : namespace || name;\n if (!namePart) {\n throw new Error(\n `Extension must declare an explicit namespace or name as it could not be resolved from context, kind=${kind} namespace=${namespace} name=${name}`,\n );\n }\n\n const id = kind ? `${kind}:${namePart}` : namePart;\n\n return {\n ...rest,\n $$type: '@backstage/Extension',\n version: 'v1',\n id,\n toString() {\n return `Extension{id=${id}}`;\n },\n } as Extension<TConfig>;\n}\n"],"names":[],"mappings":";;AAmEgB,SAAA,0BAAA,CACd,YACA,OACoB,EAAA;AAtEtB,EAAA,IAAA,EAAA,CAAA;AAuEE,EAAM,MAAA,kBAAA,GAAqB,8BAA8B,UAAU,CAAA,CAAA;AACnE,EAAA,MAAM,EAAE,IAAM,EAAA,IAAA,EAAM,WAAW,CAAG,EAAA,GAAG,MAAS,GAAA,kBAAA,CAAA;AAC9C,EAAA,MAAM,SAAY,GAAA,CAAA,EAAA,GAAA,kBAAA,CAAmB,SAAnB,KAAA,IAAA,GAAA,EAAA,GAAyC,KAAA,CAAA,CAAA,CAAA;AAE3D,EAAM,MAAA,QAAA,GACJ,QAAQ,SAAY,GAAA,CAAA,EAAG,SAAS,CAAI,CAAA,EAAA,IAAI,KAAK,SAAa,IAAA,IAAA,CAAA;AAC5D,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAuG,oGAAA,EAAA,IAAI,CAAc,WAAA,EAAA,SAAS,SAAS,IAAI,CAAA,CAAA;AAAA,KACjJ,CAAA;AAAA,GACF;AAEA,EAAA,MAAM,KAAK,IAAO,GAAA,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,QAAQ,CAAK,CAAA,GAAA,QAAA,CAAA;AAE1C,EAAO,OAAA;AAAA,IACL,GAAG,IAAA;AAAA,IACH,MAAQ,EAAA,sBAAA;AAAA,IACR,OAAS,EAAA,IAAA;AAAA,IACT,EAAA;AAAA,IACA,QAAW,GAAA;AACT,MAAA,OAAO,gBAAgB,EAAE,CAAA,CAAA,CAAA,CAAA;AAAA,KAC3B;AAAA,GACF,CAAA;AACF;;;;"}
package/dist/index.esm.js CHANGED
@@ -1,240 +1,5 @@
1
- import { MockConfigApi } from '@backstage/test-utils';
2
1
  export { MockConfigApi, MockErrorApi, MockFetchApi, MockPermissionApi, MockStorageApi, TestApiProvider, TestApiRegistry, setupRequestMockHandlers, withLogCollector } from '@backstage/test-utils';
3
- import React from 'react';
4
- import { Link, MemoryRouter } from 'react-router-dom';
5
- import { render } from '@testing-library/react';
6
- import { createSpecializedApp } from '@backstage/frontend-app-api';
7
- import { createExtension, createExtensionInput, createNavItemExtension, coreExtensionData, useRouteRef, createExtensionOverrides, createRouterExtension } from '@backstage/frontend-plugin-api';
8
-
9
- var __defProp = Object.defineProperty;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __publicField = (obj, key, value) => {
12
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
13
- return value;
14
- };
15
- class MockAnalyticsApi {
16
- constructor() {
17
- __publicField(this, "events", []);
18
- }
19
- captureEvent(event) {
20
- const { action, subject, value, attributes, context } = event;
21
- this.events.push({
22
- action,
23
- subject,
24
- context,
25
- ...value !== void 0 ? { value } : {},
26
- ...attributes !== void 0 ? { attributes } : {}
27
- });
28
- }
29
- getEvents() {
30
- return this.events;
31
- }
32
- }
33
-
34
- function toInternalExtensionDefinition(overrides) {
35
- const internal = overrides;
36
- if (internal.$$type !== "@backstage/ExtensionDefinition") {
37
- throw new Error(
38
- `Invalid extension definition instance, bad type '${internal.$$type}'`
39
- );
40
- }
41
- if (internal.version !== "v1") {
42
- throw new Error(
43
- `Invalid extension definition instance, bad version '${internal.version}'`
44
- );
45
- }
46
- return internal;
47
- }
48
-
49
- function resolveExtensionDefinition(definition, context) {
50
- var _a;
51
- const internalDefinition = toInternalExtensionDefinition(definition);
52
- const { name, kind, namespace: _, ...rest } = internalDefinition;
53
- const namespace = (_a = internalDefinition.namespace) != null ? _a : context == null ? void 0 : context.namespace;
54
- const namePart = name && namespace ? `${namespace}/${name}` : namespace || name;
55
- if (!namePart) {
56
- throw new Error(
57
- `Extension must declare an explicit namespace or name as it could not be resolved from context, kind=${kind} namespace=${namespace} name=${name}`
58
- );
59
- }
60
- const id = kind ? `${kind}:${namePart}` : namePart;
61
- return {
62
- ...rest,
63
- $$type: "@backstage/Extension",
64
- version: "v1",
65
- id,
66
- toString() {
67
- return `Extension{id=${id}}`;
68
- }
69
- };
70
- }
71
-
72
- var __accessCheck = (obj, member, msg) => {
73
- if (!member.has(obj))
74
- throw TypeError("Cannot " + msg);
75
- };
76
- var __privateGet = (obj, member, getter) => {
77
- __accessCheck(obj, member, "read from private field");
78
- return getter ? getter.call(obj) : member.get(obj);
79
- };
80
- var __privateAdd = (obj, member, value) => {
81
- if (member.has(obj))
82
- throw TypeError("Cannot add the same private member more than once");
83
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
84
- };
85
- var _extensions;
86
- const NavItem = (props) => {
87
- const { routeRef, title, icon: Icon } = props;
88
- const to = useRouteRef(routeRef)();
89
- return /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement(Link, { to }, /* @__PURE__ */ React.createElement(Icon, null), " ", title));
90
- };
91
- const TestAppNavExtension = createExtension({
92
- namespace: "app",
93
- name: "nav",
94
- attachTo: { id: "app/layout", input: "nav" },
95
- inputs: {
96
- items: createExtensionInput({
97
- target: createNavItemExtension.targetDataRef
98
- })
99
- },
100
- output: {
101
- element: coreExtensionData.reactElement
102
- },
103
- factory({ inputs }) {
104
- return {
105
- element: /* @__PURE__ */ React.createElement("nav", null, /* @__PURE__ */ React.createElement("ul", null, inputs.items.map((item, index) => /* @__PURE__ */ React.createElement(
106
- NavItem,
107
- {
108
- key: index,
109
- icon: item.output.target.icon,
110
- title: item.output.target.title,
111
- routeRef: item.output.target.routeRef
112
- }
113
- ))))
114
- };
115
- }
116
- });
117
- const _ExtensionTester = class _ExtensionTester {
118
- constructor() {
119
- __privateAdd(this, _extensions, new Array());
120
- }
121
- /** @internal */
122
- static forSubject(subject, options) {
123
- const tester = new _ExtensionTester();
124
- const { output, factory, ...rest } = toInternalExtensionDefinition(subject);
125
- const extension = createExtension({
126
- ...rest,
127
- attachTo: { id: "app/routes", input: "routes" },
128
- output: {
129
- ...output,
130
- path: coreExtensionData.routePath
131
- },
132
- factory: (params) => ({
133
- ...factory(params),
134
- path: "/"
135
- })
136
- });
137
- tester.add(extension, options);
138
- return tester;
139
- }
140
- add(extension, options) {
141
- const { name, namespace } = extension;
142
- const definition = {
143
- ...extension,
144
- // setting name "test" as fallback
145
- name: !namespace && !name ? "test" : name
146
- };
147
- const { id } = resolveExtensionDefinition(definition);
148
- __privateGet(this, _extensions).push({
149
- id,
150
- definition,
151
- config: options == null ? void 0 : options.config
152
- });
153
- return this;
154
- }
155
- render(options) {
156
- const { config = {} } = options != null ? options : {};
157
- const [subject, ...rest] = __privateGet(this, _extensions);
158
- if (!subject) {
159
- throw new Error(
160
- "No subject found. At least one extension should be added to the tester."
161
- );
162
- }
163
- const extensionsConfig = [
164
- ...rest.map((extension) => ({
165
- [extension.id]: {
166
- config: extension.config
167
- }
168
- })),
169
- {
170
- [subject.id]: {
171
- config: subject.config,
172
- disabled: false
173
- }
174
- }
175
- ];
176
- const finalConfig = {
177
- ...config,
178
- app: {
179
- ...typeof config.app === "object" ? config.app : void 0,
180
- extensions: extensionsConfig
181
- }
182
- };
183
- const app = createSpecializedApp({
184
- features: [
185
- createExtensionOverrides({
186
- extensions: [
187
- ...__privateGet(this, _extensions).map((extension) => extension.definition),
188
- TestAppNavExtension,
189
- createRouterExtension({
190
- namespace: "test",
191
- Component: ({ children }) => /* @__PURE__ */ React.createElement(MemoryRouter, null, children)
192
- })
193
- ]
194
- })
195
- ],
196
- config: new MockConfigApi(finalConfig)
197
- });
198
- return render(app.createRoot());
199
- }
200
- };
201
- _extensions = new WeakMap();
202
- let ExtensionTester = _ExtensionTester;
203
- function createExtensionTester(subject, options) {
204
- return ExtensionTester.forSubject(subject, options);
205
- }
206
-
207
- function renderInTestApp(element, options) {
208
- const extension = createExtension({
209
- namespace: "test",
210
- attachTo: { id: "app", input: "root" },
211
- output: {
212
- element: coreExtensionData.reactElement
213
- },
214
- factory: () => ({ element })
215
- });
216
- const tester = createExtensionTester(extension);
217
- if (options == null ? void 0 : options.mountedRoutes) {
218
- for (const [path, routeRef] of Object.entries(options.mountedRoutes)) {
219
- tester.add(
220
- createExtension({
221
- kind: "test-route",
222
- name: path,
223
- attachTo: { id: "app/root", input: "elements" },
224
- output: {
225
- element: coreExtensionData.reactElement,
226
- path: coreExtensionData.routePath,
227
- routeRef: coreExtensionData.routeRef
228
- },
229
- factory() {
230
- return { element: /* @__PURE__ */ React.createElement(React.Fragment, null), path, routeRef };
231
- }
232
- })
233
- );
234
- }
235
- }
236
- return tester.render();
237
- }
238
-
239
- export { MockAnalyticsApi, createExtensionTester, renderInTestApp };
2
+ export { MockAnalyticsApi } from './apis/AnalyticsApi/MockAnalyticsApi.esm.js';
3
+ export { createExtensionTester } from './app/createExtensionTester.esm.js';
4
+ export { renderInTestApp } from './app/renderInTestApp.esm.js';
240
5
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/apis/AnalyticsApi/MockAnalyticsApi.ts","../../frontend-plugin-api/src/wiring/createExtension.ts","../../frontend-plugin-api/src/wiring/resolveExtensionDefinition.ts","../src/app/createExtensionTester.tsx","../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 { AnalyticsApi, AnalyticsEvent } from '@backstage/frontend-plugin-api';\n\n/**\n * Mock implementation of {@link frontend-plugin-api#AnalyticsApi} with helpers to ensure that events are sent correctly.\n * Use getEvents in tests to verify captured events.\n *\n * @public\n */\nexport class MockAnalyticsApi implements AnalyticsApi {\n private events: AnalyticsEvent[] = [];\n\n captureEvent(event: AnalyticsEvent) {\n const { action, subject, value, attributes, context } = event;\n\n this.events.push({\n action,\n subject,\n context,\n ...(value !== undefined ? { value } : {}),\n ...(attributes !== undefined ? { attributes } : {}),\n });\n }\n\n getEvents(): AnalyticsEvent[] {\n return this.events;\n }\n}\n","/*\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 { AppNode } from '../apis';\nimport { PortableSchema } from '../schema';\nimport { Expand } from '../types';\nimport { ExtensionDataRef } from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\n\n/** @public */\nexport type AnyExtensionDataMap = {\n [name in string]: ExtensionDataRef<unknown, { optional?: true }>;\n};\n\n/** @public */\nexport type AnyExtensionInputMap = {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataMap,\n { optional: boolean; singleton: boolean }\n >;\n};\n\n/**\n * Converts an extension data map into the matching concrete data values type.\n * @public\n */\nexport type ExtensionDataValues<TExtensionData extends AnyExtensionDataMap> = {\n [DataName in keyof TExtensionData as TExtensionData[DataName]['config'] extends {\n optional: true;\n }\n ? never\n : DataName]: TExtensionData[DataName]['T'];\n} & {\n [DataName in keyof TExtensionData as TExtensionData[DataName]['config'] extends {\n optional: true;\n }\n ? DataName\n : never]?: TExtensionData[DataName]['T'];\n};\n\n/**\n * Convert a single extension input into a matching resolved input.\n * @public\n */\nexport type ResolvedExtensionInput<TExtensionData extends AnyExtensionDataMap> =\n {\n node: AppNode;\n output: ExtensionDataValues<TExtensionData>;\n };\n\n/**\n * Converts an extension input map into a matching collection of resolved inputs.\n * @public\n */\nexport type ResolvedExtensionInputs<\n TInputs extends { [name in string]: ExtensionInput<any, any> },\n> = {\n [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton']\n ? Array<Expand<ResolvedExtensionInput<TInputs[InputName]['extensionData']>>>\n : false extends TInputs[InputName]['config']['optional']\n ? Expand<ResolvedExtensionInput<TInputs[InputName]['extensionData']>>\n : Expand<\n ResolvedExtensionInput<TInputs[InputName]['extensionData']> | undefined\n >;\n};\n\n/** @public */\nexport interface CreateExtensionOptions<\n TOutput extends AnyExtensionDataMap,\n TInputs extends AnyExtensionInputMap,\n TConfig,\n> {\n kind?: string;\n namespace?: string;\n name?: string;\n attachTo: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n output: TOutput;\n configSchema?: PortableSchema<TConfig>;\n factory(options: {\n node: AppNode;\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }): Expand<ExtensionDataValues<TOutput>>;\n}\n\n/** @public */\nexport interface ExtensionDefinition<TConfig> {\n $$type: '@backstage/ExtensionDefinition';\n readonly kind?: string;\n readonly namespace?: string;\n readonly name?: string;\n readonly attachTo: { id: string; input: string };\n readonly disabled: boolean;\n readonly configSchema?: PortableSchema<TConfig>;\n}\n\n/** @internal */\nexport interface InternalExtensionDefinition<TConfig>\n extends ExtensionDefinition<TConfig> {\n readonly version: 'v1';\n readonly inputs: AnyExtensionInputMap;\n readonly output: AnyExtensionDataMap;\n factory(options: {\n node: AppNode;\n config: TConfig;\n inputs: ResolvedExtensionInputs<any>;\n }): ExtensionDataValues<any>;\n}\n\n/** @internal */\nexport function toInternalExtensionDefinition<TConfig>(\n overrides: ExtensionDefinition<TConfig>,\n): InternalExtensionDefinition<TConfig> {\n const internal = overrides as InternalExtensionDefinition<TConfig>;\n if (internal.$$type !== '@backstage/ExtensionDefinition') {\n throw new Error(\n `Invalid extension definition instance, bad type '${internal.$$type}'`,\n );\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid extension definition instance, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n\n/** @public */\nexport function createExtension<\n TOutput extends AnyExtensionDataMap,\n TInputs extends AnyExtensionInputMap,\n TConfig = never,\n>(\n options: CreateExtensionOptions<TOutput, TInputs, TConfig>,\n): ExtensionDefinition<TConfig> {\n return {\n $$type: '@backstage/ExtensionDefinition',\n version: 'v1',\n kind: options.kind,\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo,\n disabled: options.disabled ?? false,\n inputs: options.inputs ?? {},\n output: options.output,\n configSchema: options.configSchema,\n factory({ inputs, ...rest }) {\n // TODO: Simplify this, but TS wouldn't infer the input type for some reason\n return options.factory({\n inputs: inputs as Expand<ResolvedExtensionInputs<TInputs>>,\n ...rest,\n });\n },\n toString() {\n const parts: string[] = [];\n if (options.kind) {\n parts.push(`kind=${options.kind}`);\n }\n if (options.namespace) {\n parts.push(`namespace=${options.namespace}`);\n }\n if (options.name) {\n parts.push(`name=${options.name}`);\n }\n parts.push(`attachTo=${options.attachTo.id}@${options.attachTo.input}`);\n return `ExtensionDefinition{${parts.join(',')}}`;\n },\n } as InternalExtensionDefinition<TConfig>;\n}\n","/*\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 { AppNode } from '../apis';\nimport {\n AnyExtensionDataMap,\n AnyExtensionInputMap,\n ExtensionDataValues,\n ExtensionDefinition,\n ResolvedExtensionInputs,\n toInternalExtensionDefinition,\n} from './createExtension';\nimport { PortableSchema } from '../schema';\n\n/** @public */\nexport interface Extension<TConfig> {\n $$type: '@backstage/Extension';\n readonly id: string;\n readonly attachTo: { id: string; input: string };\n readonly disabled: boolean;\n readonly configSchema?: PortableSchema<TConfig>;\n}\n\n/** @internal */\nexport interface InternalExtension<TConfig> extends Extension<TConfig> {\n readonly version: 'v1';\n readonly inputs: AnyExtensionInputMap;\n readonly output: AnyExtensionDataMap;\n factory(options: {\n node: AppNode;\n config: TConfig;\n inputs: ResolvedExtensionInputs<any>;\n }): ExtensionDataValues<any>;\n}\n\n/** @internal */\nexport function toInternalExtension<TConfig>(\n overrides: Extension<TConfig>,\n): InternalExtension<TConfig> {\n const internal = overrides as InternalExtension<TConfig>;\n if (internal.$$type !== '@backstage/Extension') {\n throw new Error(\n `Invalid extension instance, bad type '${internal.$$type}'`,\n );\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid extension instance, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n\n/** @internal */\nexport function resolveExtensionDefinition<TConfig>(\n definition: ExtensionDefinition<TConfig>,\n context?: { namespace?: string },\n): Extension<TConfig> {\n const internalDefinition = toInternalExtensionDefinition(definition);\n const { name, kind, namespace: _, ...rest } = internalDefinition;\n const namespace = internalDefinition.namespace ?? context?.namespace;\n\n const namePart =\n name && namespace ? `${namespace}/${name}` : namespace || name;\n if (!namePart) {\n throw new Error(\n `Extension must declare an explicit namespace or name as it could not be resolved from context, kind=${kind} namespace=${namespace} name=${name}`,\n );\n }\n\n const id = kind ? `${kind}:${namePart}` : namePart;\n\n return {\n ...rest,\n $$type: '@backstage/Extension',\n version: 'v1',\n id,\n toString() {\n return `Extension{id=${id}}`;\n },\n } as Extension<TConfig>;\n}\n","/*\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 { MemoryRouter, Link } from 'react-router-dom';\nimport { RenderResult, render } from '@testing-library/react';\nimport { createSpecializedApp } from '@backstage/frontend-app-api';\nimport {\n ExtensionDefinition,\n IconComponent,\n RouteRef,\n coreExtensionData,\n createExtension,\n createExtensionInput,\n createExtensionOverrides,\n createNavItemExtension,\n createRouterExtension,\n useRouteRef,\n} from '@backstage/frontend-plugin-api';\nimport { MockConfigApi } from '@backstage/test-utils';\nimport { JsonArray, JsonObject, JsonValue } from '@backstage/types';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { resolveExtensionDefinition } from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExtensionDefinition } from '../../../frontend-plugin-api/src/wiring/createExtension';\n\nconst NavItem = (props: {\n routeRef: RouteRef<undefined>;\n title: string;\n icon: IconComponent;\n}) => {\n const { routeRef, title, icon: Icon } = props;\n const to = useRouteRef(routeRef)();\n return (\n <li>\n <Link to={to}>\n <Icon /> {title}\n </Link>\n </li>\n );\n};\n\nconst TestAppNavExtension = createExtension({\n namespace: 'app',\n name: 'nav',\n attachTo: { id: 'app/layout', input: 'nav' },\n inputs: {\n items: createExtensionInput({\n target: createNavItemExtension.targetDataRef,\n }),\n },\n output: {\n element: coreExtensionData.reactElement,\n },\n factory({ inputs }) {\n return {\n element: (\n <nav>\n <ul>\n {inputs.items.map((item, index) => (\n <NavItem\n key={index}\n icon={item.output.target.icon}\n title={item.output.target.title}\n routeRef={item.output.target.routeRef}\n />\n ))}\n </ul>\n </nav>\n ),\n };\n },\n});\n\n/** @public */\nexport class ExtensionTester {\n /** @internal */\n static forSubject<TConfig>(\n subject: ExtensionDefinition<TConfig>,\n options?: { config?: TConfig },\n ): ExtensionTester {\n const tester = new ExtensionTester();\n const { output, factory, ...rest } = toInternalExtensionDefinition(subject);\n // attaching to app/routes to render as index route\n const extension = createExtension({\n ...rest,\n attachTo: { id: 'app/routes', input: 'routes' },\n output: {\n ...output,\n path: coreExtensionData.routePath,\n },\n factory: params => ({\n ...factory(params),\n path: '/',\n }),\n });\n tester.add(extension, options);\n return tester;\n }\n\n readonly #extensions = new Array<{\n id: string;\n definition: ExtensionDefinition<any>;\n config?: JsonValue;\n }>();\n\n add<TConfig>(\n extension: ExtensionDefinition<TConfig>,\n options?: { config?: TConfig },\n ): ExtensionTester {\n const { name, namespace } = extension;\n\n const definition = {\n ...extension,\n // setting name \"test\" as fallback\n name: !namespace && !name ? 'test' : name,\n };\n\n const { id } = resolveExtensionDefinition(definition);\n\n this.#extensions.push({\n id,\n definition,\n config: options?.config as JsonValue,\n });\n\n return this;\n }\n\n render(options?: { config?: JsonObject }): RenderResult {\n const { config = {} } = options ?? {};\n\n const [subject, ...rest] = this.#extensions;\n if (!subject) {\n throw new Error(\n 'No subject found. At least one extension should be added to the tester.',\n );\n }\n\n const extensionsConfig: JsonArray = [\n ...rest.map(extension => ({\n [extension.id]: {\n config: extension.config,\n },\n })),\n {\n [subject.id]: {\n config: subject.config,\n disabled: false,\n },\n },\n ];\n\n const finalConfig = {\n ...config,\n app: {\n ...(typeof config.app === 'object' ? config.app : undefined),\n extensions: extensionsConfig,\n },\n };\n\n const app = createSpecializedApp({\n features: [\n createExtensionOverrides({\n extensions: [\n ...this.#extensions.map(extension => extension.definition),\n TestAppNavExtension,\n createRouterExtension({\n namespace: 'test',\n Component: ({ children }) => (\n <MemoryRouter>{children}</MemoryRouter>\n ),\n }),\n ],\n }),\n ],\n config: new MockConfigApi(finalConfig),\n });\n\n return render(app.createRoot());\n }\n}\n\n/** @public */\nexport function createExtensionTester<TConfig>(\n subject: ExtensionDefinition<TConfig>,\n options?: { config?: TConfig },\n): ExtensionTester {\n return ExtensionTester.forSubject(subject, options);\n}\n","/*\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 {\n RouteRef,\n coreExtensionData,\n createExtension,\n} from '@backstage/frontend-plugin-api';\nimport { createExtensionTester } from './createExtensionTester';\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/**\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) {\n const extension = createExtension({\n namespace: 'test',\n attachTo: { id: 'app', input: 'root' },\n output: {\n element: coreExtensionData.reactElement,\n },\n factory: () => ({ element }),\n });\n const tester = createExtensionTester(extension);\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 tester.add(\n createExtension({\n kind: 'test-route',\n name: path,\n attachTo: { id: 'app/root', input: 'elements' },\n output: {\n element: coreExtensionData.reactElement,\n path: coreExtensionData.routePath,\n routeRef: coreExtensionData.routeRef,\n },\n factory() {\n return { element: <React.Fragment />, path, routeRef };\n },\n }),\n );\n }\n }\n return tester.render();\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAwBO,MAAM,gBAAyC,CAAA;AAAA,EAA/C,WAAA,GAAA;AACL,IAAA,aAAA,CAAA,IAAA,EAAQ,UAA2B,EAAC,CAAA,CAAA;AAAA,GAAA;AAAA,EAEpC,aAAa,KAAuB,EAAA;AAClC,IAAA,MAAM,EAAE,MAAQ,EAAA,OAAA,EAAS,KAAO,EAAA,UAAA,EAAY,SAAY,GAAA,KAAA,CAAA;AAExD,IAAA,IAAA,CAAK,OAAO,IAAK,CAAA;AAAA,MACf,MAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,GAAI,KAAU,KAAA,KAAA,CAAA,GAAY,EAAE,KAAA,KAAU,EAAC;AAAA,MACvC,GAAI,UAAe,KAAA,KAAA,CAAA,GAAY,EAAE,UAAA,KAAe,EAAC;AAAA,KAClD,CAAA,CAAA;AAAA,GACH;AAAA,EAEA,SAA8B,GAAA;AAC5B,IAAA,OAAO,IAAK,CAAA,MAAA,CAAA;AAAA,GACd;AACF;;ACmFO,SAAS,8BACd,S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IACX,QAAU,EAAA,EAAE,EAAI,EAAA,KAAA,EAAO,OAAO,MAAO,EAAA;AAAA,IACrC,MAAQ,EAAA;AAAA,MACN,SAAS,iBAAkB,CAAA,YAAA;AAAA,KAC7B;AAAA,IACA,OAAA,EAAS,OAAO,EAAE,OAAQ,EAAA,CAAA;AAAA,GAC3B,CAAA,CAAA;AACD,EAAM,MAAA,MAAA,GAAS,sBAAsB,SAAS,CAAA,CAAA;AAE9C,EAAA,IAAI,mCAAS,aAAe,EAAA;AAC1B,IAAW,KAAA,MAAA,CAAC,MAAM,QAAQ,CAAA,IAAK,OAAO,OAAQ,CAAA,OAAA,CAAQ,aAAa,CAAG,EAAA;AAEpE,MAAO,MAAA,CAAA,GAAA;AAAA,QACL,eAAgB,CAAA;AAAA,UACd,IAAM,EAAA,YAAA;AAAA,UACN,IAAM,EAAA,IAAA;AAAA,UACN,QAAU,EAAA,EAAE,EAAI,EAAA,UAAA,EAAY,OAAO,UAAW,EAAA;AAAA,UAC9C,MAAQ,EAAA;AAAA,YACN,SAAS,iBAAkB,CAAA,YAAA;AAAA,YAC3B,MAAM,iBAAkB,CAAA,SAAA;AAAA,YACxB,UAAU,iBAAkB,CAAA,QAAA;AAAA,WAC9B;AAAA,UACA,OAAU,GAAA;AACR,YAAO,OAAA,EAAE,yBAAU,KAAA,CAAA,aAAA,CAAA,KAAA,CAAM,UAAN,IAAe,CAAA,EAAI,MAAM,QAAS,EAAA,CAAA;AAAA,WACvD;AAAA,SACD,CAAA;AAAA,OACH,CAAA;AAAA,KACF;AAAA,GACF;AACA,EAAA,OAAO,OAAO,MAAO,EAAA,CAAA;AACvB;;;;"}
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.1.6",
3
+ "version": "0.1.7-next.0",
4
4
  "backstage": {
5
5
  "role": "web-library"
6
6
  },
@@ -31,13 +31,13 @@
31
31
  "test": "backstage-cli package test"
32
32
  },
33
33
  "dependencies": {
34
- "@backstage/frontend-app-api": "^0.6.4",
35
- "@backstage/frontend-plugin-api": "^0.6.4",
36
- "@backstage/test-utils": "^1.5.4",
34
+ "@backstage/frontend-app-api": "^0.6.5-next.0",
35
+ "@backstage/frontend-plugin-api": "^0.6.5-next.0",
36
+ "@backstage/test-utils": "^1.5.5-next.0",
37
37
  "@backstage/types": "^1.1.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@backstage/cli": "^0.26.3",
40
+ "@backstage/cli": "^0.26.5-next.0",
41
41
  "@testing-library/jest-dom": "^6.0.0",
42
42
  "@types/react": "*"
43
43
  },