From dc12852c9e78e9b9884f2de5420eed50596a25d0 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Tue, 16 Feb 2021 14:54:35 +0100 Subject: [PATCH] test-utils: Allow ExternalRouteRef on mountedRoutes Co-authored-by: Patrik Oldsberg --- .changeset/cyan-dingos-watch.md | 5 +++++ packages/test-utils/src/testUtils/appWrappers.tsx | 3 ++- .../catalog/src/components/CatalogPage/CatalogPage.test.tsx | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/cyan-dingos-watch.md diff --git a/.changeset/cyan-dingos-watch.md b/.changeset/cyan-dingos-watch.md new file mode 100644 index 0000000000..7b15d30112 --- /dev/null +++ b/.changeset/cyan-dingos-watch.md @@ -0,0 +1,5 @@ +--- +'@backstage/test-utils': patch +--- + +Allow `ExternalRouteRef` instances to be passed as a route ref to `mountedRoutes`. diff --git a/packages/test-utils/src/testUtils/appWrappers.tsx b/packages/test-utils/src/testUtils/appWrappers.tsx index cc67a5b707..56d6e07805 100644 --- a/packages/test-utils/src/testUtils/appWrappers.tsx +++ b/packages/test-utils/src/testUtils/appWrappers.tsx @@ -22,6 +22,7 @@ import privateExports, { defaultSystemIcons, BootErrorPageProps, RouteRef, + ExternalRouteRef, createPlugin, createRoutableExtension, } from '@backstage/core-api'; @@ -62,7 +63,7 @@ type TestAppOptions = { * // ... * const link = useRouteRef(myRouteRef) */ - mountedRoutes?: { [path: string]: RouteRef }; + mountedRoutes?: { [path: string]: RouteRef | ExternalRouteRef }; }; /** diff --git a/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx b/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx index 6d4d18e4f2..accfe6eda4 100644 --- a/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx +++ b/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx @@ -33,6 +33,7 @@ import { MockStorageApi, wrapInTestApp } from '@backstage/test-utils'; import { fireEvent, render, waitFor } from '@testing-library/react'; import React from 'react'; import { EntityFilterGroupsProvider } from '../../filter'; +import { createComponentRouteRef } from '../../routes'; import { CatalogPage } from './CatalogPage'; describe('CatalogPage', () => { @@ -116,6 +117,11 @@ describe('CatalogPage', () => { > {children}, , + { + mountedRoutes: { + '/create': createComponentRouteRef, + }, + }, ), );