@backstage/test-utils 0.1.19 → 0.1.20
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 +16 -0
- package/dist/index.d.ts +134 -10
- package/dist/index.esm.js +228 -6
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @backstage/test-utils
|
|
2
2
|
|
|
3
|
+
## 0.1.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bb12aae352: Migrates all utility methods from `test-utils-core` into `test-utils` and delete exports from the old package.
|
|
8
|
+
This should have no impact since this package is considered internal and have no usages outside core packages.
|
|
9
|
+
|
|
10
|
+
Notable changes are that the testing tool `msw.setupDefaultHandlers()` have been deprecated in favour of `setupRequestMockHandlers()`.
|
|
11
|
+
|
|
12
|
+
- c5bb1df55d: Bump `msw` to `v0.35.0` to resolve [CVE-2021-32796](https://github.com/advisories/GHSA-5fg8-2547-mr8q).
|
|
13
|
+
- 10615525f3: Switch to use the json and observable types from `@backstage/types`
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @backstage/theme@0.2.12
|
|
16
|
+
- @backstage/core-app-api@0.1.19
|
|
17
|
+
- @backstage/core-plugin-api@0.1.12
|
|
18
|
+
|
|
3
19
|
## 0.1.19
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,44 @@
|
|
|
1
|
-
import { AnalyticsApi, AnalyticsEvent,
|
|
1
|
+
import { AnalyticsApi, AnalyticsEvent, ErrorContext, ErrorApi, StorageApi, StorageValueChange, RouteRef, ExternalRouteRef } from '@backstage/core-plugin-api';
|
|
2
|
+
import { Observable } from '@backstage/types';
|
|
2
3
|
import { ComponentType, ReactNode, ReactElement } from 'react';
|
|
3
4
|
import { RenderResult } from '@testing-library/react';
|
|
4
|
-
export * from '@backstage/test-utils-core';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Mock implementation of {@link core-plugin-api#AnalyticsApi} with helpers to ensure that events are sent correctly.
|
|
8
|
+
* Use getEvents in tests to verify captured events.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
6
11
|
declare class MockAnalyticsApi implements AnalyticsApi {
|
|
7
12
|
private events;
|
|
8
13
|
captureEvent({ action, subject, value, attributes, context, }: AnalyticsEvent): void;
|
|
9
14
|
getEvents(): AnalyticsEvent[];
|
|
10
15
|
}
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Constructor arguments for {@link MockErrorApi}
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
declare type MockErrorApiOptions = {
|
|
13
22
|
collect?: boolean;
|
|
14
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* ErrorWithContext contains error and ErrorContext
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
15
28
|
declare type ErrorWithContext = {
|
|
16
29
|
error: Error;
|
|
17
30
|
context?: ErrorContext;
|
|
18
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Mock implementation of the {@link core-plugin-api#ErrorApi} to be used in tests.
|
|
34
|
+
* Incudes withForError and getErrors methods for error testing.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
19
37
|
declare class MockErrorApi implements ErrorApi {
|
|
20
38
|
private readonly options;
|
|
21
39
|
private readonly errors;
|
|
22
40
|
private readonly waiters;
|
|
23
|
-
constructor(options?:
|
|
41
|
+
constructor(options?: MockErrorApiOptions);
|
|
24
42
|
post(error: Error, context?: ErrorContext): void;
|
|
25
43
|
error$(): Observable<{
|
|
26
44
|
error: Error;
|
|
@@ -30,9 +48,17 @@ declare class MockErrorApi implements ErrorApi {
|
|
|
30
48
|
waitForError(pattern: RegExp, timeoutMs?: number): Promise<ErrorWithContext>;
|
|
31
49
|
}
|
|
32
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Type for map holding data in {@link MockStorageApi}
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
33
55
|
declare type MockStorageBucket = {
|
|
34
56
|
[key: string]: any;
|
|
35
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Mock implementation of the {@link core-plugin-api#StorageApi} to be used in tests
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
36
62
|
declare class MockStorageApi implements StorageApi {
|
|
37
63
|
private readonly namespace;
|
|
38
64
|
private readonly data;
|
|
@@ -60,7 +86,7 @@ declare class MockStorageApi implements StorageApi {
|
|
|
60
86
|
* If there are any updates from MUI React on testing `useMediaQuery` this mock should be replaced
|
|
61
87
|
* https://material-ui.com/components/use-media-query/#testing
|
|
62
88
|
*
|
|
63
|
-
* @
|
|
89
|
+
* @public
|
|
64
90
|
*/
|
|
65
91
|
declare function mockBreakpoint({ matches }: {
|
|
66
92
|
matches?: boolean | undefined;
|
|
@@ -68,6 +94,7 @@ declare function mockBreakpoint({ matches }: {
|
|
|
68
94
|
|
|
69
95
|
/**
|
|
70
96
|
* Options to customize the behavior of the test app wrapper.
|
|
97
|
+
* @public
|
|
71
98
|
*/
|
|
72
99
|
declare type TestAppOptions = {
|
|
73
100
|
/**
|
|
@@ -80,11 +107,11 @@ declare type TestAppOptions = {
|
|
|
80
107
|
* used by `useRouteRef` in the rendered elements.
|
|
81
108
|
*
|
|
82
109
|
* @example
|
|
83
|
-
* wrapInTestApp(<MyComponent />, {
|
|
84
|
-
* mountedRoutes: {
|
|
110
|
+
* wrapInTestApp(<MyComponent />, \{
|
|
111
|
+
* mountedRoutes: \{
|
|
85
112
|
* '/my-path': myRouteRef,
|
|
86
|
-
* }
|
|
87
|
-
* })
|
|
113
|
+
* \}
|
|
114
|
+
* \})
|
|
88
115
|
* // ...
|
|
89
116
|
* const link = useRouteRef(myRouteRef)
|
|
90
117
|
*/
|
|
@@ -98,6 +125,7 @@ declare type TestAppOptions = {
|
|
|
98
125
|
*
|
|
99
126
|
* @param Component - A component or react node to render inside the test app.
|
|
100
127
|
* @param options - Additional options for the rendering.
|
|
128
|
+
* @public
|
|
101
129
|
*/
|
|
102
130
|
declare function wrapInTestApp(Component: ComponentType | ReactNode, options?: TestAppOptions): ReactElement;
|
|
103
131
|
/**
|
|
@@ -109,9 +137,14 @@ declare function wrapInTestApp(Component: ComponentType | ReactNode, options?: T
|
|
|
109
137
|
*
|
|
110
138
|
* @param Component - A component or react node to render inside the test app.
|
|
111
139
|
* @param options - Additional options for the rendering.
|
|
140
|
+
* @public
|
|
112
141
|
*/
|
|
113
142
|
declare function renderInTestApp(Component: ComponentType | ReactNode, options?: TestAppOptions): Promise<RenderResult>;
|
|
114
143
|
|
|
144
|
+
/**
|
|
145
|
+
* @deprecated use {@link setupRequestMockHandlers} instead which can be called directly with the worker.
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
115
148
|
declare const msw: {
|
|
116
149
|
setupDefaultHandlers: (worker: {
|
|
117
150
|
listen: (t: any) => void;
|
|
@@ -119,5 +152,96 @@ declare const msw: {
|
|
|
119
152
|
resetHandlers: () => void;
|
|
120
153
|
}) => void;
|
|
121
154
|
};
|
|
155
|
+
/**
|
|
156
|
+
* Sets up handlers for request mocking
|
|
157
|
+
* @public
|
|
158
|
+
* @param worker - service worker
|
|
159
|
+
*/
|
|
160
|
+
declare function setupRequestMockHandlers(worker: {
|
|
161
|
+
listen: (t: any) => void;
|
|
162
|
+
close: () => void;
|
|
163
|
+
resetHandlers: () => void;
|
|
164
|
+
}): void;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @public
|
|
168
|
+
* @deprecated because it has no usages. Perhaps resurfaced in the future when need be.
|
|
169
|
+
*/
|
|
170
|
+
declare class Keyboard {
|
|
171
|
+
static type(target: any, input: any): Promise<void>;
|
|
172
|
+
static typeDebug(target: any, input: any): Promise<void>;
|
|
173
|
+
static toReadableInput(chars: any): any;
|
|
174
|
+
static fromReadableInput(input: any): any;
|
|
175
|
+
constructor(target: any, { debug }?: {
|
|
176
|
+
debug?: boolean | undefined;
|
|
177
|
+
});
|
|
178
|
+
debug: boolean;
|
|
179
|
+
document: any;
|
|
180
|
+
toString(): string;
|
|
181
|
+
_log(message: any, ...args: any[]): void;
|
|
182
|
+
_pretty(element: any): string;
|
|
183
|
+
get focused(): any;
|
|
184
|
+
type(input: any): Promise<void>;
|
|
185
|
+
send(chars: any): Promise<void>;
|
|
186
|
+
click(): Promise<void>;
|
|
187
|
+
tab(): Promise<void>;
|
|
188
|
+
enter(value: any): Promise<void>;
|
|
189
|
+
escape(): Promise<void>;
|
|
190
|
+
_sendKey(key: any, charCode: any, action: any): Promise<void>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Severity levels of {@link CollectedLogs}
|
|
195
|
+
* @public */
|
|
196
|
+
declare type LogFuncs = 'log' | 'warn' | 'error';
|
|
197
|
+
/**
|
|
198
|
+
* AsyncLogCollector type used in {@link (withLogCollector:1)} callback function.
|
|
199
|
+
* @public */
|
|
200
|
+
declare type AsyncLogCollector = () => Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* SyncLogCollector type used in {@link (withLogCollector:2)} callback function.
|
|
203
|
+
* @public */
|
|
204
|
+
declare type SyncLogCollector = () => void;
|
|
205
|
+
/**
|
|
206
|
+
* Union type used in {@link (withLogCollector:3)} callback function.
|
|
207
|
+
* @public */
|
|
208
|
+
declare type LogCollector = AsyncLogCollector | SyncLogCollector;
|
|
209
|
+
/**
|
|
210
|
+
* Map of severity level and corresponding log lines.
|
|
211
|
+
* @public */
|
|
212
|
+
declare type CollectedLogs<T extends LogFuncs> = {
|
|
213
|
+
[key in T]: string[];
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Asynchronous log collector with that collects all categories
|
|
217
|
+
* @public */
|
|
218
|
+
declare function withLogCollector(callback: AsyncLogCollector): Promise<CollectedLogs<LogFuncs>>;
|
|
219
|
+
/**
|
|
220
|
+
* Synchronous log collector with that collects all categories
|
|
221
|
+
* @public */
|
|
222
|
+
declare function withLogCollector(callback: SyncLogCollector): CollectedLogs<LogFuncs>;
|
|
223
|
+
/**
|
|
224
|
+
* Asynchronous log collector with that only collects selected categories
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
declare function withLogCollector<T extends LogFuncs>(logsToCollect: T[], callback: AsyncLogCollector): Promise<CollectedLogs<T>>;
|
|
228
|
+
/**
|
|
229
|
+
* Synchronous log collector with that only collects selected categories
|
|
230
|
+
* @public */
|
|
231
|
+
declare function withLogCollector<T extends LogFuncs>(logsToCollect: T[], callback: SyncLogCollector): CollectedLogs<T>;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @public
|
|
235
|
+
* Simplifies rendering of async components in by taking care of the wrapping inside act
|
|
236
|
+
*
|
|
237
|
+
* @remarks
|
|
238
|
+
*
|
|
239
|
+
* Components using useEffect to perform an asynchronous action (such as fetch) must be rendered within an async
|
|
240
|
+
* act call to properly get the final state, even with mocked responses. This utility method makes the signature a bit
|
|
241
|
+
* cleaner, since act doesn't return the result of the evaluated function.
|
|
242
|
+
* https://github.com/testing-library/react-testing-library/issues/281
|
|
243
|
+
* https://github.com/facebook/react/pull/14853
|
|
244
|
+
*/
|
|
245
|
+
declare function renderWithEffects(nodes: ReactElement): Promise<RenderResult>;
|
|
122
246
|
|
|
123
|
-
export { MockAnalyticsApi, MockErrorApi, MockStorageApi, MockStorageBucket, mockBreakpoint, msw, renderInTestApp, wrapInTestApp };
|
|
247
|
+
export { AsyncLogCollector, CollectedLogs, ErrorWithContext, Keyboard, LogCollector, LogFuncs, MockAnalyticsApi, MockErrorApi, MockErrorApiOptions, MockStorageApi, MockStorageBucket, SyncLogCollector, TestAppOptions, mockBreakpoint, msw, renderInTestApp, renderWithEffects, setupRequestMockHandlers, withLogCollector, wrapInTestApp };
|
package/dist/index.esm.js
CHANGED
|
@@ -5,8 +5,8 @@ import { Route } from 'react-router-dom';
|
|
|
5
5
|
import { lightTheme } from '@backstage/theme';
|
|
6
6
|
import { createApp } from '@backstage/core-app-api';
|
|
7
7
|
import { createApiFactory, errorApiRef, storageApiRef, createRouteRef, attachComponentData } from '@backstage/core-plugin-api';
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import { act } from 'react-dom/test-utils';
|
|
9
|
+
import { render, fireEvent, act as act$1 } from '@testing-library/react';
|
|
10
10
|
|
|
11
11
|
class MockAnalyticsApi {
|
|
12
12
|
constructor() {
|
|
@@ -136,6 +136,14 @@ function mockBreakpoint({matches = false}) {
|
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
async function renderWithEffects(nodes) {
|
|
140
|
+
let value;
|
|
141
|
+
await act(async () => {
|
|
142
|
+
value = render(nodes);
|
|
143
|
+
});
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
|
|
139
147
|
const mockApis = [
|
|
140
148
|
createApiFactory(errorApiRef, new MockErrorApi()),
|
|
141
149
|
createApiFactory(storageApiRef, MockStorageApi.create())
|
|
@@ -224,11 +232,225 @@ async function renderInTestApp(Component, options = {}) {
|
|
|
224
232
|
|
|
225
233
|
const msw = {
|
|
226
234
|
setupDefaultHandlers: (worker) => {
|
|
227
|
-
|
|
228
|
-
afterAll(() => worker.close());
|
|
229
|
-
afterEach(() => worker.resetHandlers());
|
|
235
|
+
setupRequestMockHandlers(worker);
|
|
230
236
|
}
|
|
231
237
|
};
|
|
238
|
+
function setupRequestMockHandlers(worker) {
|
|
239
|
+
beforeAll(() => worker.listen({onUnhandledRequest: "error"}));
|
|
240
|
+
afterAll(() => worker.close());
|
|
241
|
+
afterEach(() => worker.resetHandlers());
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const codes = {
|
|
245
|
+
Tab: 9,
|
|
246
|
+
Enter: 10,
|
|
247
|
+
Click: 17,
|
|
248
|
+
Esc: 27
|
|
249
|
+
};
|
|
250
|
+
class Keyboard {
|
|
251
|
+
static async type(target, input) {
|
|
252
|
+
await new Keyboard(target).type(input);
|
|
253
|
+
}
|
|
254
|
+
static async typeDebug(target, input) {
|
|
255
|
+
await new Keyboard(target, {debug: true}).type(input);
|
|
256
|
+
}
|
|
257
|
+
static toReadableInput(chars) {
|
|
258
|
+
return chars.split("").map((char) => {
|
|
259
|
+
switch (char.charCodeAt(0)) {
|
|
260
|
+
case codes.Tab:
|
|
261
|
+
return "<Tab>";
|
|
262
|
+
case codes.Enter:
|
|
263
|
+
return "<Enter>";
|
|
264
|
+
case codes.Click:
|
|
265
|
+
return "<Click>";
|
|
266
|
+
case codes.Esc:
|
|
267
|
+
return "<Esc>";
|
|
268
|
+
default:
|
|
269
|
+
return char;
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
static fromReadableInput(input) {
|
|
274
|
+
return input.trim().replace(/\s*<([a-zA-Z]+)>\s*/g, (match, name) => {
|
|
275
|
+
if (name in codes) {
|
|
276
|
+
return String.fromCharCode(codes[name]);
|
|
277
|
+
}
|
|
278
|
+
throw new Error(`Unknown char name: '${name}'`);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
constructor(target, {debug = false} = {}) {
|
|
282
|
+
this.debug = debug;
|
|
283
|
+
if (target.ownerDocument) {
|
|
284
|
+
this.document = target.ownerDocument;
|
|
285
|
+
} else if (target.baseElement) {
|
|
286
|
+
this.document = target.baseElement.ownerDocument;
|
|
287
|
+
} else {
|
|
288
|
+
throw new TypeError("Keyboard(target): target must be DOM node or react-testing-library render() output");
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
toString() {
|
|
292
|
+
return `Keyboard{document=${this.document}, debug=${this.debug}}`;
|
|
293
|
+
}
|
|
294
|
+
_log(message, ...args) {
|
|
295
|
+
if (this.debug) {
|
|
296
|
+
console.log(`[Keyboard] ${message}`, ...args);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
_pretty(element) {
|
|
300
|
+
const attrs = [...element.attributes].map((attr) => `${attr.name}="${attr.value}"`).join(" ");
|
|
301
|
+
return `<${element.nodeName.toLocaleLowerCase("en-US")} ${attrs}>`;
|
|
302
|
+
}
|
|
303
|
+
get focused() {
|
|
304
|
+
return this.document.activeElement;
|
|
305
|
+
}
|
|
306
|
+
async type(input) {
|
|
307
|
+
this._log(`sending sequence '${input}' with initial focus ${this._pretty(this.focused)}`);
|
|
308
|
+
await this.send(Keyboard.fromReadableInput(input));
|
|
309
|
+
}
|
|
310
|
+
async send(chars) {
|
|
311
|
+
for (const key of chars.split("")) {
|
|
312
|
+
const charCode = key.charCodeAt(0);
|
|
313
|
+
if (charCode === codes.Tab) {
|
|
314
|
+
await this.tab();
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
const focused = this.focused;
|
|
318
|
+
if (!focused || focused === this.document.body) {
|
|
319
|
+
throw Error(`No element focused in document while trying to type '${Keyboard.toReadableInput(chars)}'`);
|
|
320
|
+
}
|
|
321
|
+
const nextValue = (focused.value || "") + key;
|
|
322
|
+
if (charCode >= 32) {
|
|
323
|
+
await this._sendKey(key, charCode, () => {
|
|
324
|
+
this._log(`sending +${key} = '${nextValue}' to ${this._pretty(focused)}`);
|
|
325
|
+
fireEvent.change(focused, {
|
|
326
|
+
target: {value: nextValue},
|
|
327
|
+
bubbles: true,
|
|
328
|
+
cancelable: true
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
} else if (charCode === codes.Enter) {
|
|
332
|
+
await this.enter(focused.value || "");
|
|
333
|
+
} else if (charCode === codes.Esc) {
|
|
334
|
+
await this.escape();
|
|
335
|
+
} else if (charCode === codes.Click) {
|
|
336
|
+
await this.click();
|
|
337
|
+
} else {
|
|
338
|
+
throw new Error(`Unsupported char code, ${charCode}`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
async click() {
|
|
343
|
+
this._log(`clicking ${this._pretty(this.focused)}`);
|
|
344
|
+
await act$1(async () => fireEvent.click(this.focused));
|
|
345
|
+
}
|
|
346
|
+
async tab() {
|
|
347
|
+
await this._sendKey("Tab", codes.Tab, () => {
|
|
348
|
+
const focusable = this.document.querySelectorAll([
|
|
349
|
+
"a[href]",
|
|
350
|
+
"area[href]",
|
|
351
|
+
"input:not([disabled])",
|
|
352
|
+
"select:not([disabled])",
|
|
353
|
+
"textarea:not([disabled])",
|
|
354
|
+
"button:not([disabled])",
|
|
355
|
+
"iframe",
|
|
356
|
+
"object",
|
|
357
|
+
"embed",
|
|
358
|
+
"*[tabindex]",
|
|
359
|
+
"*[contenteditable]"
|
|
360
|
+
].join(","));
|
|
361
|
+
const tabbable = [...focusable].filter((el) => {
|
|
362
|
+
return el.tabIndex >= 0;
|
|
363
|
+
});
|
|
364
|
+
const focused = this.document.activeElement;
|
|
365
|
+
const focusedIndex = tabbable.indexOf(focused);
|
|
366
|
+
const nextFocus = tabbable[focusedIndex + 1 % tabbable.length];
|
|
367
|
+
this._log(`tabbing to ${this._pretty(nextFocus)} ${this.focused.textContent}`);
|
|
368
|
+
nextFocus.focus();
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
async enter(value) {
|
|
372
|
+
this._log(`submitting '${value}' via ${this._pretty(this.focused)}`);
|
|
373
|
+
await act$1(() => this._sendKey("Enter", codes.Enter, () => {
|
|
374
|
+
if (this.focused.type === "button") {
|
|
375
|
+
fireEvent.click(this.focused, {target: {value}});
|
|
376
|
+
} else {
|
|
377
|
+
fireEvent.submit(this.focused, {
|
|
378
|
+
target: {value},
|
|
379
|
+
bubbles: true,
|
|
380
|
+
cancelable: true
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}));
|
|
384
|
+
}
|
|
385
|
+
async escape() {
|
|
386
|
+
this._log(`escape from ${this._pretty(this.focused)}`);
|
|
387
|
+
await act$1(async () => this._sendKey("Escape", codes.Esc));
|
|
388
|
+
}
|
|
389
|
+
async _sendKey(key, charCode, action) {
|
|
390
|
+
const event = {key, charCode, keyCode: charCode, which: charCode};
|
|
391
|
+
const focused = this.focused;
|
|
392
|
+
if (fireEvent.keyDown(focused, event)) {
|
|
393
|
+
if (fireEvent.keyPress(focused, event)) {
|
|
394
|
+
if (action) {
|
|
395
|
+
action();
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
fireEvent.keyUp(focused, event);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const allCategories = ["log", "warn", "error"];
|
|
404
|
+
function withLogCollector(logsToCollect, callback) {
|
|
405
|
+
const oneArg = !callback;
|
|
406
|
+
const actualCallback = oneArg ? logsToCollect : callback;
|
|
407
|
+
const categories = oneArg ? allCategories : logsToCollect;
|
|
408
|
+
const logs = {
|
|
409
|
+
log: new Array(),
|
|
410
|
+
warn: new Array(),
|
|
411
|
+
error: new Array()
|
|
412
|
+
};
|
|
413
|
+
const origLog = console.log;
|
|
414
|
+
const origWarn = console.warn;
|
|
415
|
+
const origError = console.error;
|
|
416
|
+
if (categories.includes("log")) {
|
|
417
|
+
console.log = (message) => {
|
|
418
|
+
logs.log.push(message);
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
if (categories.includes("warn")) {
|
|
422
|
+
console.warn = (message) => {
|
|
423
|
+
logs.warn.push(message);
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
if (categories.includes("error")) {
|
|
427
|
+
console.error = (message) => {
|
|
428
|
+
logs.error.push(message);
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
const restore = () => {
|
|
432
|
+
console.log = origLog;
|
|
433
|
+
console.warn = origWarn;
|
|
434
|
+
console.error = origError;
|
|
435
|
+
};
|
|
436
|
+
try {
|
|
437
|
+
const ret = actualCallback();
|
|
438
|
+
if (!ret || !ret.then) {
|
|
439
|
+
restore();
|
|
440
|
+
return logs;
|
|
441
|
+
}
|
|
442
|
+
return ret.then(() => {
|
|
443
|
+
restore();
|
|
444
|
+
return logs;
|
|
445
|
+
}, (error) => {
|
|
446
|
+
restore();
|
|
447
|
+
throw error;
|
|
448
|
+
});
|
|
449
|
+
} catch (error) {
|
|
450
|
+
restore();
|
|
451
|
+
throw error;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
232
454
|
|
|
233
|
-
export { MockAnalyticsApi, MockErrorApi, MockStorageApi, mockBreakpoint, msw, renderInTestApp, wrapInTestApp };
|
|
455
|
+
export { Keyboard, MockAnalyticsApi, MockErrorApi, MockStorageApi, mockBreakpoint, msw, renderInTestApp, renderWithEffects, setupRequestMockHandlers, withLogCollector, wrapInTestApp };
|
|
234
456
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/testUtils/apis/AnalyticsApi/MockAnalyticsApi.ts","../src/testUtils/apis/ErrorApi/MockErrorApi.ts","../src/testUtils/apis/StorageApi/MockStorageApi.ts","../src/testUtils/mockBreakpoint.ts","../src/testUtils/mockApis.ts","../src/testUtils/appWrappers.tsx","../src/testUtils/msw/index.ts"],"sourcesContent":["/*\n * Copyright 2021 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/core-plugin-api';\n\nexport class MockAnalyticsApi implements AnalyticsApi {\n private events: AnalyticsEvent[] = [];\n\n captureEvent({\n action,\n subject,\n value,\n attributes,\n context,\n }: AnalyticsEvent) {\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 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 { ErrorApi, ErrorContext, Observable } from '@backstage/core-plugin-api';\n\ntype Options = {\n collect?: boolean;\n};\n\ntype ErrorWithContext = {\n error: Error;\n context?: ErrorContext;\n};\n\ntype Waiter = {\n pattern: RegExp;\n resolve: (err: ErrorWithContext) => void;\n};\n\nconst nullObservable = {\n subscribe: () => ({ unsubscribe: () => {}, closed: true }),\n\n [Symbol.observable]() {\n return this;\n },\n};\n\nexport class MockErrorApi implements ErrorApi {\n private readonly errors = new Array<ErrorWithContext>();\n private readonly waiters = new Set<Waiter>();\n\n constructor(private readonly options: Options = {}) {}\n\n post(error: Error, context?: ErrorContext) {\n if (this.options.collect) {\n this.errors.push({ error, context });\n\n for (const waiter of this.waiters) {\n if (waiter.pattern.test(error.message)) {\n this.waiters.delete(waiter);\n waiter.resolve({ error, context });\n }\n }\n\n return;\n }\n\n throw new Error(`MockErrorApi received unexpected error, ${error}`);\n }\n\n error$(): Observable<{ error: Error; context?: ErrorContext }> {\n return nullObservable;\n }\n\n getErrors(): ErrorWithContext[] {\n return this.errors;\n }\n\n waitForError(\n pattern: RegExp,\n timeoutMs: number = 2000,\n ): Promise<ErrorWithContext> {\n return new Promise<ErrorWithContext>((resolve, reject) => {\n setTimeout(() => {\n reject(new Error('Timed out waiting for error'));\n }, timeoutMs);\n\n this.waiters.add({ resolve, pattern });\n });\n }\n}\n","/*\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 {\n Observable,\n StorageApi,\n StorageValueChange,\n} from '@backstage/core-plugin-api';\nimport ObservableImpl from 'zen-observable';\n\nexport type MockStorageBucket = { [key: string]: any };\n\nexport class MockStorageApi implements StorageApi {\n private readonly namespace: string;\n private readonly data: MockStorageBucket;\n private readonly bucketStorageApis: Map<string, MockStorageApi>;\n\n private constructor(\n namespace: string,\n bucketStorageApis: Map<string, MockStorageApi>,\n data?: MockStorageBucket,\n ) {\n this.namespace = namespace;\n this.bucketStorageApis = bucketStorageApis;\n this.data = { ...data };\n }\n\n static create(data?: MockStorageBucket) {\n return new MockStorageApi('', new Map(), data);\n }\n\n forBucket(name: string): StorageApi {\n if (!this.bucketStorageApis.has(name)) {\n this.bucketStorageApis.set(\n name,\n new MockStorageApi(\n `${this.namespace}/${name}`,\n this.bucketStorageApis,\n this.data,\n ),\n );\n }\n return this.bucketStorageApis.get(name)!;\n }\n\n get<T>(key: string): T | undefined {\n return this.data[this.getKeyName(key)];\n }\n\n async set<T>(key: string, data: T): Promise<void> {\n this.data[this.getKeyName(key)] = data;\n this.notifyChanges({ key, newValue: data });\n }\n\n async remove(key: string): Promise<void> {\n delete this.data[this.getKeyName(key)];\n this.notifyChanges({ key, newValue: undefined });\n }\n\n observe$<T>(key: string): Observable<StorageValueChange<T>> {\n return this.observable.filter(({ key: messageKey }) => messageKey === key);\n }\n\n private getKeyName(key: string) {\n return `${this.namespace}/${encodeURIComponent(key)}`;\n }\n\n private notifyChanges<T>(message: StorageValueChange<T>) {\n for (const subscription of this.subscribers) {\n subscription.next(message);\n }\n }\n\n private subscribers = new Set<\n ZenObservable.SubscriptionObserver<StorageValueChange>\n >();\n\n private readonly observable = new ObservableImpl<StorageValueChange>(\n subscriber => {\n this.subscribers.add(subscriber);\n return () => {\n this.subscribers.delete(subscriber);\n };\n },\n );\n}\n","/*\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\n/**\n * This is a mocking method suggested in the Jest Doc's, as it is not implemented in JSDOM yet.\n * It can be used to mock values when the MUI `useMediaQuery` hook if it is used in a tested component.\n *\n * For issues checkout the documentation:\n * https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom\n *\n * If there are any updates from MUI React on testing `useMediaQuery` this mock should be replaced\n * https://material-ui.com/components/use-media-query/#testing\n *\n * @param matchMediaOptions\n */\nexport default function mockBreakpoint({ matches = false }) {\n Object.defineProperty(window, 'matchMedia', {\n writable: true,\n value: jest.fn().mockImplementation(query => ({\n matches: matches,\n media: query,\n onchange: null,\n addListener: jest.fn(), // deprecated\n removeListener: jest.fn(), // deprecated\n addEventListener: jest.fn(),\n removeEventListener: jest.fn(),\n dispatchEvent: jest.fn(),\n })),\n });\n}\n","/*\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 {\n storageApiRef,\n errorApiRef,\n createApiFactory,\n} from '@backstage/core-plugin-api';\nimport { MockErrorApi, MockStorageApi } from './apis';\n\nexport const mockApis = [\n createApiFactory(errorApiRef, new MockErrorApi()),\n createApiFactory(storageApiRef, MockStorageApi.create()),\n];\n","/*\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 React, { ComponentType, ReactNode, ReactElement } from 'react';\nimport { MemoryRouter } from 'react-router';\nimport { Route } from 'react-router-dom';\nimport { lightTheme } from '@backstage/theme';\nimport { createApp } from '@backstage/core-app-api';\nimport {\n BootErrorPageProps,\n RouteRef,\n ExternalRouteRef,\n attachComponentData,\n createRouteRef,\n} from '@backstage/core-plugin-api';\nimport { RenderResult } from '@testing-library/react';\nimport { renderWithEffects } from '@backstage/test-utils-core';\nimport { mockApis } from './mockApis';\n\nconst ErrorBoundaryFallback = ({ error }: { error: Error }) => {\n throw new Error(`Reached ErrorBoundaryFallback Page with error, ${error}`);\n};\nconst NotFoundErrorPage = () => {\n throw new Error('Reached NotFound Page');\n};\nconst BootErrorPage = ({ step, error }: BootErrorPageProps) => {\n throw new Error(`Reached BootError Page at step ${step} with error ${error}`);\n};\nconst Progress = () => <div data-testid=\"progress\" />;\n\n/**\n * Options to customize the behavior of the test app wrapper.\n */\ntype TestAppOptions = {\n /**\n * Initial route entries to pass along as `initialEntries` to the router.\n */\n routeEntries?: string[];\n\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 * wrapInTestApp(<MyComponent />, {\n * mountedRoutes: {\n * '/my-path': myRouteRef,\n * }\n * })\n * // ...\n * const link = useRouteRef(myRouteRef)\n */\n mountedRoutes?: { [path: string]: RouteRef | ExternalRouteRef };\n};\n\nfunction isExternalRouteRef(\n routeRef: RouteRef | ExternalRouteRef,\n): routeRef is ExternalRouteRef {\n // TODO(Rugvip): Least ugly workaround for now, but replace :D\n return String(routeRef).includes('{type=external,');\n}\n\n/**\n * Wraps a component inside a Backstage test app, providing a mocked theme\n * and app context, along with mocked APIs.\n *\n * @param Component - A component or react node to render inside the test app.\n * @param options - Additional options for the rendering.\n */\nexport function wrapInTestApp(\n Component: ComponentType | ReactNode,\n options: TestAppOptions = {},\n): ReactElement {\n const { routeEntries = ['/'] } = options;\n const boundRoutes = new Map<ExternalRouteRef, RouteRef>();\n\n const app = createApp({\n apis: mockApis,\n // Bit of a hack to make sure that the default config loader isn't used\n // as that would force every single test to wait for config loading.\n configLoader: false as unknown as undefined,\n components: {\n Progress,\n BootErrorPage,\n NotFoundErrorPage,\n ErrorBoundaryFallback,\n Router: ({ children }) => (\n <MemoryRouter initialEntries={routeEntries} children={children} />\n ),\n },\n plugins: [],\n themes: [\n {\n id: 'light',\n theme: lightTheme,\n title: 'Test App Theme',\n variant: 'light',\n },\n ],\n bindRoutes: ({ bind }) => {\n for (const [externalRef, absoluteRef] of boundRoutes) {\n bind(\n { ref: externalRef },\n {\n ref: absoluteRef,\n },\n );\n }\n },\n });\n\n let wrappedElement: React.ReactElement;\n if (Component instanceof Function) {\n wrappedElement = <Component />;\n } else {\n wrappedElement = Component as React.ReactElement;\n }\n\n const routeElements = Object.entries(options.mountedRoutes ?? {}).map(\n ([path, routeRef]) => {\n const Page = () => <div>Mounted at {path}</div>;\n\n // Allow external route refs to be bound to paths as well, for convenience.\n // We work around it by creating and binding an absolute ref to the external one.\n if (isExternalRouteRef(routeRef)) {\n const absoluteRef = createRouteRef({ id: 'id' });\n boundRoutes.set(routeRef, absoluteRef);\n attachComponentData(Page, 'core.mountPoint', absoluteRef);\n } else {\n attachComponentData(Page, 'core.mountPoint', routeRef);\n }\n return <Route key={path} path={path} element={<Page />} />;\n },\n );\n\n const AppProvider = app.getProvider();\n const AppRouter = app.getRouter();\n\n return (\n <AppProvider>\n <AppRouter>\n {routeElements}\n {/* The path of * here is needed to be set as a catch all, so it will render the wrapper element\n * and work with nested routes if they exist too */}\n <Route path=\"*\" element={wrappedElement} />\n </AppRouter>\n </AppProvider>\n );\n}\n\n/**\n * Renders a component inside a Backstage test app, providing a mocked theme\n * and app context, along with mocked APIs.\n *\n * The render executes async effects similar to `renderWithEffects`. To avoid this\n * behavior, use a regular `render()` + `wrapInTestApp()` instead.\n *\n * @param Component - A component or react node to render inside the test app.\n * @param options - Additional options for the rendering.\n */\nexport async function renderInTestApp(\n Component: ComponentType | ReactNode,\n options: TestAppOptions = {},\n): Promise<RenderResult> {\n return renderWithEffects(wrapInTestApp(Component, options));\n}\n","/*\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\nexport const msw = {\n setupDefaultHandlers: (worker: {\n listen: (t: any) => void;\n close: () => void;\n resetHandlers: () => void;\n }) => {\n beforeAll(() => worker.listen({ onUnhandledRequest: 'error' }));\n afterAll(() => worker.close());\n afterEach(() => worker.resetHandlers());\n },\n};\n"],"names":[],"mappings":";;;;;;;;;;uBAkBsD;AAAA,EAA/C,cAlBP;AAmBU,kBAA2B;AAAA;AAAA,EAEnC,aAAa;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KACiB;AACjB,SAAK,OAAO,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,SACI,UAAU,SAAY,CAAE,SAAU;AAAA,SAClC,eAAe,SAAY,CAAE,cAAe;AAAA;AAA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AAD;AAAA;AAAA;AAIlD,QAAM,cAAc,IAAI;AACxB,QAAM,YAAY,IAAI;AAEtB,6CACG,aAAD,0CACG,WAAD,MACG,mDAGA,OAAD;AAAA,IAAO,MAAK;AAAA,IAAI,SAAS;AAAA;AAAA;+BAiB/B,WACA,UAA0B,IACH;AACvB,SAAO,kBAAkB,cAAc,WAAW;AAAA;;MClKvC,MAAM;AAAA,EACjB,sBAAsB,CAAC,WAIjB;AACJ,cAAU,MAAM,OAAO,OAAO,CAAE,oBAAoB;AACpD,aAAS,MAAM,OAAO;AACtB,cAAU,MAAM,OAAO;AAAA;AAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/testUtils/apis/AnalyticsApi/MockAnalyticsApi.ts","../src/testUtils/apis/ErrorApi/MockErrorApi.ts","../src/testUtils/apis/StorageApi/MockStorageApi.ts","../src/testUtils/mockBreakpoint.ts","../src/testUtils/testingLibrary.ts","../src/testUtils/mockApis.ts","../src/testUtils/appWrappers.tsx","../src/testUtils/msw/index.ts","../src/testUtils/Keyboard.js","../src/testUtils/logCollector.ts"],"sourcesContent":["/*\n * Copyright 2021 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/core-plugin-api';\n\n/**\n * Mock implementation of {@link core-plugin-api#AnalyticsApi} with helpers to ensure that events are sent correctly.\n * Use getEvents in tests to verify captured events.\n * @public\n */\nexport class MockAnalyticsApi implements AnalyticsApi {\n private events: AnalyticsEvent[] = [];\n\n captureEvent({\n action,\n subject,\n value,\n attributes,\n context,\n }: AnalyticsEvent) {\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 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 { ErrorApi, ErrorContext } from '@backstage/core-plugin-api';\nimport { Observable } from '@backstage/types';\n\n/**\n * Constructor arguments for {@link MockErrorApi}\n * @public\n */\nexport type MockErrorApiOptions = {\n // Need to be true if getErrors is used in testing.\n collect?: boolean;\n};\n\n/**\n * ErrorWithContext contains error and ErrorContext\n * @public\n */\nexport type ErrorWithContext = {\n error: Error;\n context?: ErrorContext;\n};\n\ntype Waiter = {\n pattern: RegExp;\n resolve: (err: ErrorWithContext) => void;\n};\n\nconst nullObservable = {\n subscribe: () => ({ unsubscribe: () => {}, closed: true }),\n\n [Symbol.observable]() {\n return this;\n },\n};\n\n/**\n * Mock implementation of the {@link core-plugin-api#ErrorApi} to be used in tests.\n * Incudes withForError and getErrors methods for error testing.\n * @public\n */\nexport class MockErrorApi implements ErrorApi {\n private readonly errors = new Array<ErrorWithContext>();\n private readonly waiters = new Set<Waiter>();\n\n constructor(private readonly options: MockErrorApiOptions = {}) {}\n\n post(error: Error, context?: ErrorContext) {\n if (this.options.collect) {\n this.errors.push({ error, context });\n\n for (const waiter of this.waiters) {\n if (waiter.pattern.test(error.message)) {\n this.waiters.delete(waiter);\n waiter.resolve({ error, context });\n }\n }\n\n return;\n }\n\n throw new Error(`MockErrorApi received unexpected error, ${error}`);\n }\n\n error$(): Observable<{ error: Error; context?: ErrorContext }> {\n return nullObservable;\n }\n\n getErrors(): ErrorWithContext[] {\n return this.errors;\n }\n\n waitForError(\n pattern: RegExp,\n timeoutMs: number = 2000,\n ): Promise<ErrorWithContext> {\n return new Promise<ErrorWithContext>((resolve, reject) => {\n setTimeout(() => {\n reject(new Error('Timed out waiting for error'));\n }, timeoutMs);\n\n this.waiters.add({ resolve, pattern });\n });\n }\n}\n","/*\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 { StorageApi, StorageValueChange } from '@backstage/core-plugin-api';\nimport { Observable } from '@backstage/types';\nimport ObservableImpl from 'zen-observable';\n\n/**\n * Type for map holding data in {@link MockStorageApi}\n * @public\n */\nexport type MockStorageBucket = { [key: string]: any };\n\n/**\n * Mock implementation of the {@link core-plugin-api#StorageApi} to be used in tests\n * @public\n */\nexport class MockStorageApi implements StorageApi {\n private readonly namespace: string;\n private readonly data: MockStorageBucket;\n private readonly bucketStorageApis: Map<string, MockStorageApi>;\n\n private constructor(\n namespace: string,\n bucketStorageApis: Map<string, MockStorageApi>,\n data?: MockStorageBucket,\n ) {\n this.namespace = namespace;\n this.bucketStorageApis = bucketStorageApis;\n this.data = { ...data };\n }\n\n static create(data?: MockStorageBucket) {\n return new MockStorageApi('', new Map(), data);\n }\n\n forBucket(name: string): StorageApi {\n if (!this.bucketStorageApis.has(name)) {\n this.bucketStorageApis.set(\n name,\n new MockStorageApi(\n `${this.namespace}/${name}`,\n this.bucketStorageApis,\n this.data,\n ),\n );\n }\n return this.bucketStorageApis.get(name)!;\n }\n\n get<T>(key: string): T | undefined {\n return this.data[this.getKeyName(key)];\n }\n\n async set<T>(key: string, data: T): Promise<void> {\n this.data[this.getKeyName(key)] = data;\n this.notifyChanges({ key, newValue: data });\n }\n\n async remove(key: string): Promise<void> {\n delete this.data[this.getKeyName(key)];\n this.notifyChanges({ key, newValue: undefined });\n }\n\n observe$<T>(key: string): Observable<StorageValueChange<T>> {\n return this.observable.filter(({ key: messageKey }) => messageKey === key);\n }\n\n private getKeyName(key: string) {\n return `${this.namespace}/${encodeURIComponent(key)}`;\n }\n\n private notifyChanges<T>(message: StorageValueChange<T>) {\n for (const subscription of this.subscribers) {\n subscription.next(message);\n }\n }\n\n private subscribers = new Set<\n ZenObservable.SubscriptionObserver<StorageValueChange>\n >();\n\n private readonly observable = new ObservableImpl<StorageValueChange>(\n subscriber => {\n this.subscribers.add(subscriber);\n return () => {\n this.subscribers.delete(subscriber);\n };\n },\n );\n}\n","/*\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\n/**\n * This is a mocking method suggested in the Jest Doc's, as it is not implemented in JSDOM yet.\n * It can be used to mock values when the MUI `useMediaQuery` hook if it is used in a tested component.\n *\n * For issues checkout the documentation:\n * https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom\n *\n * If there are any updates from MUI React on testing `useMediaQuery` this mock should be replaced\n * https://material-ui.com/components/use-media-query/#testing\n *\n * @public\n */\nexport default function mockBreakpoint({ matches = false }) {\n Object.defineProperty(window, 'matchMedia', {\n writable: true,\n value: jest.fn().mockImplementation(query => ({\n matches: matches,\n media: query,\n onchange: null,\n addListener: jest.fn(), // deprecated\n removeListener: jest.fn(), // deprecated\n addEventListener: jest.fn(),\n removeEventListener: jest.fn(),\n dispatchEvent: jest.fn(),\n })),\n });\n}\n","/*\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 { ReactElement } from 'react';\nimport { act } from 'react-dom/test-utils';\nimport { render, RenderResult } from '@testing-library/react';\n\n/**\n * @public\n * Simplifies rendering of async components in by taking care of the wrapping inside act\n *\n * @remarks\n *\n * Components using useEffect to perform an asynchronous action (such as fetch) must be rendered within an async\n * act call to properly get the final state, even with mocked responses. This utility method makes the signature a bit\n * cleaner, since act doesn't return the result of the evaluated function.\n * https://github.com/testing-library/react-testing-library/issues/281\n * https://github.com/facebook/react/pull/14853\n */\nexport async function renderWithEffects(\n nodes: ReactElement,\n): Promise<RenderResult> {\n let value: RenderResult;\n await act(async () => {\n value = render(nodes);\n });\n // @ts-ignore\n return value;\n}\n","/*\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 {\n storageApiRef,\n errorApiRef,\n createApiFactory,\n} from '@backstage/core-plugin-api';\nimport { MockErrorApi, MockStorageApi } from './apis';\n\nexport const mockApis = [\n createApiFactory(errorApiRef, new MockErrorApi()),\n createApiFactory(storageApiRef, MockStorageApi.create()),\n];\n","/*\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 React, { ComponentType, ReactNode, ReactElement } from 'react';\nimport { MemoryRouter } from 'react-router';\nimport { Route } from 'react-router-dom';\nimport { lightTheme } from '@backstage/theme';\nimport { createApp } from '@backstage/core-app-api';\nimport {\n BootErrorPageProps,\n RouteRef,\n ExternalRouteRef,\n attachComponentData,\n createRouteRef,\n} from '@backstage/core-plugin-api';\nimport { RenderResult } from '@testing-library/react';\nimport { renderWithEffects } from './testingLibrary';\nimport { mockApis } from './mockApis';\n\nconst ErrorBoundaryFallback = ({ error }: { error: Error }) => {\n throw new Error(`Reached ErrorBoundaryFallback Page with error, ${error}`);\n};\nconst NotFoundErrorPage = () => {\n throw new Error('Reached NotFound Page');\n};\nconst BootErrorPage = ({ step, error }: BootErrorPageProps) => {\n throw new Error(`Reached BootError Page at step ${step} with error ${error}`);\n};\nconst Progress = () => <div data-testid=\"progress\" />;\n\n/**\n * Options to customize the behavior of the test app wrapper.\n * @public\n */\nexport type TestAppOptions = {\n /**\n * Initial route entries to pass along as `initialEntries` to the router.\n */\n routeEntries?: string[];\n\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 * wrapInTestApp(<MyComponent />, \\{\n * mountedRoutes: \\{\n * '/my-path': myRouteRef,\n * \\}\n * \\})\n * // ...\n * const link = useRouteRef(myRouteRef)\n */\n mountedRoutes?: { [path: string]: RouteRef | ExternalRouteRef };\n};\n\nfunction isExternalRouteRef(\n routeRef: RouteRef | ExternalRouteRef,\n): routeRef is ExternalRouteRef {\n // TODO(Rugvip): Least ugly workaround for now, but replace :D\n return String(routeRef).includes('{type=external,');\n}\n\n/**\n * Wraps a component inside a Backstage test app, providing a mocked theme\n * and app context, along with mocked APIs.\n *\n * @param Component - A component or react node to render inside the test app.\n * @param options - Additional options for the rendering.\n * @public\n */\nexport function wrapInTestApp(\n Component: ComponentType | ReactNode,\n options: TestAppOptions = {},\n): ReactElement {\n const { routeEntries = ['/'] } = options;\n const boundRoutes = new Map<ExternalRouteRef, RouteRef>();\n\n const app = createApp({\n apis: mockApis,\n // Bit of a hack to make sure that the default config loader isn't used\n // as that would force every single test to wait for config loading.\n configLoader: false as unknown as undefined,\n components: {\n Progress,\n BootErrorPage,\n NotFoundErrorPage,\n ErrorBoundaryFallback,\n Router: ({ children }) => (\n <MemoryRouter initialEntries={routeEntries} children={children} />\n ),\n },\n plugins: [],\n themes: [\n {\n id: 'light',\n theme: lightTheme,\n title: 'Test App Theme',\n variant: 'light',\n },\n ],\n bindRoutes: ({ bind }) => {\n for (const [externalRef, absoluteRef] of boundRoutes) {\n bind(\n { ref: externalRef },\n {\n ref: absoluteRef,\n },\n );\n }\n },\n });\n\n let wrappedElement: React.ReactElement;\n if (Component instanceof Function) {\n wrappedElement = <Component />;\n } else {\n wrappedElement = Component as React.ReactElement;\n }\n\n const routeElements = Object.entries(options.mountedRoutes ?? {}).map(\n ([path, routeRef]) => {\n const Page = () => <div>Mounted at {path}</div>;\n\n // Allow external route refs to be bound to paths as well, for convenience.\n // We work around it by creating and binding an absolute ref to the external one.\n if (isExternalRouteRef(routeRef)) {\n const absoluteRef = createRouteRef({ id: 'id' });\n boundRoutes.set(routeRef, absoluteRef);\n attachComponentData(Page, 'core.mountPoint', absoluteRef);\n } else {\n attachComponentData(Page, 'core.mountPoint', routeRef);\n }\n return <Route key={path} path={path} element={<Page />} />;\n },\n );\n\n const AppProvider = app.getProvider();\n const AppRouter = app.getRouter();\n\n return (\n <AppProvider>\n <AppRouter>\n {routeElements}\n {/* The path of * here is needed to be set as a catch all, so it will render the wrapper element\n * and work with nested routes if they exist too */}\n <Route path=\"*\" element={wrappedElement} />\n </AppRouter>\n </AppProvider>\n );\n}\n\n/**\n * Renders a component inside a Backstage test app, providing a mocked theme\n * and app context, along with mocked APIs.\n *\n * The render executes async effects similar to `renderWithEffects`. To avoid this\n * behavior, use a regular `render()` + `wrapInTestApp()` instead.\n *\n * @param Component - A component or react node to render inside the test app.\n * @param options - Additional options for the rendering.\n * @public\n */\nexport async function renderInTestApp(\n Component: ComponentType | ReactNode,\n options: TestAppOptions = {},\n): Promise<RenderResult> {\n return renderWithEffects(wrapInTestApp(Component, options));\n}\n","/*\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\n/**\n * @deprecated use {@link setupRequestMockHandlers} instead which can be called directly with the worker.\n * @public\n */\nexport const msw = {\n setupDefaultHandlers: (worker: {\n listen: (t: any) => void;\n close: () => void;\n resetHandlers: () => void;\n }) => {\n setupRequestMockHandlers(worker);\n },\n};\n\n/**\n * Sets up handlers for request mocking\n * @public\n * @param worker - service worker\n */\nexport function setupRequestMockHandlers(worker: {\n listen: (t: any) => void;\n close: () => void;\n resetHandlers: () => void;\n}) {\n beforeAll(() => worker.listen({ onUnhandledRequest: 'error' }));\n afterAll(() => worker.close());\n afterEach(() => worker.resetHandlers());\n}\n","/*\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 { act, fireEvent } from '@testing-library/react';\n\nconst codes = {\n Tab: 9,\n Enter: 10,\n Click: 17 /* This keyboard can click, deal with it */,\n Esc: 27,\n};\n\n/**\n * @public\n * @deprecated because it has no usages. Perhaps resurfaced in the future when need be.\n */\nexport class Keyboard {\n static async type(target, input) {\n await new Keyboard(target).type(input);\n }\n\n static async typeDebug(target, input) {\n await new Keyboard(target, { debug: true }).type(input);\n }\n\n static toReadableInput(chars) {\n return chars.split('').map(char => {\n switch (char.charCodeAt(0)) {\n case codes.Tab:\n return '<Tab>';\n case codes.Enter:\n return '<Enter>';\n case codes.Click:\n return '<Click>';\n case codes.Esc:\n return '<Esc>';\n default:\n return char;\n }\n });\n }\n\n static fromReadableInput(input) {\n return input.trim().replace(/\\s*<([a-zA-Z]+)>\\s*/g, (match, name) => {\n if (name in codes) {\n return String.fromCharCode(codes[name]);\n }\n throw new Error(`Unknown char name: '${name}'`);\n });\n }\n\n constructor(target, { debug = false } = {}) {\n this.debug = debug;\n\n if (target.ownerDocument) {\n this.document = target.ownerDocument;\n } else if (target.baseElement) {\n this.document = target.baseElement.ownerDocument;\n } else {\n throw new TypeError(\n 'Keyboard(target): target must be DOM node or react-testing-library render() output',\n );\n }\n }\n\n toString() {\n return `Keyboard{document=${this.document}, debug=${this.debug}}`;\n }\n\n _log(message, ...args) {\n if (this.debug) {\n // eslint-disable-next-line no-console\n console.log(`[Keyboard] ${message}`, ...args);\n }\n }\n\n _pretty(element) {\n const attrs = [...element.attributes]\n .map(attr => `${attr.name}=\"${attr.value}\"`)\n .join(' ');\n return `<${element.nodeName.toLocaleLowerCase('en-US')} ${attrs}>`;\n }\n\n get focused() {\n return this.document.activeElement;\n }\n\n async type(input) {\n this._log(\n `sending sequence '${input}' with initial focus ${this._pretty(\n this.focused,\n )}`,\n );\n await this.send(Keyboard.fromReadableInput(input));\n }\n\n async send(chars) {\n for (const key of chars.split('')) {\n const charCode = key.charCodeAt(0);\n\n if (charCode === codes.Tab) {\n await this.tab();\n continue;\n }\n\n const focused = this.focused;\n if (!focused || focused === this.document.body) {\n throw Error(\n `No element focused in document while trying to type '${Keyboard.toReadableInput(\n chars,\n )}'`,\n );\n }\n const nextValue = (focused.value || '') + key;\n\n if (charCode >= 32) {\n await this._sendKey(key, charCode, () => {\n this._log(\n `sending +${key} = '${nextValue}' to ${this._pretty(focused)}`,\n );\n fireEvent.change(focused, {\n target: { value: nextValue },\n bubbles: true,\n cancelable: true,\n });\n });\n } else if (charCode === codes.Enter) {\n await this.enter(focused.value || '');\n } else if (charCode === codes.Esc) {\n await this.escape();\n } else if (charCode === codes.Click) {\n await this.click();\n } else {\n throw new Error(`Unsupported char code, ${charCode}`);\n }\n }\n }\n\n async click() {\n this._log(`clicking ${this._pretty(this.focused)}`);\n await act(async () => fireEvent.click(this.focused));\n }\n\n async tab() {\n await this._sendKey('Tab', codes.Tab, () => {\n const focusable = this.document.querySelectorAll(\n [\n 'a[href]',\n 'area[href]',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'button:not([disabled])',\n 'iframe',\n 'object',\n 'embed',\n '*[tabindex]',\n '*[contenteditable]',\n ].join(','),\n );\n\n const tabbable = [...focusable].filter(el => {\n return el.tabIndex >= 0;\n });\n\n const focused = this.document.activeElement;\n const focusedIndex = tabbable.indexOf(focused);\n const nextFocus = tabbable[focusedIndex + (1 % tabbable.length)];\n\n this._log(\n `tabbing to ${this._pretty(nextFocus)} ${this.focused.textContent}`,\n );\n nextFocus.focus();\n });\n }\n\n async enter(value) {\n this._log(`submitting '${value}' via ${this._pretty(this.focused)}`);\n await act(() =>\n this._sendKey('Enter', codes.Enter, () => {\n if (this.focused.type === 'button') {\n fireEvent.click(this.focused, { target: { value } });\n } else {\n fireEvent.submit(this.focused, {\n target: { value },\n bubbles: true,\n cancelable: true,\n });\n }\n }),\n );\n }\n\n async escape() {\n this._log(`escape from ${this._pretty(this.focused)}`);\n await act(async () => this._sendKey('Escape', codes.Esc));\n }\n\n async _sendKey(key, charCode, action) {\n const event = { key, charCode, keyCode: charCode, which: charCode };\n const focused = this.focused;\n\n if (fireEvent.keyDown(focused, event)) {\n if (fireEvent.keyPress(focused, event)) {\n if (action) {\n action();\n }\n }\n }\n fireEvent.keyUp(focused, event);\n }\n}\n","/*\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\n/* eslint-disable no-console */\n\n/**\n * Severity levels of {@link CollectedLogs}\n * @public */\nexport type LogFuncs = 'log' | 'warn' | 'error';\n/**\n * AsyncLogCollector type used in {@link (withLogCollector:1)} callback function.\n * @public */\nexport type AsyncLogCollector = () => Promise<void>;\n/**\n * SyncLogCollector type used in {@link (withLogCollector:2)} callback function.\n * @public */\nexport type SyncLogCollector = () => void;\n/**\n * Union type used in {@link (withLogCollector:3)} callback function.\n * @public */\nexport type LogCollector = AsyncLogCollector | SyncLogCollector;\n/**\n * Map of severity level and corresponding log lines.\n * @public */\nexport type CollectedLogs<T extends LogFuncs> = { [key in T]: string[] };\n\nconst allCategories = ['log', 'warn', 'error'];\n\n/**\n * Asynchronous log collector with that collects all categories\n * @public */\nexport function withLogCollector(\n callback: AsyncLogCollector,\n): Promise<CollectedLogs<LogFuncs>>;\n\n/**\n * Synchronous log collector with that collects all categories\n * @public */\nexport function withLogCollector(\n callback: SyncLogCollector,\n): CollectedLogs<LogFuncs>;\n\n/**\n * Asynchronous log collector with that only collects selected categories\n * @public\n */\nexport function withLogCollector<T extends LogFuncs>(\n logsToCollect: T[],\n callback: AsyncLogCollector,\n): Promise<CollectedLogs<T>>;\n\n/**\n * Synchronous log collector with that only collects selected categories\n * @public */\nexport function withLogCollector<T extends LogFuncs>(\n logsToCollect: T[],\n callback: SyncLogCollector,\n): CollectedLogs<T>;\n\n/**\n * Log collector that collect logs either from a sync or async collector.\n * @public\n * @deprecated import from test-utils instead\n * */\nexport function withLogCollector(\n logsToCollect: LogFuncs[] | LogCollector,\n callback?: LogCollector,\n): CollectedLogs<LogFuncs> | Promise<CollectedLogs<LogFuncs>> {\n const oneArg = !callback;\n const actualCallback = (oneArg ? logsToCollect : callback) as LogCollector;\n const categories = (oneArg ? allCategories : logsToCollect) as LogFuncs[];\n\n const logs = {\n log: new Array<string>(),\n warn: new Array<string>(),\n error: new Array<string>(),\n };\n\n const origLog = console.log;\n const origWarn = console.warn;\n const origError = console.error;\n\n if (categories.includes('log')) {\n console.log = (message: string) => {\n logs.log.push(message);\n };\n }\n if (categories.includes('warn')) {\n console.warn = (message: string) => {\n logs.warn.push(message);\n };\n }\n if (categories.includes('error')) {\n console.error = (message: string) => {\n logs.error.push(message);\n };\n }\n\n const restore = () => {\n console.log = origLog;\n console.warn = origWarn;\n console.error = origError;\n };\n\n try {\n const ret = actualCallback();\n\n if (!ret || !ret.then) {\n restore();\n return logs;\n }\n\n return ret.then(\n () => {\n restore();\n return logs;\n },\n error => {\n restore();\n throw error;\n },\n );\n } catch (error) {\n restore();\n throw error;\n }\n}\n"],"names":["act"],"mappings":";;;;;;;;;;uBAuBsD;AAAA,EAA/C,cAvBP;AAwBU,kBAA2B;AAAA;AAAA,EAEnC,aAAa;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KACiB;AACjB,SAAK,OAAO,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,SACI,UAAU,SAAY,C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;AACrB;AACA,aAAO;AAAA;AAGT,WAAO,IAAI,KACT,MAAM;AACJ;AACA,aAAO;AAAA,OAET,WAAS;AACP;AACA,YAAM;AAAA;AAAA,WAGH,OAAP;AACA;AACA,UAAM;AAAA;AAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/test-utils",
|
|
3
3
|
"description": "Utilities to test Backstage plugins and apps.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.20",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -29,16 +29,15 @@
|
|
|
29
29
|
"clean": "backstage-cli clean"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@backstage/core-app-api": "^0.1.
|
|
33
|
-
"@backstage/core-plugin-api": "^0.1.
|
|
34
|
-
"@backstage/
|
|
35
|
-
"@backstage/
|
|
32
|
+
"@backstage/core-app-api": "^0.1.19",
|
|
33
|
+
"@backstage/core-plugin-api": "^0.1.12",
|
|
34
|
+
"@backstage/theme": "^0.2.12",
|
|
35
|
+
"@backstage/types": "^0.1.1",
|
|
36
36
|
"@material-ui/core": "^4.12.2",
|
|
37
37
|
"@testing-library/jest-dom": "^5.10.1",
|
|
38
38
|
"@testing-library/react": "^11.2.5",
|
|
39
39
|
"@testing-library/user-event": "^13.1.8",
|
|
40
40
|
"@types/react": "*",
|
|
41
|
-
"msw": "^0.29.0",
|
|
42
41
|
"react": "^16.12.0",
|
|
43
42
|
"react-dom": "^16.12.0",
|
|
44
43
|
"react-router": "6.0.0-beta.0",
|
|
@@ -46,12 +45,12 @@
|
|
|
46
45
|
"zen-observable": "^0.8.15"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"@backstage/cli": "^0.
|
|
48
|
+
"@backstage/cli": "^0.8.1",
|
|
50
49
|
"@types/jest": "^26.0.7",
|
|
51
50
|
"@types/node": "^14.14.32"
|
|
52
51
|
},
|
|
53
52
|
"files": [
|
|
54
53
|
"dist"
|
|
55
54
|
],
|
|
56
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "3db0cb3683d3000666802af90a465ba4fb0d1e8d"
|
|
57
56
|
}
|